--- a/net/minecraft/entity/Entity.java +++ b/net/minecraft/entity/Entity.java @@ -97,7 +97,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public abstract class Entity implements INameable, ICommandSource { +public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider implements INameable, ICommandSource, net.minecraftforge.common.extensions.IForgeEntity { protected static final Logger field_184243_a = LogManager.getLogger(); private static final List field_190535_b = Collections.emptyList(); private static final AxisAlignedBB field_174836_a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); @@ -210,7 +210,7 @@ this.field_70170_p = p_i48580_2_; this.func_70107_b(0.0D, 0.0D, 0.0D); if (p_i48580_2_ != null) { - this.field_71093_bK = p_i48580_2_.field_73011_w.func_186058_p().func_186068_a(); + this.field_71093_bK = p_i48580_2_.field_73011_w.getId(); } this.field_70180_af = new EntityDataManager(this); @@ -221,6 +221,8 @@ this.field_70180_af.func_187214_a(field_184234_aB, false); this.field_70180_af.func_187214_a(field_189655_aD, false); this.func_70088_a(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this)); + this.gatherCapabilities(); } public EntityType func_200600_R() { @@ -845,7 +847,7 @@ protected void func_180429_a(BlockPos p_180429_1_, IBlockState p_180429_2_) { if (!p_180429_2_.func_185904_a().func_76224_d()) { - SoundType soundtype = this.field_70170_p.func_180495_p(p_180429_1_.func_177984_a()).func_177230_c() == Blocks.field_150433_aE ? Blocks.field_150433_aE.func_185467_w() : p_180429_2_.func_177230_c().func_185467_w(); + SoundType soundtype = this.field_70170_p.func_180495_p(p_180429_1_.func_177984_a()).func_177230_c() == Blocks.field_150433_aE ? Blocks.field_150433_aE.func_185467_w() : p_180429_2_.getSoundType(field_70170_p, p_180429_1_, this); this.func_184185_a(soundtype.func_185844_d(), soundtype.func_185843_a() * 0.15F, soundtype.func_185847_b()); } } @@ -1040,6 +1042,7 @@ int k = MathHelper.func_76128_c(this.field_70161_v); BlockPos blockpos = new BlockPos(i, j, k); IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); + if (!iblockstate.addRunningEffects(field_70170_p, blockpos, this)) if (iblockstate.func_185901_i() != EnumBlockRenderType.INVISIBLE) { this.field_70170_p.func_195594_a(new BlockParticleData(Particles.field_197611_d, iblockstate), this.field_70165_t + ((double)this.field_70146_Z.nextFloat() - 0.5D) * (double)this.field_70130_N, this.func_174813_aQ().field_72338_b + 0.1D, this.field_70161_v + ((double)this.field_70146_Z.nextFloat() - 0.5D) * (double)this.field_70130_N, -this.field_70159_w * 4.0D, 1.5D, -this.field_70179_y * 4.0D); } @@ -1053,7 +1056,7 @@ double d0 = this.field_70163_u + (double)this.func_70047_e(); BlockPos blockpos = new BlockPos(this.field_70165_t, d0, this.field_70161_v); IFluidState ifluidstate = this.field_70170_p.func_204610_c(blockpos); - return ifluidstate.func_206884_a(p_208600_1_) && d0 < (double)((float)blockpos.func_177956_o() + ifluidstate.func_206885_f() + 0.11111111F); + return ifluidstate.isEntityInside(field_70170_p, blockpos, this, d0, p_208600_1_, true); } } @@ -1370,6 +1373,7 @@ if (this.field_184238_ar) { p_189511_1_.func_74757_a("Glowing", this.field_184238_ar); } + p_189511_1_.func_74757_a("CanUpdate", canUpdate); if (!this.field_184236_aF.isEmpty()) { NBTTagList nbttaglist = new NBTTagList(); @@ -1381,6 +1385,9 @@ p_189511_1_.func_74782_a("Tags", nbttaglist); } + NBTTagCompound caps = serializeCaps(); + if (caps != null) p_189511_1_.func_74782_a("ForgeCaps", caps); + this.func_70014_b(p_189511_1_); if (this.func_184207_aI()) { NBTTagList nbttaglist1 = new NBTTagList(); @@ -1466,6 +1473,8 @@ this.func_174810_b(p_70020_1_.func_74767_n("Silent")); this.func_189654_d(p_70020_1_.func_74767_n("NoGravity")); this.func_184195_f(p_70020_1_.func_74767_n("Glowing")); + if (p_70020_1_.func_150297_b("CanUpdate", 99)) this.canUpdate(p_70020_1_.func_74767_n("CanUpdate")); + if (p_70020_1_.func_150297_b("ForgeCaps", 10)) deserializeCaps(p_70020_1_.func_74775_l("ForgeCaps")); if (p_70020_1_.func_150297_b("Tags", 9)) { this.field_184236_aF.clear(); NBTTagList nbttaglist1 = p_70020_1_.func_150295_c("Tags", 8); @@ -1546,6 +1555,8 @@ } else { 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(); + if (captureDrops() != null) captureDrops().add(entityitem); + else this.field_70170_p.func_72838_d(entityitem); return entityitem; } @@ -1595,6 +1606,7 @@ this.field_70159_w = 0.0D; this.field_70181_x = 0.0D; this.field_70179_y = 0.0D; + if (canUpdate()) this.func_70071_h_(); if (this.func_184218_aH()) { entity.func_184232_k(this); @@ -1636,6 +1648,7 @@ } } + 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()) { this.func_184210_p(); @@ -1663,6 +1676,7 @@ public void func_184210_p() { if (this.field_184239_as != null) { Entity entity = this.field_184239_as; + if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, entity, false)) return; this.field_184239_as = null; entity.func_184225_p(this); } @@ -2053,6 +2067,14 @@ @Nullable public Entity func_184204_a(int p_184204_1_) { + if (this.field_70170_p.field_72995_K || this.field_70128_L) return null; + return changeDimension(p_184204_1_, this.func_184102_h().func_71218_a(p_184204_1_).func_85176_s()); + } + + @Nullable // Forge: Entities that require custom handling should override this method, not the other + public Entity changeDimension(int p_184204_1_, net.minecraftforge.common.util.ITeleporter teleporter) + { + if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_184204_1_)) return null; if (!this.field_70170_p.field_72995_K && !this.field_70128_L) { this.field_70170_p.field_72984_F.func_76320_a("changeDimension"); MinecraftServer minecraftserver = this.func_184102_h(); @@ -2060,7 +2082,7 @@ WorldServer worldserver = minecraftserver.func_71218_a(i); WorldServer worldserver1 = minecraftserver.func_71218_a(p_184204_1_); this.field_71093_bK = p_184204_1_; - if (i == 1 && p_184204_1_ == 1) { + if (i == 1 && p_184204_1_ == 1 && teleporter.isVanilla()) { worldserver1 = minecraftserver.func_200667_a(DimensionType.OVERWORLD); this.field_71093_bK = 0; } @@ -2069,16 +2091,17 @@ this.field_70128_L = false; this.field_70170_p.field_72984_F.func_76320_a("reposition"); BlockPos blockpos; - if (p_184204_1_ == 1) { + if (p_184204_1_ == 1 && teleporter.isVanilla()) { blockpos = worldserver1.func_180504_m(); } else { - double d0 = this.field_70165_t; - double d1 = this.field_70161_v; + double moveFactor = worldserver.field_73011_w.getMovementFactor() / worldserver1.field_73011_w.getMovementFactor(); + double d0 = MathHelper.func_151237_a(this.field_70165_t * moveFactor, worldserver1.func_175723_af().func_177726_b() + 16.0D, worldserver1.func_175723_af().func_177728_d() - 16.0D); + double d1 = MathHelper.func_151237_a(this.field_70161_v * moveFactor, worldserver1.func_175723_af().func_177736_c() + 16.0D, worldserver1.func_175723_af().func_177733_e() - 16.0D); double d2 = 8.0D; - if (p_184204_1_ == -1) { + if (false && p_184204_1_ == -1) { d0 = MathHelper.func_151237_a(d0 / 8.0D, worldserver1.func_175723_af().func_177726_b() + 16.0D, worldserver1.func_175723_af().func_177728_d() - 16.0D); d1 = MathHelper.func_151237_a(d1 / 8.0D, worldserver1.func_175723_af().func_177736_c() + 16.0D, worldserver1.func_175723_af().func_177733_e() - 16.0D); - } else if (p_184204_1_ == 0) { + } else if (false && p_184204_1_ == 0) { d0 = MathHelper.func_151237_a(d0 * 8.0D, worldserver1.func_175723_af().func_177726_b() + 16.0D, worldserver1.func_175723_af().func_177728_d() - 16.0D); d1 = MathHelper.func_151237_a(d1 * 8.0D, worldserver1.func_175723_af().func_177736_c() + 16.0D, worldserver1.func_175723_af().func_177733_e() - 16.0D); } @@ -2087,8 +2110,7 @@ d1 = (double)MathHelper.func_76125_a((int)d1, -29999872, 29999872); float f = this.field_70177_z; this.func_70012_b(d0, this.field_70163_u, d1, 90.0F, 0.0F); - Teleporter teleporter = worldserver1.func_85176_s(); - teleporter.func_180620_b(this, f); + teleporter.placeEntity(worldserver1, this, f); blockpos = new BlockPos(this); } @@ -2097,7 +2119,7 @@ Entity entity = this.func_200600_R().func_200721_a(worldserver1); if (entity != null) { entity.func_180432_n(this); - if (i == 1 && p_184204_1_ == 1) { + if (i == 1 && p_184204_1_ == 1 && teleporter.isVanilla()) { BlockPos blockpos1 = worldserver1.func_205770_a(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.func_175694_M()); entity.func_174828_a(blockpos1, entity.field_70177_z, entity.field_70125_A); } else { @@ -2591,4 +2613,32 @@ public double func_212107_bY() { return this.field_211517_W; } + + private boolean canUpdate = false; + @Override + public void canUpdate(boolean value) { + this.canUpdate = value; + } + @Override + public boolean canUpdate() { + return this.canUpdate; + } + private Collection captureDrops = null; + @Override + public Collection captureDrops() { + return captureDrops; + } + @Override + public Collection captureDrops(Collection value) { + Collection ret = captureDrops; + this.captureDrops = value; + return ret; + } + @Override + public boolean canTrample(IBlockState state, BlockPos pos, float fallDistance) { + return field_70170_p.field_73012_v.nextFloat() < fallDistance - 0.5F + && this instanceof EntityLivingBase + && (this instanceof EntityPlayer || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(field_70170_p, this)) + && this.field_70130_N * this.field_70130_N * this.field_70131_O > 0.512F; + } }