From d24b372625213e0e2e11d194edec00e5b8fac662 Mon Sep 17 00:00:00 2001 From: Prototik Date: Wed, 27 May 2015 18:26:08 +0700 Subject: [PATCH] Even don't try to spawn invalid entityitem, fix for extrabiomes --- .../net/minecraft/entity/Entity.java.patch | 11 ++++ .../entity/item/EntityItem.java.patch | 11 ++++ patches/net/minecraft/world/World.java.patch | 59 ++++++++++--------- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/patches/net/minecraft/entity/Entity.java.patch b/patches/net/minecraft/entity/Entity.java.patch index fb9dcb0..751045c 100644 --- a/patches/net/minecraft/entity/Entity.java.patch +++ b/patches/net/minecraft/entity/Entity.java.patch @@ -780,3 +780,14 @@ public float func_145772_a(Explosion p_145772_1_, World p_145772_2_, int p_145772_3_, int p_145772_4_, int p_145772_5_, Block p_145772_6_) { return p_145772_6_.getExplosionResistance(this, p_145772_2_, p_145772_3_, p_145772_4_, p_145772_5_, posX, posY + getEyeHeight(), posZ); +@@ -2474,4 +2925,10 @@ + } + } + } ++ ++ // Cauldron start ++ public boolean entityAllowedToSpawn() { ++ return true; ++ } ++ // Cauldron end + } diff --git a/patches/net/minecraft/entity/item/EntityItem.java.patch b/patches/net/minecraft/entity/item/EntityItem.java.patch index 076a7fe..26eb7db 100644 --- a/patches/net/minecraft/entity/item/EntityItem.java.patch +++ b/patches/net/minecraft/entity/item/EntityItem.java.patch @@ -299,3 +299,14 @@ } public void setEntityItemStack(ItemStack p_92058_1_) +@@ -451,4 +526,10 @@ + { + this.field_145801_f = p_145799_1_; + } ++ ++ @Override ++ public boolean entityAllowedToSpawn() { ++ ItemStack stack = getDataWatcher().getWatchableObjectItemStack(10); ++ return stack != null && stack.stackSize > 0; ++ } + } diff --git a/patches/net/minecraft/world/World.java.patch b/patches/net/minecraft/world/World.java.patch index 9be0d09..d1d1aee 100644 --- a/patches/net/minecraft/world/World.java.patch +++ b/patches/net/minecraft/world/World.java.patch @@ -608,7 +608,7 @@ block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_); } catch (Throwable throwable1) -@@ -1307,6 +1709,12 @@ +@@ -1307,6 +1709,13 @@ public boolean spawnEntityInWorld(Entity p_72838_1_) { @@ -618,10 +618,11 @@ + + public boolean addEntity(Entity p_72838_1_, SpawnReason spawnReason) // Changed signature, added SpawnReason + { ++ if (!p_72838_1_.entityAllowedToSpawn()) return false; // Cauldron // 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; -@@ -1319,8 +1727,84 @@ +@@ -1319,8 +1728,84 @@ flag = true; } @@ -706,7 +707,7 @@ return false; } else -@@ -1332,10 +1816,10 @@ +@@ -1332,10 +1817,10 @@ this.updateAllPlayersSleepingFlag(); } if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72838_1_, this)) && !flag) return false; @@ -718,7 +719,7 @@ return true; } } -@@ -1346,6 +1830,8 @@ +@@ -1346,6 +1831,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_); } @@ -727,7 +728,7 @@ } public void onEntityRemoved(Entity p_72847_1_) -@@ -1354,6 +1840,8 @@ +@@ -1354,6 +1841,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_); } @@ -736,7 +737,7 @@ } public void removeEntity(Entity p_72900_1_) -@@ -1397,6 +1885,19 @@ +@@ -1397,6 +1886,19 @@ } this.loadedEntityList.remove(p_72973_1_); @@ -756,7 +757,7 @@ this.onEntityRemoved(p_72973_1_); } -@@ -1408,40 +1909,58 @@ +@@ -1408,40 +1910,58 @@ public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_) { this.collidingBoundingBoxes.clear(); @@ -829,7 +830,7 @@ for (int j2 = 0; j2 < list.size(); ++j2) { -@@ -1797,11 +2316,22 @@ +@@ -1797,11 +2317,22 @@ Entity entity; CrashReport crashreport; CrashReportCategory crashreportcategory; @@ -852,7 +853,7 @@ try { ++entity.ticksExisted; -@@ -1862,10 +2392,14 @@ +@@ -1862,10 +2393,14 @@ this.unloadedEntityList.clear(); this.theProfiler.endStartSection("regular"); @@ -870,7 +871,7 @@ if (entity.ridingEntity != null) { -@@ -1884,7 +2418,9 @@ +@@ -1884,7 +2419,9 @@ { try { @@ -880,7 +881,7 @@ } catch (Throwable throwable1) { -@@ -1917,29 +2453,67 @@ +@@ -1917,29 +2454,67 @@ this.getChunkFromChunkCoords(j, l).removeEntity(entity); } @@ -954,7 +955,7 @@ crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity"); crashreportcategory = crashreport.makeCategory("Block entity being ticked"); tileentity.func_145828_a(crashreportcategory); -@@ -1955,23 +2529,13 @@ +@@ -1955,23 +2530,13 @@ } } } @@ -983,7 +984,7 @@ if (!this.field_147483_b.isEmpty()) { for (Object tile : field_147483_b) -@@ -1981,6 +2545,7 @@ +@@ -1981,6 +2546,7 @@ this.loadedTileEntityList.removeAll(this.field_147483_b); this.field_147483_b.clear(); } @@ -991,7 +992,7 @@ this.field_147481_N = false; -@@ -2016,17 +2581,23 @@ +@@ -2016,17 +2582,23 @@ this.addedTileEntityList.clear(); } @@ -1018,7 +1019,7 @@ } public void updateEntity(Entity p_72870_1_) -@@ -2041,16 +2612,27 @@ +@@ -2041,16 +2613,27 @@ boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(i >> 4, j >> 4)); byte b0 = isForced ? (byte)0 : 32; boolean canUpdate = !p_72866_2_ || this.checkChunksExist(i - b0, 0, j - b0, i + b0, 0, j + b0); @@ -1047,7 +1048,7 @@ p_72866_1_.lastTickPosX = p_72866_1_.posX; p_72866_1_.lastTickPosY = p_72866_1_.posY; p_72866_1_.lastTickPosZ = p_72866_1_.posZ; -@@ -2134,6 +2716,7 @@ +@@ -2134,6 +2717,7 @@ p_72866_1_.riddenByEntity = null; } } @@ -1055,7 +1056,7 @@ } } -@@ -2570,7 +3153,7 @@ +@@ -2570,7 +3154,7 @@ return; } @@ -1064,7 +1065,7 @@ { if (this.field_147481_N) { -@@ -2718,7 +3301,15 @@ +@@ -2718,7 +3302,15 @@ if (i <= 0) { @@ -1081,7 +1082,7 @@ } } -@@ -2754,7 +3345,15 @@ +@@ -2754,7 +3346,15 @@ if (j <= 0) { @@ -1098,7 +1099,7 @@ } } -@@ -2777,8 +3376,41 @@ +@@ -2777,8 +3377,41 @@ protected void setActivePlayerChunksAndCheckLight() { this.activeChunkSet.clear(); @@ -1141,7 +1142,7 @@ int i; EntityPlayer entityplayer; int j; -@@ -2788,17 +3420,28 @@ +@@ -2788,17 +3421,28 @@ for (i = 0; i < this.playerEntities.size(); ++i) { entityplayer = (EntityPlayer)this.playerEntities.get(i); @@ -1176,7 +1177,7 @@ } this.theProfiler.endSection(); -@@ -2810,7 +3453,7 @@ +@@ -2810,7 +3454,7 @@ this.theProfiler.startSection("playerCheckLight"); @@ -1185,7 +1186,7 @@ { i = this.rand.nextInt(this.playerEntities.size()); entityplayer = (EntityPlayer)this.playerEntities.get(i); -@@ -3284,8 +3927,21 @@ +@@ -3284,8 +3928,21 @@ { Entity entity = (Entity)this.loadedEntityList.get(j); @@ -1208,7 +1209,7 @@ ++i; } } -@@ -3314,8 +3970,17 @@ +@@ -3314,8 +3971,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_) { Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_); @@ -1227,7 +1228,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 +4129,12 @@ +@@ -3464,6 +4130,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1240,7 +1241,7 @@ 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)) -@@ -3489,7 +4160,12 @@ +@@ -3489,7 +4161,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1254,7 +1255,7 @@ if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) { double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_); -@@ -3660,6 +4336,18 @@ +@@ -3660,6 +4337,18 @@ public void updateAllPlayersSleepingFlag() {} @@ -1273,7 +1274,7 @@ public float getWeightedThunderStrength(float p_72819_1_) { return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_); -@@ -3932,8 +4620,8 @@ +@@ -3932,8 +4621,8 @@ */ public void addTileEntity(TileEntity entity) { @@ -1284,7 +1285,7 @@ { dest.add(entity); } -@@ -4029,4 +4717,73 @@ +@@ -4029,4 +4718,73 @@ } return count; }