ForgePatch/patches/minecraft/net/minecraft/src/Entity.java.patch

99 lines
3.0 KiB
Diff

--- ../src_base/minecraft/net/minecraft/src/Entity.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft/net/minecraft/src/Entity.java 0000-00-00 00:00:00.000000000 -0000
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -173,6 +174,11 @@
*/
public boolean ignoreFrustumCheck;
public boolean isAirBorne;
+
+ /** Forge: Used to store custom data for each entity. */
+ private NBTTagCompound customEntityData;
+ protected boolean captureDrops = false;
+ protected ArrayList<EntityItem> capturedDrops = new ArrayList<EntityItem>();
public Entity(World par1World)
{
@@ -214,6 +220,29 @@
}
protected abstract void entityInit();
+
+ /**
+ * 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;
+ }
public DataWatcher getDataWatcher()
{
@@ -1318,6 +1347,10 @@
par1NBTTagCompound.setShort("Fire", (short)this.fire);
par1NBTTagCompound.setShort("Air", (short)this.getAir());
par1NBTTagCompound.setBoolean("OnGround", this.onGround);
+ if (customEntityData != null)
+ {
+ par1NBTTagCompound.setCompoundTag("ForgeData", customEntityData);
+ }
this.writeEntityToNBT(par1NBTTagCompound);
}
@@ -1359,6 +1392,10 @@
this.onGround = par1NBTTagCompound.getBoolean("OnGround");
this.setPosition(this.posX, this.posY, this.posZ);
this.setRotation(this.rotationYaw, this.rotationPitch);
+ if (par1NBTTagCompound.hasKey("ForgeData"))
+ {
+ customEntityData = par1NBTTagCompound.getCompoundTag("ForgeData");
+ }
this.readEntityFromNBT(par1NBTTagCompound);
}
@@ -1444,7 +1481,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;
}
@@ -1717,7 +1761,7 @@
*/
public boolean isRiding()
{
- return this.ridingEntity != null || this.getFlag(2);
+ return (this.ridingEntity != null && ridingEntity.shouldRiderSit()) || this.getFlag(2);
}
/**