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

277 lines
11 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/Entity.java
+++ ../src-work/minecraft/net/minecraft/entity/Entity.java
@@ -77,7 +77,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-public abstract class Entity implements ICommandSender
+public abstract class Entity implements ICommandSender, net.minecraftforge.common.capabilities.ICapabilitySerializable<NBTTagCompound>
{
private static final Logger field_184243_a = LogManager.getLogger();
private static final AxisAlignedBB field_174836_a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
@@ -188,7 +188,7 @@
if (p_i1582_1_ != null)
{
- this.field_71093_bK = p_i1582_1_.field_73011_w.func_186058_p().func_186068_a();
+ this.field_71093_bK = p_i1582_1_.field_73011_w.getDimension();
}
this.field_70180_af = new EntityDataManager(this);
@@ -198,8 +198,16 @@
this.field_70180_af.func_187214_a(field_184242_az, "");
this.field_70180_af.func_187214_a(field_184234_aB, Boolean.valueOf(false));
this.func_70088_a();
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this));
+ capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this);
}
+ /** Forge: Used to store custom data for each entity. */
+ private NBTTagCompound customEntityData;
+ public boolean captureDrops = false;
+ public java.util.ArrayList<EntityItem> capturedDrops = new java.util.ArrayList<EntityItem>();
+ private net.minecraftforge.common.capabilities.CapabilityDispatcher capabilities;
+
public int func_145782_y()
{
return this.field_145783_c;
@@ -1138,12 +1146,12 @@
BlockPos blockpos = new BlockPos(this.field_70165_t, d0, this.field_70161_v);
IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos);
+ Boolean result = iblockstate.func_177230_c().isEntityInsideMaterial(this.field_70170_p, blockpos, iblockstate, this, d0, p_70055_1_, true);
+ if (result != null) return result;
+
if (iblockstate.func_185904_a() == p_70055_1_)
{
- float f = BlockLiquid.func_149801_b(iblockstate.func_177230_c().func_176201_c(iblockstate)) - 0.11111111F;
- float f1 = (float)(blockpos.func_177956_o() + 1) - f;
- boolean flag = d0 < (double)f1;
- return !flag && this instanceof EntityPlayer ? false : flag;
+ return net.minecraftforge.common.ForgeHooks.isInsideOfMaterial(p_70055_1_, this, blockpos);
}
else
{
@@ -1539,6 +1547,9 @@
p_189511_1_.func_74782_a("Tags", nbttaglist);
}
+ if (customEntityData != null) p_189511_1_.func_74782_a("ForgeData", customEntityData);
+ if (this.capabilities != null) p_189511_1_.func_74782_a("ForgeCaps", this.capabilities.serializeNBT());
+
this.func_70014_b(p_189511_1_);
if (this.func_184207_aI())
@@ -1637,6 +1648,9 @@
this.func_174810_b(p_70020_1_.func_74767_n("Silent"));
this.func_184195_f(p_70020_1_.func_74767_n("Glowing"));
+ if (p_70020_1_.func_74764_b("ForgeData")) customEntityData = p_70020_1_.func_74775_l("ForgeData");
+ if (this.capabilities != null && p_70020_1_.func_74764_b("ForgeCaps")) this.capabilities.deserializeNBT(p_70020_1_.func_74775_l("ForgeCaps"));
+
if (p_70020_1_.func_150297_b("Tags", 9))
{
this.field_184236_aF.clear();
@@ -1723,7 +1737,10 @@
{
EntityItem entityitem = new EntityItem(this.field_70170_p, this.field_70165_t, this.field_70163_u + (double)p_70099_2_, this.field_70161_v, p_70099_1_);
entityitem.func_174869_p();
- this.field_70170_p.func_72838_d(entityitem);
+ if (captureDrops)
+ this.capturedDrops.add(entityitem);
+ else
+ this.field_70170_p.func_72838_d(entityitem);
return entityitem;
}
else
@@ -1833,6 +1850,7 @@
public boolean func_184205_a(Entity p_184205_1_, boolean p_184205_2_)
{
+ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_184205_1_, true)) return false;
if (p_184205_2_ || this.func_184228_n(p_184205_1_) && p_184205_1_.func_184219_q(this))
{
if (this.func_184218_aH())
@@ -2289,6 +2307,7 @@
{
if (!this.field_70170_p.field_72995_K && !this.field_70128_L)
{
+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_184204_1_)) return null;
this.field_70170_p.field_72984_F.func_76320_a("changeDimension");
MinecraftServer minecraftserver = this.func_184102_h();
int i = this.field_71093_bK;
@@ -2382,7 +2401,7 @@
public float func_180428_a(Explosion p_180428_1_, World p_180428_2_, BlockPos p_180428_3_, IBlockState p_180428_4_)
{
- return p_180428_4_.func_177230_c().func_149638_a(this);
+ return p_180428_4_.func_177230_c().getExplosionResistance(p_180428_2_, p_180428_3_, this, p_180428_1_);
}
public boolean func_174816_a(Explosion p_174816_1_, World p_174816_2_, BlockPos p_174816_3_, IBlockState p_174816_4_, float p_174816_5_)
@@ -2679,6 +2698,164 @@
EnchantmentHelper.func_151385_b(p_174815_1_, p_174815_2_);
}
+ /* ================================== 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(RayTraceResult target)
+ {
+ if (this instanceof net.minecraft.entity.item.EntityPainting)
+ {
+ return new ItemStack(net.minecraft.init.Items.field_151159_an);
+ }
+ else if (this instanceof EntityLeashKnot)
+ {
+ return new ItemStack(net.minecraft.init.Items.field_151058_ca);
+ }
+ else if (this instanceof net.minecraft.entity.item.EntityItemFrame)
+ {
+ ItemStack held = ((net.minecraft.entity.item.EntityItemFrame)this).func_82335_i();
+ if (held == null)
+ {
+ return new ItemStack(net.minecraft.init.Items.field_151160_bD);
+ }
+ else
+ {
+ return held.func_77946_l();
+ }
+ }
+ else if (this instanceof net.minecraft.entity.item.EntityMinecart)
+ {
+ return ((net.minecraft.entity.item.EntityMinecart)this).getCartItem();
+ }
+ else if (this instanceof net.minecraft.entity.item.EntityBoat)
+ {
+ return new ItemStack(((EntityBoat)this).func_184455_j());
+ }
+ else if (this instanceof net.minecraft.entity.item.EntityArmorStand)
+ {
+ return new ItemStack(net.minecraft.init.Items.field_179565_cj);
+ }
+ else if (this instanceof net.minecraft.entity.item.EntityEnderCrystal)
+ {
+ return new ItemStack(net.minecraft.init.Items.field_185158_cP);
+ }
+ else
+ {
+ String name = EntityList.func_75621_b(this);
+ if (EntityList.field_75627_a.containsKey(name))
+ {
+ ItemStack stack = new ItemStack(net.minecraft.init.Items.field_151063_bx);
+ net.minecraft.item.ItemMonsterPlacer.func_185078_a(stack, name);
+ return stack;
+ }
+ }
+ return null;
+ }
+
+ public UUID getPersistentID()
+ {
+ return field_96093_i;
+ }
+
+ /**
+ * Reset the entity ID to a new value. Not to be used from Mod code
+ */
+ public final void resetEntityId()
+ {
+ this.field_145783_c = field_70152_a++;
+ }
+
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass == 0;
+ }
+
+ /**
+ * Returns true if the entity is of the @link{EnumCreatureType} provided
+ * @param type The EnumCreatureType type this entity is evaluating
+ * @param forSpawnCount If this is being invoked to check spawn count caps.
+ * @return If the creature is of the type provided
+ */
+ public boolean isCreatureType(EnumCreatureType type, boolean forSpawnCount)
+ {
+ if (forSpawnCount && (this instanceof EntityLiving) && ((EntityLiving)this).func_104002_bU()) return false;
+ return type.func_75598_a().isAssignableFrom(this.getClass());
+ }
+
+ /**
+ * If a rider of this entity can interact with this entity. Should return true on the
+ * ridden entity if so.
+ *
+ * @return if the entity can be interacted with from a rider
+ */
+ public boolean canRiderInteract()
+ {
+ return false;
+ }
+
+ /**
+ * If the rider should be dismounted from the entity when the entity goes under water
+ *
+ * @param rider The entity that is riding
+ * @return if the entity should be dismounted when under water
+ */
+ public boolean shouldDismountInWater(Entity rider)
+ {
+ return this instanceof EntityLivingBase;
+ }
+
+ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, net.minecraft.util.EnumFacing facing)
+ {
+ if (getCapability(capability, facing) != null)
+ return true;
+ return capabilities == null ? false : capabilities.hasCapability(capability, facing);
+ }
+
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ {
+ return capabilities == null ? null : capabilities.getCapability(capability, facing);
+ }
+
+ public void deserializeNBT(NBTTagCompound nbt)
+ {
+ this.func_70020_e(nbt);
+ }
+
+ public NBTTagCompound serializeNBT()
+ {
+ NBTTagCompound ret = new NBTTagCompound();
+ ret.func_74778_a("id", this.func_70022_Q());
+ return this.func_189511_e(ret);
+ }
+ /* ================================== Forge End =====================================*/
+
public void func_184178_b(EntityPlayerMP p_184178_1_)
{
}