From 8b3326270149d21c8c592fb9aa380a5b67db7b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=81=AA=E8=81=AA?= <178666380@qq.com> Date: Sun, 25 Jun 2017 20:22:28 +0800 Subject: [PATCH] add new class --- .../common/util/EntitySnapshot.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/net/minecraftforge/common/util/EntitySnapshot.java 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); + } +}