diff --git a/src/main/java/net/minecraftforge/common/util/EntitySnapshot.java b/src/main/java/net/minecraftforge/common/util/EntitySnapshot.java new file mode 100644 index 0000000..0e702d8 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/EntitySnapshot.java @@ -0,0 +1,27 @@ +package net.minecraftforge.common.util; + +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; + +public class EntitySnapshot{ + + public final World mWorld; + public final Entity mEntity; + public final SpawnReason mReason; + + public EntitySnapshot(World pWorld,Entity pEntity,SpawnReason pReason){ + this.mWorld=pWorld; + this.mEntity=pEntity; + this.mReason=pReason==null?SpawnReason.CUSTOM:pReason; + } + + public boolean apply(){ + return this.mWorld.addEntity(this.mEntity,this.mReason); + } + + public void cancel(){ + this.mEntity.setDead(); + this.mWorld.removeEntity(this.mEntity); + } +}