mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
183 lines
6.1 KiB
Diff
183 lines
6.1 KiB
Diff
--- ../src_base/common/net/minecraft/src/Entity.java
|
|
+++ ../src_work/common/net/minecraft/src/Entity.java
|
|
@@ -4,6 +4,8 @@
|
|
import cpw.mods.fml.common.asm.SideOnly;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
+import java.util.UUID;
|
|
+import java.util.ArrayList;
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
public abstract class Entity
|
|
@@ -197,6 +199,11 @@
|
|
protected int field_82152_aq;
|
|
private boolean field_83001_bt;
|
|
public EnumEntitySize myEntitySize;
|
|
+ /** Forge: Used to store custom data for each entity. */
|
|
+ private NBTTagCompound customEntityData;
|
|
+ public boolean captureDrops = false;
|
|
+ public ArrayList<EntityItem> capturedDrops = new ArrayList<EntityItem>();
|
|
+ private UUID persistentID;
|
|
|
|
public Entity(World par1World)
|
|
{
|
|
@@ -519,7 +526,7 @@
|
|
if (!this.worldObj.isRemote)
|
|
{
|
|
this.setFlag(0, this.fire > 0);
|
|
- this.setFlag(2, this.ridingEntity != null);
|
|
+ this.setFlag(2, this.ridingEntity != null && ridingEntity.shouldRiderSit());
|
|
}
|
|
|
|
this.firstUpdate = false;
|
|
@@ -1489,6 +1496,15 @@
|
|
par1NBTTagCompound.setInteger("Dimension", this.dimension);
|
|
par1NBTTagCompound.setBoolean("Invulnerable", this.field_83001_bt);
|
|
par1NBTTagCompound.setInteger("PortalCooldown", this.timeUntilPortal);
|
|
+ if (persistentID != null)
|
|
+ {
|
|
+ par1NBTTagCompound.setLong("PersistentIDMSB", persistentID.getMostSignificantBits());
|
|
+ par1NBTTagCompound.setLong("PersistentIDLSB", persistentID.getLeastSignificantBits());
|
|
+ }
|
|
+ if (customEntityData != null)
|
|
+ {
|
|
+ par1NBTTagCompound.setCompoundTag("ForgeData", customEntityData);
|
|
+ }
|
|
this.writeEntityToNBT(par1NBTTagCompound);
|
|
}
|
|
catch (Throwable var5)
|
|
@@ -1543,6 +1559,14 @@
|
|
this.timeUntilPortal = par1NBTTagCompound.getInteger("PortalCooldown");
|
|
this.setPosition(this.posX, this.posY, this.posZ);
|
|
this.setRotation(this.rotationYaw, this.rotationPitch);
|
|
+ if (par1NBTTagCompound.hasKey("ForgeData"))
|
|
+ {
|
|
+ customEntityData = par1NBTTagCompound.getCompoundTag("ForgeData");
|
|
+ }
|
|
+ if (par1NBTTagCompound.hasKey("PersistentIDMSB") && par1NBTTagCompound.hasKey("PersistentIDLSB"))
|
|
+ {
|
|
+ persistentID = new UUID(par1NBTTagCompound.getLong("PersistentIDMSB"), par1NBTTagCompound.getLong("PersistentIDLSB"));
|
|
+ }
|
|
this.readEntityFromNBT(par1NBTTagCompound);
|
|
}
|
|
catch (Throwable var5)
|
|
@@ -1637,7 +1661,14 @@
|
|
{
|
|
EntityItem var3 = new EntityItem(this.worldObj, this.posX, this.posY + (double)par2, this.posZ, par1ItemStack);
|
|
var3.delayBeforeCanPickup = 10;
|
|
- this.worldObj.spawnEntityInWorld(var3);
|
|
+ if (captureDrops)
|
|
+ {
|
|
+ capturedDrops.add(var3);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ this.worldObj.spawnEntityInWorld(var3);
|
|
+ }
|
|
return var3;
|
|
}
|
|
|
|
@@ -1996,7 +2027,7 @@
|
|
*/
|
|
public boolean isRiding()
|
|
{
|
|
- return this.ridingEntity != null || this.getFlag(2);
|
|
+ return (this.ridingEntity != null && ridingEntity.shouldRiderSit()) || this.getFlag(2);
|
|
}
|
|
|
|
/**
|
|
@@ -2331,7 +2362,7 @@
|
|
|
|
public float func_82146_a(Explosion par1Explosion, Block par2Block, int par3, int par4, int par5)
|
|
{
|
|
- return par2Block.getExplosionResistance(this);
|
|
+ return par2Block.getExplosionResistance(this, worldObj, par3, par4, par5, posX, posY + (double)getEyeHeight(), posZ);
|
|
}
|
|
|
|
public int func_82143_as()
|
|
@@ -2367,4 +2398,84 @@
|
|
{
|
|
return this.isBurning();
|
|
}
|
|
+
|
|
+ /* ================================== Forge Start =====================================*/
|
|
+ /**
|
|
+ * Returns a NBTTagCompound that can be used to store custom data for this entity.
|
|
+ * It will be written, and read from disc, so it persists over world saves.
|
|
+ * @return A NBTTagCompound
|
|
+ */
|
|
+ public NBTTagCompound getEntityData()
|
|
+ {
|
|
+ if (customEntityData == null)
|
|
+ {
|
|
+ customEntityData = new NBTTagCompound();
|
|
+ }
|
|
+ return customEntityData;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Used in model rendering to determine if the entity riding this entity should be in the 'sitting' position.
|
|
+ * @return false to prevent an entity that is mounted to this entity from displaying the 'sitting' animation.
|
|
+ */
|
|
+ public boolean shouldRiderSit()
|
|
+ {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Called when a user uses the creative pick block button on this entity.
|
|
+ *
|
|
+ * @param target The full target the player is looking at
|
|
+ * @return A ItemStack to add to the player's inventory, Null if nothing should be added.
|
|
+ */
|
|
+ public ItemStack getPickedResult(MovingObjectPosition target)
|
|
+ {
|
|
+ if (this instanceof EntityPainting)
|
|
+ {
|
|
+ return new ItemStack(Item.painting);
|
|
+ }
|
|
+ else if (this instanceof EntityMinecart)
|
|
+ {
|
|
+ return ((EntityMinecart)this).getCartItem();
|
|
+ }
|
|
+ else if (this instanceof EntityBoat)
|
|
+ {
|
|
+ return new ItemStack(Item.boat);
|
|
+ }
|
|
+ else if (this instanceof EntityItemFrame)
|
|
+ {
|
|
+ ItemStack held = ((EntityItemFrame)this).getDisplayedItem();
|
|
+ if (held == null)
|
|
+ {
|
|
+ return new ItemStack(Item.itemFrame);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ return held.copy();
|
|
+ }
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ int id = EntityList.getEntityID(this);
|
|
+ if (id > 0 && EntityList.entityEggs.containsKey(id))
|
|
+ {
|
|
+ return new ItemStack(Item.monsterPlacer, 1, id);
|
|
+ }
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ public UUID getPersistentID()
|
|
+ {
|
|
+ return persistentID;
|
|
+ }
|
|
+
|
|
+ public synchronized void generatePersistentID()
|
|
+ {
|
|
+ if (persistentID == null)
|
|
+ {
|
|
+ persistentID = UUID.randomUUID();
|
|
+ }
|
|
+ }
|
|
}
|