2012-08-09 10:06:41 +00:00
|
|
|
--- ../src_base/common/net/minecraft/src/Entity.java
|
|
|
|
+++ ../src_work/common/net/minecraft/src/Entity.java
|
2012-10-21 17:20:39 +00:00
|
|
|
@@ -5,6 +5,8 @@
|
2012-08-06 22:07:53 +00:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
2012-09-22 16:27:14 +00:00
|
|
|
+import java.util.UUID;
|
2012-10-21 17:20:39 +00:00
|
|
|
+import java.util.ArrayList;
|
|
|
|
import net.minecraft.server.MinecraftServer;
|
2012-09-22 16:27:14 +00:00
|
|
|
|
|
|
|
public abstract class Entity
|
2012-10-21 17:20:39 +00:00
|
|
|
@@ -197,6 +199,11 @@
|
|
|
|
public int dimension;
|
|
|
|
protected int field_82152_aq;
|
2012-08-06 22:07:53 +00:00
|
|
|
public EnumEntitySize myEntitySize;
|
|
|
|
+ /** Forge: Used to store custom data for each entity. */
|
|
|
|
+ private NBTTagCompound customEntityData;
|
2012-09-11 22:27:34 +00:00
|
|
|
+ public boolean captureDrops = false;
|
|
|
|
+ public ArrayList<EntityItem> capturedDrops = new ArrayList<EntityItem>();
|
2012-09-22 16:27:14 +00:00
|
|
|
+ private UUID persistentID;
|
2012-08-09 10:06:41 +00:00
|
|
|
|
2012-08-06 22:07:53 +00:00
|
|
|
public Entity(World par1World)
|
|
|
|
{
|
2012-10-31 17:16:46 +00:00
|
|
|
@@ -1466,6 +1473,15 @@
|
2012-08-06 22:07:53 +00:00
|
|
|
par1NBTTagCompound.setShort("Air", (short)this.getAir());
|
|
|
|
par1NBTTagCompound.setBoolean("OnGround", this.onGround);
|
2012-10-21 17:20:39 +00:00
|
|
|
par1NBTTagCompound.setInteger("Dimension", this.dimension);
|
2012-09-22 16:27:14 +00:00
|
|
|
+ if (persistentID != null)
|
|
|
|
+ {
|
|
|
|
+ par1NBTTagCompound.setLong("PersistentIDMSB", persistentID.getMostSignificantBits());
|
|
|
|
+ par1NBTTagCompound.setLong("PersistentIDLSB", persistentID.getLeastSignificantBits());
|
|
|
|
+ }
|
2012-08-06 22:07:53 +00:00
|
|
|
+ if (customEntityData != null)
|
|
|
|
+ {
|
|
|
|
+ par1NBTTagCompound.setCompoundTag("ForgeData", customEntityData);
|
|
|
|
+ }
|
|
|
|
this.writeEntityToNBT(par1NBTTagCompound);
|
|
|
|
}
|
|
|
|
|
2012-10-31 17:16:46 +00:00
|
|
|
@@ -1508,6 +1524,14 @@
|
2012-10-21 17:20:39 +00:00
|
|
|
this.dimension = par1NBTTagCompound.getInteger("Dimension");
|
2012-08-06 22:07:53 +00:00
|
|
|
this.setPosition(this.posX, this.posY, this.posZ);
|
|
|
|
this.setRotation(this.rotationYaw, this.rotationPitch);
|
|
|
|
+ if (par1NBTTagCompound.hasKey("ForgeData"))
|
|
|
|
+ {
|
|
|
|
+ customEntityData = par1NBTTagCompound.getCompoundTag("ForgeData");
|
2012-09-22 16:27:14 +00:00
|
|
|
+ }
|
|
|
|
+ if (par1NBTTagCompound.hasKey("PersistentIDMSB") && par1NBTTagCompound.hasKey("PersistentIDLSB"))
|
|
|
|
+ {
|
|
|
|
+ persistentID = new UUID(par1NBTTagCompound.getLong("PersistentIDMSB"), par1NBTTagCompound.getLong("PersistentIDLSB"));
|
2012-08-06 22:07:53 +00:00
|
|
|
+ }
|
|
|
|
this.readEntityFromNBT(par1NBTTagCompound);
|
|
|
|
}
|
|
|
|
|
2012-10-31 17:16:46 +00:00
|
|
|
@@ -1594,7 +1618,14 @@
|
2012-08-06 22:07:53 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-10-31 17:16:46 +00:00
|
|
|
@@ -1954,7 +1985,7 @@
|
2012-08-06 22:07:53 +00:00
|
|
|
*/
|
|
|
|
public boolean isRiding()
|
|
|
|
{
|
|
|
|
- return this.ridingEntity != null || this.getFlag(2);
|
|
|
|
+ return (this.ridingEntity != null && ridingEntity.shouldRiderSit()) || this.getFlag(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-10-31 17:16:46 +00:00
|
|
|
@@ -2279,7 +2310,7 @@
|
2012-10-21 17:20:39 +00:00
|
|
|
|
|
|
|
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()
|
2012-10-31 17:16:46 +00:00
|
|
|
@@ -2299,4 +2330,84 @@
|
2012-08-06 22:07:53 +00:00
|
|
|
{
|
2012-10-21 17:20:39 +00:00
|
|
|
return false;
|
2012-08-06 22:07:53 +00:00
|
|
|
}
|
|
|
|
+
|
2012-08-10 09:09:11 +00:00
|
|
|
+ /* ================================== Forge Start =====================================*/
|
2012-08-06 22:07:53 +00:00
|
|
|
+ /**
|
|
|
|
+ * 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;
|
|
|
|
+ }
|
2012-08-09 10:06:41 +00:00
|
|
|
+
|
2012-08-06 22:07:53 +00:00
|
|
|
+ /**
|
|
|
|
+ * 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;
|
2012-08-10 09:09:11 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Called when a user uses the creative pick block button on this entity.
|
2012-09-22 16:27:14 +00:00
|
|
|
+ *
|
2012-08-10 09:09:11 +00:00
|
|
|
+ * @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);
|
|
|
|
+ }
|
2012-10-21 17:20:39 +00:00
|
|
|
+ else if (this instanceof EntityItemFrame)
|
|
|
|
+ {
|
|
|
|
+ ItemStack held = ((EntityItemFrame)this).func_82335_i();
|
|
|
|
+ if (held == null)
|
|
|
|
+ {
|
2012-10-31 17:16:46 +00:00
|
|
|
+ return new ItemStack(Item.itemFrame);
|
2012-10-21 17:20:39 +00:00
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return held.copy();
|
|
|
|
+ }
|
|
|
|
+ }
|
2012-08-10 09:09:11 +00:00
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ int id = EntityList.getEntityID(this);
|
2012-09-18 14:55:11 +00:00
|
|
|
+ if (id > 0 && EntityList.entityEggs.containsKey(id))
|
2012-08-10 09:09:11 +00:00
|
|
|
+ {
|
|
|
|
+ return new ItemStack(Item.monsterPlacer, 1, id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
2012-09-22 16:27:14 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public UUID getPersistentID()
|
|
|
|
+ {
|
|
|
|
+ return persistentID;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public synchronized void generatePersistentID()
|
|
|
|
+ {
|
|
|
|
+ if (persistentID == null)
|
|
|
|
+ {
|
|
|
|
+ persistentID = UUID.randomUUID();
|
|
|
|
+ }
|
2012-08-06 22:07:53 +00:00
|
|
|
+ }
|
|
|
|
}
|