diff --git a/patches/net/minecraft/tileentity/TileEntity.java.patch b/patches/net/minecraft/tileentity/TileEntity.java.patch index 8b36b9b..71ea620 100644 --- a/patches/net/minecraft/tileentity/TileEntity.java.patch +++ b/patches/net/minecraft/tileentity/TileEntity.java.patch @@ -59,3 +59,10 @@ // -- BEGIN FORGE PATCHES -- /** * Determines if this TileEntity requires update calls. +@@ -370,4 +392,6 @@ + } + return bb; + } ++ ++ public boolean dead; + } diff --git a/patches/net/minecraft/world/World.java.patch b/patches/net/minecraft/world/World.java.patch index d10e86c..ced9fe2 100644 --- a/patches/net/minecraft/world/World.java.patch +++ b/patches/net/minecraft/world/World.java.patch @@ -895,7 +895,7 @@ } catch (Throwable throwable1) { -@@ -1916,30 +2453,69 @@ +@@ -1916,30 +2453,85 @@ { this.getChunkFromChunkCoords(j, l).removeEntity(entity); } @@ -918,7 +918,7 @@ - - while (iterator.hasNext()) + // CraftBukkit start - From below, clean up tile entities before ticking them -+ if (!this.field_147483_b.isEmpty()) ++ if (!this.field_147483_b.isEmpty() && !kcauldron.KCauldronConfig.tileEntityListRecreation) { - TileEntity tileentity = (TileEntity)iterator.next(); + for (Object tile : field_147483_b) @@ -931,6 +931,22 @@ + // CraftBukkit end - if (!tileentity.isInvalid() && tileentity.hasWorldObj() && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord)) ++ // KCauldron start ++ if (kcauldron.KCauldronConfig.tileEntityListRecreation) { ++ List newEntityList = new ArrayList(); ++ final int length = loadedTileEntityList.size(); ++ for (int tileIndex = 0; tileIndex < length; tileIndex++) { ++ TileEntity tile = (TileEntity) loadedTileEntityList.get(tileIndex); ++ if (tile.dead) { ++ tile.onChunkUnload(); ++ continue; ++ } ++ newEntityList.add(tile); ++ } ++ loadedTileEntityList = newEntityList; ++ } ++ // KCauldron end ++ + int tilesThisCycle = 0; + for (tileLimiter.initTick(); tilesThisCycle < loadedTileEntityList.size() && (tilesThisCycle % 10 == 0 || tileLimiter.shouldContinue()); tileTickPosition++, tilesThisCycle++) { + tileTickPosition = (tileTickPosition < loadedTileEntityList.size()) ? tileTickPosition : 0; @@ -972,7 +988,7 @@ crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity"); crashreportcategory = crashreport.makeCategory("Block entity being ticked"); tileentity.func_145828_a(crashreportcategory); -@@ -1955,23 +2531,13 @@ +@@ -1955,23 +2547,13 @@ } } } @@ -1001,7 +1017,7 @@ if (!this.field_147483_b.isEmpty()) { for (Object tile : field_147483_b) -@@ -1981,6 +2547,7 @@ +@@ -1981,6 +2563,7 @@ this.loadedTileEntityList.removeAll(this.field_147483_b); this.field_147483_b.clear(); } @@ -1009,7 +1025,7 @@ this.field_147481_N = false; -@@ -2016,17 +2583,23 @@ +@@ -2016,17 +2599,23 @@ this.addedTileEntityList.clear(); } @@ -1036,7 +1052,7 @@ } public void updateEntity(Entity p_72870_1_) -@@ -2036,21 +2609,36 @@ +@@ -2036,21 +2625,36 @@ public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_) { @@ -1075,7 +1091,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 +2722,7 @@ +@@ -2134,6 +2738,7 @@ p_72866_1_.riddenByEntity = null; } } @@ -1083,7 +1099,7 @@ } } -@@ -2570,7 +3159,7 @@ +@@ -2570,7 +3175,7 @@ return; } @@ -1092,7 +1108,17 @@ { if (this.field_147481_N) { -@@ -2718,7 +3307,15 @@ +@@ -2612,6 +3217,9 @@ + + public void func_147457_a(TileEntity p_147457_1_) + { ++ if (kcauldron.KCauldronConfig.tileEntityListRecreation) { ++ p_147457_1_.dead = true; return; ++ } + this.field_147483_b.add(p_147457_1_); + } + +@@ -2718,7 +3326,15 @@ if (i <= 0) { @@ -1109,7 +1135,7 @@ } } -@@ -2754,7 +3351,15 @@ +@@ -2754,7 +3370,15 @@ if (j <= 0) { @@ -1126,7 +1152,7 @@ } } -@@ -2777,8 +3382,41 @@ +@@ -2777,8 +3401,41 @@ protected void setActivePlayerChunksAndCheckLight() { this.activeChunkSet.clear(); @@ -1169,7 +1195,7 @@ int i; EntityPlayer entityplayer; int j; -@@ -2788,17 +3426,28 @@ +@@ -2788,17 +3445,28 @@ for (i = 0; i < this.playerEntities.size(); ++i) { entityplayer = (EntityPlayer)this.playerEntities.get(i); @@ -1204,7 +1230,7 @@ } this.theProfiler.endSection(); -@@ -2810,7 +3459,7 @@ +@@ -2810,7 +3478,7 @@ this.theProfiler.startSection("playerCheckLight"); @@ -1213,7 +1239,7 @@ { i = this.rand.nextInt(this.playerEntities.size()); entityplayer = (EntityPlayer)this.playerEntities.get(i); -@@ -3034,9 +3683,9 @@ +@@ -3034,9 +3702,9 @@ } } @@ -1225,7 +1251,7 @@ { return false; } -@@ -3166,6 +3815,16 @@ +@@ -3166,6 +3834,16 @@ } } @@ -1242,7 +1268,7 @@ this.theProfiler.endSection(); return true; } -@@ -3284,8 +3943,21 @@ +@@ -3284,8 +3962,21 @@ { Entity entity = (Entity)this.loadedEntityList.get(j); @@ -1265,7 +1291,7 @@ ++i; } } -@@ -3298,6 +3970,7 @@ +@@ -3298,6 +3989,7 @@ for (int i = 0; i < p_72868_1_.size(); ++i) { Entity entity = (Entity)p_72868_1_.get(i); @@ -1273,7 +1299,7 @@ if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this))) { loadedEntityList.add(entity); -@@ -3314,8 +3987,17 @@ +@@ -3314,8 +4006,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_); @@ -1292,7 +1318,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 +4146,12 @@ +@@ -3464,6 +4165,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1305,7 +1331,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 +4177,12 @@ +@@ -3489,7 +4196,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1319,7 +1345,7 @@ if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) { double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_); -@@ -3660,6 +4353,18 @@ +@@ -3660,6 +4372,18 @@ public void updateAllPlayersSleepingFlag() {} @@ -1338,7 +1364,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 +4637,8 @@ +@@ -3932,8 +4656,8 @@ */ public void addTileEntity(TileEntity entity) { @@ -1349,7 +1375,7 @@ { dest.add(entity); } -@@ -4029,4 +4734,122 @@ +@@ -4029,4 +4753,122 @@ } return count; } diff --git a/src/main/java/kcauldron/KCauldronConfig.java b/src/main/java/kcauldron/KCauldronConfig.java index 1416047..c247736 100644 --- a/src/main/java/kcauldron/KCauldronConfig.java +++ b/src/main/java/kcauldron/KCauldronConfig.java @@ -29,6 +29,10 @@ public class KCauldronConfig extends ConfigBase { public BoolSetting commonAllowNetherPortal = new BoolSetting(this, "common.allowNetherPortalBesidesOverworld", false, "Allow nether portals in dimensions besides overworld"); + + public BoolSetting experimentalTileEntityListRecreation = new BoolSetting(this, + "experimental.tileEntityListRecreation", false, "EXPERIMENTAL! Recreate list of TE each tick."); + public static boolean tileEntityListRecreation; public KCauldronConfig() { super("kcauldron.yml", "kc"); @@ -41,6 +45,7 @@ public class KCauldronConfig extends ConfigBase { register(loggingMaterialInjection); register(loggingClientModList); register(commonAllowNetherPortal); + register(experimentalTileEntityListRecreation); load(); } @@ -82,5 +87,6 @@ public class KCauldronConfig extends ConfigBase { "Could not load " + this.configFile); ex.printStackTrace(); } + tileEntityListRecreation = experimentalTileEntityListRecreation.getValue(); } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java index 59ca63c..a114665 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java +++ b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java @@ -24,7 +24,7 @@ public class TerminalConsoleWriterThread implements Runnable { while (true) { message = QueueLogAppender.getNextLogEvent("TerminalConsole"); if (message == null) { - continue; + Thread.yield(); } try {