From a39d22379185107cdd3686e5611962324a00ada4 Mon Sep 17 00:00:00 2001 From: Robotia Date: Fri, 29 Jan 2016 13:50:08 -0500 Subject: [PATCH] Some mods have custom TE classes? 0.o --- .../tileentity/TileEntity.java.patch | 16 +++-- patches/net/minecraft/world/World.java.patch | 63 ++++++++++--------- 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/patches/net/minecraft/tileentity/TileEntity.java.patch b/patches/net/minecraft/tileentity/TileEntity.java.patch index 8fb58fd..e1809cd 100644 --- a/patches/net/minecraft/tileentity/TileEntity.java.patch +++ b/patches/net/minecraft/tileentity/TileEntity.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntity.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntity.java -@@ -22,18 +22,22 @@ +@@ -22,18 +22,23 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,7 +26,7 @@ private static final String __OBFID = "CL_00000340"; public static void addMapping(Class p_145826_0_, String p_145826_1_) -@@ -106,7 +110,11 @@ +@@ -106,7 +111,11 @@ } catch (Exception exception) { @@ -39,7 +39,7 @@ } if (tileentity != null) -@@ -282,6 +290,20 @@ +@@ -282,6 +291,31 @@ addMapping(TileEntityFlowerPot.class, "FlowerPot"); } @@ -57,12 +57,12 @@ + } + // CraftBukkit end + // KCauldron start -+ public boolean isGC() ++ public boolean isGC() + { + return this.GC; //Returns true if the chunk it is inside of has marked it for unloading + } + -+ public void setGC(boolean state) ++ public void setGC(boolean state) + { + this.GC = state; //Should never be touched by a mod. Would make it package-private but not sure if that would still work + } @@ -71,3 +71,9 @@ // -- BEGIN FORGE PATCHES -- /** * Determines if this TileEntity requires update calls. +@@ -370,4 +404,4 @@ + } + return bb; + } +-} ++} diff --git a/patches/net/minecraft/world/World.java.patch b/patches/net/minecraft/world/World.java.patch index 7d49ed5..38b7800 100644 --- a/patches/net/minecraft/world/World.java.patch +++ b/patches/net/minecraft/world/World.java.patch @@ -896,7 +896,7 @@ } catch (Throwable throwable1) { -@@ -1916,30 +2454,80 @@ +@@ -1916,30 +2454,83 @@ { this.getChunkFromChunkCoords(j, l).removeEntity(entity); } @@ -925,18 +925,21 @@ + for (Object tile : field_147483_b) + { + TileEntity te = (TileEntity)tile; -+ te.setGC(true); ++ try { te.setGC(true); } catch (Exception e) {} + te.onChunkUnload(); + } + List temporary_tile_entity_list = new ArrayList(this.loadedTileEntityList.size()); + for(Object tile : loadedTileEntityList) -+ if(!((TileEntity)tile).isGC()) -+ temporary_tile_entity_list.add(tile); ++ { ++ boolean marker = false; ++ try { marker = !((TileEntity)tile).isGC(); } catch (Exception e) { try { marker = this.field_14783_b.contains(tile) } catch (Exception ex) { marker = false; } } ++ if (marker) { temporary_tile_entity_list.add(tile); } ++ } + this.loadedTileEntityList = temporary_tile_entity_list; + for (Object tile : field_147483_b) + { + TileEntity te = (TileEntity)tile; -+ te.setGC(false); ++ try { te.setGC(false); } catch (Exception e) {} + } + this.field_147483_b.clear(); + } @@ -946,7 +949,7 @@ + for (tileLimiter.initTick(); tilesThisCycle < loadedTileEntityList.size() && (tilesThisCycle % 10 == 0 || tileLimiter.shouldContinue()); tileTickPosition++, tilesThisCycle++) { + tileTickPosition = (tileTickPosition < loadedTileEntityList.size()) ? tileTickPosition : 0; + TileEntity tileentity = (TileEntity) this.loadedTileEntityList.get(tileTickPosition); -+ ++ + // Spigot start + if (tileentity == null) + { @@ -956,7 +959,7 @@ + continue; + } + // Spigot end -+ ++ + if (tileentity.isInvalid()) { + tilesThisCycle--; + this.loadedTileEntityList.remove(tileTickPosition--); @@ -984,7 +987,7 @@ crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity"); crashreportcategory = crashreport.makeCategory("Block entity being ticked"); tileentity.func_145828_a(crashreportcategory); -@@ -1955,23 +2543,13 @@ +@@ -1955,23 +2546,13 @@ } } } @@ -1013,7 +1016,7 @@ if (!this.field_147483_b.isEmpty()) { for (Object tile : field_147483_b) -@@ -1981,6 +2559,7 @@ +@@ -1981,6 +2562,7 @@ this.loadedTileEntityList.removeAll(this.field_147483_b); this.field_147483_b.clear(); } @@ -1021,7 +1024,7 @@ this.field_147481_N = false; -@@ -2016,17 +2595,23 @@ +@@ -2016,17 +2598,23 @@ this.addedTileEntityList.clear(); } @@ -1048,7 +1051,7 @@ } public void updateEntity(Entity p_72870_1_) -@@ -2036,21 +2621,36 @@ +@@ -2036,21 +2624,36 @@ public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_) { @@ -1087,7 +1090,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 +2734,7 @@ +@@ -2134,6 +2737,7 @@ p_72866_1_.riddenByEntity = null; } } @@ -1095,7 +1098,7 @@ } } -@@ -2570,7 +3171,7 @@ +@@ -2570,7 +3174,7 @@ return; } @@ -1104,7 +1107,7 @@ { if (this.field_147481_N) { -@@ -2718,7 +3319,15 @@ +@@ -2718,7 +3322,15 @@ if (i <= 0) { @@ -1121,7 +1124,7 @@ } } -@@ -2754,7 +3363,15 @@ +@@ -2754,7 +3366,15 @@ if (j <= 0) { @@ -1138,7 +1141,7 @@ } } -@@ -2777,8 +3394,41 @@ +@@ -2777,8 +3397,41 @@ protected void setActivePlayerChunksAndCheckLight() { this.activeChunkSet.clear(); @@ -1181,7 +1184,7 @@ int i; EntityPlayer entityplayer; int j; -@@ -2788,17 +3438,28 @@ +@@ -2788,17 +3441,28 @@ for (i = 0; i < this.playerEntities.size(); ++i) { entityplayer = (EntityPlayer)this.playerEntities.get(i); @@ -1217,7 +1220,7 @@ } this.theProfiler.endSection(); -@@ -2810,7 +3471,7 @@ +@@ -2810,7 +3474,7 @@ this.theProfiler.startSection("playerCheckLight"); @@ -1226,7 +1229,7 @@ { i = this.rand.nextInt(this.playerEntities.size()); entityplayer = (EntityPlayer)this.playerEntities.get(i); -@@ -3034,9 +3695,9 @@ +@@ -3034,9 +3698,9 @@ } } @@ -1238,7 +1241,7 @@ { return false; } -@@ -3166,6 +3827,16 @@ +@@ -3166,6 +3830,16 @@ } } @@ -1255,14 +1258,14 @@ this.theProfiler.endSection(); return true; } -@@ -3284,8 +3955,21 @@ +@@ -3284,8 +3958,21 @@ { Entity entity = (Entity)this.loadedEntityList.get(j); - if ((!(entity instanceof EntityLiving) || !((EntityLiving)entity).isNoDespawnRequired()) && p_72907_1_.isAssignableFrom(entity.getClass())) + // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs + if (entity instanceof EntityLiving) -+ { + { + EntityLiving entityliving = (EntityLiving) entity; + + if (entityliving.canDespawn_CB() && entityliving.isNoDespawnRequired()) @@ -1272,13 +1275,13 @@ + } + + if (p_72907_1_.isAssignableFrom(entity.getClass())) - { ++ { + // if ((!(entity instanceof EntityLiving) || !((EntityLiving)entity).isNoDespawnRequired()) && p_72907_1_.isAssignableFrom(entity.getClass())) + // CraftBukkit end ++i; } } -@@ -3298,6 +3982,7 @@ +@@ -3298,6 +3985,7 @@ for (int i = 0; i < p_72868_1_.size(); ++i) { Entity entity = (Entity)p_72868_1_.get(i); @@ -1286,7 +1289,7 @@ if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this))) { loadedEntityList.add(entity); -@@ -3314,8 +3999,17 @@ +@@ -3314,8 +4002,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_); @@ -1305,7 +1308,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 +4158,12 @@ +@@ -3464,6 +4161,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1318,7 +1321,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 +4189,12 @@ +@@ -3489,7 +4192,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1332,7 +1335,7 @@ if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) { double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_); -@@ -3660,6 +4365,18 @@ +@@ -3660,6 +4368,18 @@ public void updateAllPlayersSleepingFlag() {} @@ -1351,7 +1354,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 +4649,8 @@ +@@ -3932,8 +4652,8 @@ */ public void addTileEntity(TileEntity entity) { @@ -1362,7 +1365,7 @@ { dest.add(entity); } -@@ -4029,4 +4746,122 @@ +@@ -4029,4 +4749,122 @@ } return count; }