1
0
forked from xjboss/KCauldronX

Additional checks during entity update

This commit is contained in:
Prototik 2015-06-08 14:20:26 +07:00
parent 3ec6f6a65f
commit 596a7b993b

View File

@ -631,7 +631,7 @@
// do not drop any items while restoring blocksnapshots. Prevents dupes // do not drop any items while restoring blocksnapshots. Prevents dupes
if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false; if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false;
@@ -1319,8 +1728,84 @@ @@ -1319,23 +1728,99 @@
flag = true; flag = true;
} }
@ -716,10 +716,15 @@
return false; return false;
} }
else else
@@ -1332,10 +1817,10 @@ {
+ if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72838_1_, this)) && !flag || p_72838_1_.isDead) return false;
if (p_72838_1_ instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)p_72838_1_;
this.playerEntities.add(entityplayer);
this.updateAllPlayersSleepingFlag(); this.updateAllPlayersSleepingFlag();
} }
if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72838_1_, this)) && !flag) return false; - if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72838_1_, this)) && !flag) return false;
- -
this.getChunkFromChunkCoords(i, j).addEntity(p_72838_1_); this.getChunkFromChunkCoords(i, j).addEntity(p_72838_1_);
this.loadedEntityList.add(p_72838_1_); this.loadedEntityList.add(p_72838_1_);
@ -1028,7 +1033,13 @@
} }
public void updateEntity(Entity p_72870_1_) public void updateEntity(Entity p_72870_1_)
@@ -2041,16 +2613,27 @@ @@ -2036,21 +2608,33 @@
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
{
+ if (p_72866_1_.isDead) return;
int i = MathHelper.floor_double(p_72866_1_.posX);
int j = MathHelper.floor_double(p_72866_1_.posZ);
boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(i >> 4, j >> 4)); boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(i >> 4, j >> 4));
byte b0 = isForced ? (byte)0 : 32; byte b0 = isForced ? (byte)0 : 32;
boolean canUpdate = !p_72866_2_ || this.checkChunksExist(i - b0, 0, j - b0, i + b0, 0, j + b0); boolean canUpdate = !p_72866_2_ || this.checkChunksExist(i - b0, 0, j - b0, i + b0, 0, j + b0);
@ -1057,7 +1068,7 @@
p_72866_1_.lastTickPosX = p_72866_1_.posX; p_72866_1_.lastTickPosX = p_72866_1_.posX;
p_72866_1_.lastTickPosY = p_72866_1_.posY; p_72866_1_.lastTickPosY = p_72866_1_.posY;
p_72866_1_.lastTickPosZ = p_72866_1_.posZ; p_72866_1_.lastTickPosZ = p_72866_1_.posZ;
@@ -2134,6 +2717,7 @@ @@ -2134,6 +2718,7 @@
p_72866_1_.riddenByEntity = null; p_72866_1_.riddenByEntity = null;
} }
} }
@ -1065,7 +1076,7 @@
} }
} }
@@ -2570,7 +3154,7 @@ @@ -2570,7 +3155,7 @@
return; return;
} }
@ -1074,7 +1085,7 @@
{ {
if (this.field_147481_N) if (this.field_147481_N)
{ {
@@ -2718,7 +3302,15 @@ @@ -2718,7 +3303,15 @@
if (i <= 0) if (i <= 0)
{ {
@ -1091,7 +1102,7 @@
} }
} }
@@ -2754,7 +3346,15 @@ @@ -2754,7 +3347,15 @@
if (j <= 0) if (j <= 0)
{ {
@ -1108,7 +1119,7 @@
} }
} }
@@ -2777,8 +3377,41 @@ @@ -2777,8 +3378,41 @@
protected void setActivePlayerChunksAndCheckLight() protected void setActivePlayerChunksAndCheckLight()
{ {
this.activeChunkSet.clear(); this.activeChunkSet.clear();
@ -1151,7 +1162,7 @@
int i; int i;
EntityPlayer entityplayer; EntityPlayer entityplayer;
int j; int j;
@@ -2788,17 +3421,28 @@ @@ -2788,17 +3422,28 @@
for (i = 0; i < this.playerEntities.size(); ++i) for (i = 0; i < this.playerEntities.size(); ++i)
{ {
entityplayer = (EntityPlayer)this.playerEntities.get(i); entityplayer = (EntityPlayer)this.playerEntities.get(i);
@ -1186,7 +1197,7 @@
} }
this.theProfiler.endSection(); this.theProfiler.endSection();
@@ -2810,7 +3454,7 @@ @@ -2810,7 +3455,7 @@
this.theProfiler.startSection("playerCheckLight"); this.theProfiler.startSection("playerCheckLight");
@ -1195,7 +1206,7 @@
{ {
i = this.rand.nextInt(this.playerEntities.size()); i = this.rand.nextInt(this.playerEntities.size());
entityplayer = (EntityPlayer)this.playerEntities.get(i); entityplayer = (EntityPlayer)this.playerEntities.get(i);
@@ -3284,8 +3928,21 @@ @@ -3284,8 +3929,21 @@
{ {
Entity entity = (Entity)this.loadedEntityList.get(j); Entity entity = (Entity)this.loadedEntityList.get(j);
@ -1218,7 +1229,7 @@
++i; ++i;
} }
} }
@@ -3298,6 +3955,7 @@ @@ -3298,6 +3956,7 @@
for (int i = 0; i < p_72868_1_.size(); ++i) for (int i = 0; i < p_72868_1_.size(); ++i)
{ {
Entity entity = (Entity)p_72868_1_.get(i); Entity entity = (Entity)p_72868_1_.get(i);
@ -1226,7 +1237,7 @@
if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this))) if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this)))
{ {
loadedEntityList.add(entity); loadedEntityList.add(entity);
@@ -3314,8 +3972,17 @@ @@ -3314,8 +3973,17 @@
public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_) public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_)
{ {
Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_); Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_);
@ -1245,7 +1256,7 @@
} }
public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_) public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
@@ -3464,6 +4131,12 @@ @@ -3464,6 +4132,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i) for (int i = 0; i < this.playerEntities.size(); ++i)
{ {
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1258,7 +1269,7 @@
double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_); double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_);
if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4)) if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4))
@@ -3489,7 +4162,12 @@ @@ -3489,7 +4163,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i) for (int i = 0; i < this.playerEntities.size(); ++i)
{ {
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1272,7 +1283,7 @@
if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive())
{ {
double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_); double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_);
@@ -3660,6 +4338,18 @@ @@ -3660,6 +4339,18 @@
public void updateAllPlayersSleepingFlag() {} public void updateAllPlayersSleepingFlag() {}
@ -1291,7 +1302,7 @@
public float getWeightedThunderStrength(float p_72819_1_) public float getWeightedThunderStrength(float p_72819_1_)
{ {
return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_); return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_);
@@ -3932,8 +4622,8 @@ @@ -3932,8 +4623,8 @@
*/ */
public void addTileEntity(TileEntity entity) public void addTileEntity(TileEntity entity)
{ {
@ -1302,7 +1313,7 @@
{ {
dest.add(entity); dest.add(entity);
} }
@@ -4029,4 +4719,73 @@ @@ -4029,4 +4720,73 @@
} }
return count; return count;
} }