From b38656588163842ad3fd51ba70b69a11d9614e66 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 26 Jan 2013 14:07:51 -0500 Subject: [PATCH 01/12] Add in a mechanism for explicit subclassing of WeightedRandomChestItem to allow for generational style chest content generation rather than static. Cleans up some old code nicely --- .../minecraftforge/common/DungeonHooks.java | 11 ++++- .../WeightedRandomChestContent.java.patch | 43 ++++++++++++------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/common/net/minecraftforge/common/DungeonHooks.java b/common/net/minecraftforge/common/DungeonHooks.java index bc1965aa2..09f6ff6db 100644 --- a/common/net/minecraftforge/common/DungeonHooks.java +++ b/common/net/minecraftforge/common/DungeonHooks.java @@ -3,6 +3,9 @@ package net.minecraftforge.common; import java.util.ArrayList; import java.util.Random; +import cpw.mods.fml.common.FMLLog; + +import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandom; @@ -148,12 +151,18 @@ public class DungeonHooks { int min = theMinimumChanceToGenerateItem; int max = theMaximumChanceToGenerateItem; - + ItemStack ret = this.theItemId.copy(); ret.stackSize = min + (rand.nextInt(max - min + 1)); return ret; } + @Override + protected final ItemStack[] generateChestContent(Random random, IInventory newInventory) + { + FMLLog.warning("Some mod is still using DungeonHooks.DungonLoot, tell them to stop! %s", this); + return new ItemStack[] { generateStack(random) }; + } public boolean equals(ItemStack item, int min, int max) { int minCount = theMinimumChanceToGenerateItem; diff --git a/patches/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch b/patches/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch index caca7b31f..fb28b6763 100644 --- a/patches/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch +++ b/patches/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch @@ -1,11 +1,12 @@ --- ../src_base/minecraft/net/minecraft/util/WeightedRandomChestContent.java +++ ../src_work/minecraft/net/minecraft/util/WeightedRandomChestContent.java -@@ -1,9 +1,13 @@ +@@ -1,9 +1,14 @@ package net.minecraft.util; import java.util.Random; + +import cpw.mods.fml.common.FMLLog; ++import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.tileentity.TileEntityDispenser; @@ -14,7 +15,7 @@ public class WeightedRandomChestContent extends WeightedRandomItem { -@@ -35,27 +39,26 @@ +@@ -35,27 +40,17 @@ /** * Generates the Chest contents. */ @@ -25,24 +26,17 @@ { WeightedRandomChestContent var5 = (WeightedRandomChestContent)WeightedRandom.getRandomItem(par0Random, par1ArrayOfWeightedRandomChestContent); - int var6 = var5.theMinimumChanceToGenerateItem + par0Random.nextInt(var5.theMaximumChanceToGenerateItem - var5.theMinimumChanceToGenerateItem + 1); ++ ItemStack[] stacks = var5.generateChestContent(par0Random, par2TileEntityChest); - if (var5.theItemId.getMaxStackSize() >= var6) -+ if (var5 instanceof DungeonHooks.DungeonLoot) ++ for (ItemStack item : stacks) { - ItemStack var7 = var5.theItemId.copy(); - var7.stackSize = var6; - par2TileEntityChest.setInventorySlotContents(par0Random.nextInt(par2TileEntityChest.getSizeInventory()), var7); -+ DungeonHooks.DungeonLoot loot = (DungeonHooks.DungeonLoot)var5; -+ par2TileEntityChest.setInventorySlotContents(par0Random.nextInt(par2TileEntityChest.getSizeInventory()), loot.generateStack(par0Random)); -+ FMLLog.warning("Some mod is still using DungeonHooks.DungonLoot, tell them to stop! %s", loot); -+ continue; - } +- } - else -+ -+ ItemStack[] stacks = ChestGenHooks.generateStacks(par0Random, var5.theItemId, var5.theMinimumChanceToGenerateItem, var5.theMaximumChanceToGenerateItem); -+ -+ for (ItemStack item : stacks) - { +- { - for (int var9 = 0; var9 < var6; ++var9) - { - ItemStack var8 = var5.theItemId.copy(); @@ -53,12 +47,12 @@ } } } -@@ -68,22 +71,11 @@ +@@ -68,22 +63,11 @@ for (int var4 = 0; var4 < par3; ++var4) { WeightedRandomChestContent var5 = (WeightedRandomChestContent)WeightedRandom.getRandomItem(par0Random, par1ArrayOfWeightedRandomChestContent); - int var6 = var5.theMinimumChanceToGenerateItem + par0Random.nextInt(var5.theMaximumChanceToGenerateItem - var5.theMinimumChanceToGenerateItem + 1); -+ ItemStack[] stacks = ChestGenHooks.generateStacks(par0Random, var5.theItemId, var5.theMinimumChanceToGenerateItem, var5.theMaximumChanceToGenerateItem); ++ ItemStack[] stacks = var5.generateChestContent(par0Random, par2TileEntityDispenser); - if (var5.theItemId.getMaxStackSize() >= var6) + for (ItemStack item : stacks) @@ -79,3 +73,22 @@ } } } +@@ -109,4 +93,18 @@ + + return var2; + } ++ ++ // -- Forge hooks ++ /** ++ * Allow a mod to submit a custom implementation that can delegate item stack generation beyond simple stack lookup ++ * ++ * @param random The current random for generation ++ * @param newInventory The inventory being generated (do not populate it, but you can refer to it) ++ * @return An array of {@link ItemStack} to put into the chest ++ */ ++ protected ItemStack[] generateChestContent(Random random, IInventory newInventory) ++ { ++ return ChestGenHooks.generateStacks(random, theItemId, theMinimumChanceToGenerateItem, theMaximumChanceToGenerateItem); ++ } ++ + } From f06e0be5e59723808305f4c4aeb89c9108c79230 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 27 Jan 2013 10:43:35 -0500 Subject: [PATCH 02/12] We try and log a message if we detect a world leak: it's probably not infallible, but it should help mod developers- if you see this when testing your mod with, say, mystcraft, you're probably keeping a hold of an invalid handle to the World (either directly, or indirectly via Entity or TileEntity) and you should look to refactor to wrap those handles in WeakReferences --- .../common/DimensionManager.java | 40 ++++++++++++++++++- .../server/MinecraftServer.java.patch | 2 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/common/net/minecraftforge/common/DimensionManager.java b/common/net/minecraftforge/common/DimensionManager.java index 8cf50502d..2b29e7413 100644 --- a/common/net/minecraftforge/common/DimensionManager.java +++ b/common/net/minecraftforge/common/DimensionManager.java @@ -3,15 +3,23 @@ package net.minecraftforge.common; import java.io.File; import java.util.ArrayList; import java.util.BitSet; +import java.util.HashSet; import java.util.Hashtable; +import java.util.List; +import java.util.ListIterator; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.ConcurrentMap; import java.util.logging.Level; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.MapMaker; import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; @@ -40,9 +48,10 @@ public class DimensionManager private static Hashtable worlds = new Hashtable(); private static boolean hasInit = false; private static Hashtable dimensions = new Hashtable(); - private static Map> persistentChunkStore = Maps.newHashMap(); //FIXME: Unused? private static ArrayList unloadQueue = new ArrayList(); private static BitSet dimensionMap = new BitSet(Long.SIZE << 4); + private static ConcurrentMap weakWorldMap = new MapMaker().weakKeys().weakValues().makeMap(); + private static Set leakedWorlds = Sets.newHashSet(); public static boolean registerProviderType(int id, Class provider, boolean keepLoaded) { @@ -115,6 +124,34 @@ public class DimensionManager return getWorld(dim).provider; } + public static Integer[] getIDs(boolean check) + { + if (check) + { + List allWorlds = Lists.newArrayList(weakWorldMap.keySet()); + allWorlds.removeAll(worlds.values()); + Set newLeaks = Sets.newHashSet(); + for (ListIterator li = allWorlds.listIterator(); li.hasNext(); ) + { + World w = li.next(); + if (leakedWorlds.contains(System.identityHashCode(w))) + { + li.remove(); + } + newLeaks.add(System.identityHashCode(w)); + } + leakedWorlds = newLeaks; + if (allWorlds.size() > 0) + { + FMLLog.severe("Detected leaking worlds in memory. There are %d worlds that appear to be persisting. A mod is likely caching the world incorrectly\n", allWorlds.size() + leakedWorlds.size()); + for (World w : allWorlds) + { + FMLLog.severe("The world %x (%s) has leaked.\n", System.identityHashCode(w), w.getWorldInfo().getWorldName()); + } + } + } + return getIDs(); + } public static Integer[] getIDs() { return worlds.keySet().toArray(new Integer[worlds.size()]); //Only loaded dims, since usually used to cycle through loaded worlds @@ -124,6 +161,7 @@ public class DimensionManager { if (world != null) { worlds.put(id, world); + weakWorldMap.put(world, world); MinecraftServer.getServer().worldTickTimes.put(id, new long[100]); FMLLog.info("Loading dimension %d (%s) (%s)", id, world.getWorldInfo().getWorldName(), world.getMinecraftServer()); } else { diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 6a773e51d..7d08a6c34 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -117,7 +117,7 @@ - for (var1 = 0; var1 < this.worldServers.length; ++var1) - { -+ Integer[] ids = DimensionManager.getIDs(); ++ Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0); + for (int x = 0; x < ids.length; x++) + { + int id = ids[x]; From 30db5773892259c65924efc7f5007c1e66268a60 Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 28 Jan 2013 16:36:03 -0800 Subject: [PATCH 03/12] Moved warning logic down, so that no more tickets are isues if the mod is over it's alotment. Fixes #378 --- common/net/minecraftforge/common/ForgeChunkManager.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/net/minecraftforge/common/ForgeChunkManager.java b/common/net/minecraftforge/common/ForgeChunkManager.java index 4794f53b2..99146b846 100644 --- a/common/net/minecraftforge/common/ForgeChunkManager.java +++ b/common/net/minecraftforge/common/ForgeChunkManager.java @@ -653,10 +653,13 @@ public class ForgeChunkManager int allowedCount = ticketConstraints.containsKey(modId) ? ticketConstraints.get(modId) : defaultMaxCount; - if (tickets.get(world).get(modId).size() >= allowedCount && !warnedMods.contains(modId)) + if (tickets.get(world).get(modId).size() >= allowedCount) { - FMLLog.info("The mod %s has attempted to allocate a chunkloading ticket beyond it's currently allocated maximum : %d", modId, allowedCount); - warnedMods.add(modId); + if (!warnedMods.contains(modId)) + { + FMLLog.info("The mod %s has attempted to allocate a chunkloading ticket beyond it's currently allocated maximum : %d", modId, allowedCount); + warnedMods.add(modId); + } return null; } Ticket ticket = new Ticket(modId, type, world); From 89e695cee935b010fe80a1a4acd3b7468a12bf8a Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 28 Jan 2013 17:02:31 -0800 Subject: [PATCH 04/12] Forge Additions: Exposed ChunkCache.worldObj to public PR #383 --- common/forge_at.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/forge_at.cfg b/common/forge_at.cfg index cf6c2b5da..abccc5a37 100644 --- a/common/forge_at.cfg +++ b/common/forge_at.cfg @@ -126,3 +126,5 @@ public yc.o #FD:World/field_73018_p #prevThunderingStrength public ayp.b(Llq;)V #MD:WorldClient/func_72847_b #releaseEntitySkin #WorldServer public in.b(Llq;)V #MD:WorldServer/func_72847_b #releaseEntitySkin +# ChunkCache +public ys.e # FD:ChunkCache/field_72815_e # worldObj \ No newline at end of file From fbe86287b4ed8d8da408aadbe79dd80d2796722a Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 28 Jan 2013 17:06:45 -0800 Subject: [PATCH 05/12] Fixup a resource leak warning. --- common/net/minecraftforge/common/Configuration.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/net/minecraftforge/common/Configuration.java b/common/net/minecraftforge/common/Configuration.java index 70a651d75..2f04a89cf 100644 --- a/common/net/minecraftforge/common/Configuration.java +++ b/common/net/minecraftforge/common/Configuration.java @@ -440,6 +440,7 @@ public class Configuration } BufferedReader buffer = null; + UnicodeInputStreamReader input = null; try { if (file.getParentFile() != null) @@ -454,7 +455,7 @@ public class Configuration if (file.canRead()) { - UnicodeInputStreamReader input = new UnicodeInputStreamReader(new FileInputStream(file), defaultEncoding); + input = new UnicodeInputStreamReader(new FileInputStream(file), defaultEncoding); defaultEncoding = input.getEncoding(); buffer = new BufferedReader(input); @@ -638,6 +639,13 @@ public class Configuration buffer.close(); } catch (IOException e){} } + if (input != null) + { + try + { + input.close(); + } catch (IOException e){} + } } } From c58433692c72e29cb3ca5bd405d7c4cbd27cbc7a Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 28 Jan 2013 17:26:02 -0800 Subject: [PATCH 06/12] Add DimensionManager.unregisterProviderType for PR #388 --- .../common/DimensionManager.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/common/net/minecraftforge/common/DimensionManager.java b/common/net/minecraftforge/common/DimensionManager.java index 2b29e7413..14e4f062c 100644 --- a/common/net/minecraftforge/common/DimensionManager.java +++ b/common/net/minecraftforge/common/DimensionManager.java @@ -2,6 +2,7 @@ package net.minecraftforge.common; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.BitSet; import java.util.HashSet; import java.util.Hashtable; @@ -64,6 +65,38 @@ public class DimensionManager return true; } + /** + * Unregisters a Provider type, and returns a array of all dimensions that are + * registered to this provider type. + * If the return size is greater then 0, it is required that the caller either + * change those dimensions's registered type, or replace this type before the + * world is attempted to load, else the loader will throw an exception. + * + * @param id The provider type ID to unreigster + * @return An array containing all dimension IDs still registered to this provider type. + */ + public static int[] unregisterProviderType(int id) + { + if (!providers.containsKey(id)) + { + return new int[0]; + } + providers.remove(id); + spawnSettings.remove(id); + + int[] ret = new int[dimensions.size()]; + int x = 0; + for (Map.Entry ent : dimensions.entrySet()) + { + if (ent.getValue() == id) + { + ret[x++] = ent.getKey(); + } + } + + return Arrays.copyOf(ret, x); + } + public static void init() { if (hasInit) From fb87773c3ab77522a27651dcf20066277bb5e88d Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 28 Jan 2013 17:33:53 -0800 Subject: [PATCH 07/12] Added input getters for Ore recipies, and javadoc warning for modders, #390 --- common/net/minecraftforge/oredict/ShapedOreRecipe.java | 10 ++++++++++ .../net/minecraftforge/oredict/ShapelessOreRecipe.java | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/common/net/minecraftforge/oredict/ShapedOreRecipe.java b/common/net/minecraftforge/oredict/ShapedOreRecipe.java index c3409309f..cdf86574f 100644 --- a/common/net/minecraftforge/oredict/ShapedOreRecipe.java +++ b/common/net/minecraftforge/oredict/ShapedOreRecipe.java @@ -251,4 +251,14 @@ public class ShapedOreRecipe implements IRecipe mirrored = mirror; return this; } + + /** + * Returns the input for this recipe, any mod accessing this value should never + * manipulate the values in this array as it will effect the recipe itself. + * @return The recipes input vales. + */ + public Object[] getInput() + { + return this.input; + } } diff --git a/common/net/minecraftforge/oredict/ShapelessOreRecipe.java b/common/net/minecraftforge/oredict/ShapelessOreRecipe.java index db3e605f0..18e3d8912 100644 --- a/common/net/minecraftforge/oredict/ShapelessOreRecipe.java +++ b/common/net/minecraftforge/oredict/ShapelessOreRecipe.java @@ -139,4 +139,14 @@ public class ShapelessOreRecipe implements IRecipe { return (target.itemID == input.itemID && (target.getItemDamage() == -1 || target.getItemDamage() == input.getItemDamage())); } + + /** + * Returns the input for this recipe, any mod accessing this value should never + * manipulate the values in this array as it will effect the recipe itself. + * @return The recipes input vales. + */ + public ArrayList getInput() + { + return this.input; + } } From 704f879320a7ff8a0fde0bc823f8a8ca54eaf256 Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 28 Jan 2013 17:51:48 -0800 Subject: [PATCH 08/12] Rework canSilkHarvest hook to try and honor vanilla overrides, should close #391 --- .../net/minecraft/block/Block.java.patch | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index a43bef911..01dbf229f 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -141,7 +141,22 @@ { ItemStack var8 = this.createStackedBlock(par6); -@@ -1364,4 +1380,840 @@ +@@ -1097,12 +1113,13 @@ + } + } + ++ private int silk_check_meta = -1; //Dirty hack to stop us from needing to special case the silk check hook. + /** + * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops. + */ + protected boolean canSilkHarvest() + { +- return this.renderAsNormalBlock() && !this.isBlockContainer; ++ return this.renderAsNormalBlock() && !this.hasTileEntity(silk_check_meta); + } + + /** +@@ -1364,4 +1381,839 @@ canBlockGrass[0] = true; StatList.initBreakableStats(); } @@ -493,11 +508,10 @@ + */ + public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata) + { -+ if (this instanceof BlockGlass || this instanceof BlockEnderChest) -+ { -+ return true; -+ } -+ return renderAsNormalBlock() && !hasTileEntity(metadata); ++ silk_check_meta = metadata; ++ boolean ret = this.canSilkHarvest(); ++ silk_check_meta = 0; ++ return ret; + } + + /** From 6d6405973ce067c4e00b1fbe63dd1fd1615b36ba Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 28 Jan 2013 18:05:38 -0800 Subject: [PATCH 09/12] Added catch to TileEntityChestRenderer for potential crash when modders do bad things -.- Closes #389 --- .../TileEntityChestRenderer.java.patch | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityChestRenderer.java.patch diff --git a/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityChestRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityChestRenderer.java.patch new file mode 100644 index 000000000..46392dd59 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityChestRenderer.java.patch @@ -0,0 +1,26 @@ +--- ../src_base/minecraft/net/minecraft/client/renderer/tileentity/TileEntityChestRenderer.java ++++ ../src_work/minecraft/net/minecraft/client/renderer/tileentity/TileEntityChestRenderer.java +@@ -1,5 +1,6 @@ + package net.minecraft.client.renderer.tileentity; + ++import cpw.mods.fml.common.FMLLog; + import cpw.mods.fml.relauncher.Side; + import cpw.mods.fml.relauncher.SideOnly; + import java.util.Calendar; +@@ -50,7 +51,15 @@ + + if (var10 != null && var9 == 0) + { +- ((BlockChest)var10).unifyAdjacentChests(par1TileEntityChest.getWorldObj(), par1TileEntityChest.xCoord, par1TileEntityChest.yCoord, par1TileEntityChest.zCoord); ++ try ++ { ++ ((BlockChest)var10).unifyAdjacentChests(par1TileEntityChest.getWorldObj(), par1TileEntityChest.xCoord, par1TileEntityChest.yCoord, par1TileEntityChest.zCoord); ++ } ++ catch (ClassCastException e) ++ { ++ FMLLog.severe("Attempted to render a chest at %d, %d, %d that was not a chest", ++ par1TileEntityChest.xCoord, par1TileEntityChest.yCoord, par1TileEntityChest.zCoord); ++ } + var9 = par1TileEntityChest.getBlockMetadata(); + } + From 40392216b3cdcced2678ba0e7ccdb1bf97009029 Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 28 Jan 2013 18:08:38 -0800 Subject: [PATCH 10/12] Change access of upper and lower chest fields of InventoryLargeChest to public. Closes #387 --- common/forge_at.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/forge_at.cfg b/common/forge_at.cfg index abccc5a37..0ec7c1cc8 100644 --- a/common/forge_at.cfg +++ b/common/forge_at.cfg @@ -127,4 +127,7 @@ public ayp.b(Llq;)V #MD:WorldClient/func_72847_b #releaseEntitySkin #WorldServer public in.b(Llq;)V #MD:WorldServer/func_72847_b #releaseEntitySkin # ChunkCache -public ys.e # FD:ChunkCache/field_72815_e # worldObj \ No newline at end of file +public ys.e # FD:ChunkCache/field_72815_e # worldObj +# InventoryLargeChest +public kz.c #FD:InventoryLargeChest/field_70478_c #lowerChest +public kz.b #FD:InventoryLargeChest/field_70477_b #upperChest \ No newline at end of file From 4299aa22ffcc7770499b5edc4ec330da042a5eb8 Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 28 Jan 2013 18:12:29 -0800 Subject: [PATCH 11/12] Change WorldServer.allPlayersSleeping to public, and remove the SideOnly annotation on EntityPlayer.getSleepTimer() Closes #393 --- common/forge_at.cfg | 1 + .../entity/player/EntityPlayer.java.patch | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/forge_at.cfg b/common/forge_at.cfg index 0ec7c1cc8..660c5736c 100644 --- a/common/forge_at.cfg +++ b/common/forge_at.cfg @@ -126,6 +126,7 @@ public yc.o #FD:World/field_73018_p #prevThunderingStrength public ayp.b(Llq;)V #MD:WorldClient/func_72847_b #releaseEntitySkin #WorldServer public in.b(Llq;)V #MD:WorldServer/func_72847_b #releaseEntitySkin +public in.N #FD:WorldServer/field_73068_P #allPlayersSleeping # ChunkCache public ys.e # FD:ChunkCache/field_72815_e # worldObj # InventoryLargeChest diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index 7e5e7055b..2e93c8560 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -314,7 +314,15 @@ switch (var2) { -@@ -1846,7 +1953,7 @@ +@@ -1571,7 +1678,6 @@ + return this.sleeping && this.sleepTimer >= 100; + } + +- @SideOnly(Side.CLIENT) + public int getSleepTimer() + { + return this.sleepTimer; +@@ -1846,7 +1952,7 @@ { if (par1ItemStack.getItem().requiresMultipleRenderPasses()) { @@ -323,7 +331,7 @@ } if (this.itemInUse != null && par1ItemStack.itemID == Item.bow.itemID) -@@ -1868,6 +1975,7 @@ +@@ -1868,6 +1974,7 @@ return 101; } } @@ -331,7 +339,7 @@ } return var3; -@@ -2088,6 +2196,14 @@ +@@ -2088,6 +2195,14 @@ } this.theInventoryEnderChest = par1EntityPlayer.theInventoryEnderChest; From 1dc9ef9b08b6d363d83b3d24c76b177b6b558893 Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 29 Jan 2013 03:11:59 -0800 Subject: [PATCH 12/12] Fix initalization issue with the clamping threshold config value. And remove vanilla console spam related to it. --- .../minecraftforge/common/ForgeDummyContainer.java | 2 +- .../net/minecraftforge/common/MinecraftForge.java | 1 - .../packet/Packet52MultiBlockChange.java.patch | 14 +++++++++----- .../server/management/PlayerInstance.java.patch | 11 ++++++----- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/common/net/minecraftforge/common/ForgeDummyContainer.java b/common/net/minecraftforge/common/ForgeDummyContainer.java index e3db4f8d5..8a3dffe0e 100644 --- a/common/net/minecraftforge/common/ForgeDummyContainer.java +++ b/common/net/minecraftforge/common/ForgeDummyContainer.java @@ -25,7 +25,7 @@ import static net.minecraftforge.common.ForgeVersion.*; public class ForgeDummyContainer extends DummyModContainer implements WorldAccessContainer { - public static int clumpingThreshold; + public static int clumpingThreshold = 64; public ForgeDummyContainer() { diff --git a/common/net/minecraftforge/common/MinecraftForge.java b/common/net/minecraftforge/common/MinecraftForge.java index 3af29f725..48a6d22fa 100644 --- a/common/net/minecraftforge/common/MinecraftForge.java +++ b/common/net/minecraftforge/common/MinecraftForge.java @@ -35,7 +35,6 @@ public class MinecraftForge public static final EventBus ORE_GEN_BUS = new EventBus(); @Deprecated //Vanilla feature now public static boolean SPAWNER_ALLOW_ON_INVERTED = false; - public static final int clumpingThreshold = ForgeDummyContainer.clumpingThreshold; private static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler(); diff --git a/patches/minecraft/net/minecraft/network/packet/Packet52MultiBlockChange.java.patch b/patches/minecraft/net/minecraft/network/packet/Packet52MultiBlockChange.java.patch index 75bd5217b..d1d879562 100644 --- a/patches/minecraft/net/minecraft/network/packet/Packet52MultiBlockChange.java.patch +++ b/patches/minecraft/net/minecraft/network/packet/Packet52MultiBlockChange.java.patch @@ -1,19 +1,23 @@ --- ../src_base/minecraft/net/minecraft/network/packet/Packet52MultiBlockChange.java +++ ../src_work/minecraft/net/minecraft/network/packet/Packet52MultiBlockChange.java -@@ -6,6 +6,7 @@ +@@ -6,6 +6,8 @@ import java.io.IOException; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; ++import net.minecraftforge.common.ForgeDummyContainer; +import net.minecraftforge.common.MinecraftForge; public class Packet52MultiBlockChange extends Packet { -@@ -38,7 +39,7 @@ +@@ -38,10 +40,8 @@ try { - if (par4 >= 64) -+ if (par4 >= MinecraftForge.clumpingThreshold) ++ if (par4 >= ForgeDummyContainer.clumpingThreshold) { - System.out.println("ChunkTilesUpdatePacket compress " + par4); - +- System.out.println("ChunkTilesUpdatePacket compress " + par4); +- + if (field_73449_e.length < var6) + { + field_73449_e = new byte[var6]; diff --git a/patches/minecraft/net/minecraft/server/management/PlayerInstance.java.patch b/patches/minecraft/net/minecraft/server/management/PlayerInstance.java.patch index 232daa62d..0d53d3431 100644 --- a/patches/minecraft/net/minecraft/server/management/PlayerInstance.java.patch +++ b/patches/minecraft/net/minecraft/server/management/PlayerInstance.java.patch @@ -12,10 +12,11 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet51MapChunk; -@@ -10,9 +14,15 @@ +@@ -10,9 +14,16 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.ChunkCoordIntPair; ++import net.minecraftforge.common.ForgeDummyContainer; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.ChunkWatchEvent; @@ -29,7 +30,7 @@ /** note: this is final */ private final ChunkCoordIntPair chunkLocation; -@@ -56,6 +66,8 @@ +@@ -56,6 +67,8 @@ this.playersInChunk.remove(par1EntityPlayerMP); par1EntityPlayerMP.loadedChunks.remove(this.chunkLocation); @@ -38,7 +39,7 @@ if (this.playersInChunk.isEmpty()) { long var2 = (long)this.chunkLocation.chunkXPos + 2147483647L | (long)this.chunkLocation.chunkZPos + 2147483647L << 32; -@@ -80,20 +92,21 @@ +@@ -80,20 +93,21 @@ this.field_73260_f |= 1 << (par2 >> 4); @@ -74,12 +75,12 @@ } public void sendToAllPlayersWatchingChunk(Packet par1Packet) -@@ -133,40 +146,26 @@ +@@ -133,40 +147,26 @@ { int var4; - if (this.numberOfTilesToUpdate == 64) -+ if (this.numberOfTilesToUpdate >= MinecraftForge.clumpingThreshold) ++ if (this.numberOfTilesToUpdate >= ForgeDummyContainer.clumpingThreshold) { var1 = this.chunkLocation.chunkXPos * 16; var2 = this.chunkLocation.chunkZPos * 16;