diff --git a/patches.mcp/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch b/patches.mcp/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch deleted file mode 100644 index 577624b95..000000000 --- a/patches.mcp/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/util/WeightedRandomChestContent.java -+++ ../src-work/minecraft/net/minecraft/util/WeightedRandomChestContent.java -@@ -20,11 +20,29 @@ - this.maxStackSize = maximumChance; - } - -+ // -- 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 -+ */ -+ @Deprecated // New loottable system shouldn't need this. Need to research more. -+ protected ItemStack[] generateChestContent(Random random, net.minecraft.inventory.IInventory newInventory) -+ { -+ return net.minecraftforge.common.ChestGenHooks.generateStacks(random, theItemId, minStackSize, maxStackSize); -+ } -+ - public static void generateDispenserContents(Random random, List listIn, TileEntityDispenser dispenser, int max) - { - for (int i = 0; i < max; ++i) - { - WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(random, listIn); -+ ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(random, dispenser); -+ for (ItemStack stack : stacks) -+ dispenser.setInventorySlotContents(random.nextInt(dispenser.getSizeInventory()), stack); -+ if (true) continue; // Forge: Skip the rest we replace it. - int j = weightedrandomchestcontent.minStackSize + random.nextInt(weightedrandomchestcontent.maxStackSize - weightedrandomchestcontent.minStackSize + 1); - - if (weightedrandomchestcontent.theItemId.getMaxStackSize() >= j) diff --git a/patches.mcp/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch b/patches.mcp/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch deleted file mode 100644 index 713c9cc04..000000000 --- a/patches.mcp/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java -+++ ../src-work/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java -@@ -451,6 +451,11 @@ - private static final List field_175815_j = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.arrow, 0, 2, 7, 30)}); - private static ComponentScatteredFeaturePieces.JunglePyramid.Stones junglePyramidsRandomScatteredStones = new ComponentScatteredFeaturePieces.JunglePyramid.Stones(); - -+ static -+ { -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER, field_175815_j, 2, 2); -+ } -+ - public JunglePyramid() - { - } -@@ -607,9 +612,10 @@ - this.setBlockState(worldIn, Blocks.redstone_wire.getDefaultState(), 4, -3, 1, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.mossy_cobblestone.getDefaultState(), 3, -3, 1, structureBoundingBoxIn); - -+ net.minecraftforge.common.ChestGenHooks dispenser = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER); - if (!this.field_74945_j) - { -- this.field_74945_j = this.func_186166_a(worldIn, structureBoundingBoxIn, randomIn, 3, -2, 1, EnumFacing.NORTH, field_175815_j, 2); -+ this.field_74945_j = this.func_186166_a(worldIn, structureBoundingBoxIn, randomIn, 3, -2, 1, EnumFacing.NORTH, dispenser.getItems(randomIn), dispenser.getCount(randomIn)); - } - - this.setBlockState(worldIn, Blocks.vine.getDefaultState().withProperty(BlockVine.SOUTH, Boolean.valueOf(true)), 3, -2, 2, structureBoundingBoxIn); -@@ -626,7 +632,7 @@ - - if (!this.field_74946_k) - { -- this.field_74946_k = this.func_186166_a(worldIn, structureBoundingBoxIn, randomIn, 9, -2, 3, EnumFacing.WEST, field_175815_j, 2); -+ this.field_74946_k = this.func_186166_a(worldIn, structureBoundingBoxIn, randomIn, 9, -2, 3, EnumFacing.WEST, dispenser.getItems(randomIn), dispenser.getCount(randomIn)); - } - - this.setBlockState(worldIn, Blocks.vine.getDefaultState().withProperty(BlockVine.EAST, Boolean.valueOf(true)), 8, -1, 3, structureBoundingBoxIn); diff --git a/src/main/java/net/minecraftforge/common/ChestGenHooks.java b/src/main/java/net/minecraftforge/common/ChestGenHooks.java deleted file mode 100644 index 8d2cc0a75..000000000 --- a/src/main/java/net/minecraftforge/common/ChestGenHooks.java +++ /dev/null @@ -1,230 +0,0 @@ -package net.minecraftforge.common; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraft.world.WorldServer; -import net.minecraft.world.gen.feature.WorldGenDungeons; -import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.DesertPyramid; -import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.JunglePyramid; -import net.minecraft.world.gen.structure.StructureMineshaftPieces; -import net.minecraft.world.gen.structure.StructureNetherBridgePieces; -import net.minecraft.world.gen.structure.StructureOceanMonument; -import net.minecraft.world.gen.structure.StructureStrongholdPieces; -import net.minecraft.world.gen.structure.StructureVillagePieces; -import net.minecraftforge.oredict.OreDictionary; - -public class ChestGenHooks -{ - //Currently implemented categories for chests/dispensers, Dungeon loot is still in DungeonHooks - public static final String PYRAMID_JUNGLE_DISPENSER = "pyramidJungleDispenser"; // TODO: Convert to a Loot Table - public static final String BONUS_CHEST = "bonusChest"; - public static final String DUNGEON_CHEST = "dungeonChest"; - - private static final HashMap chestInfo = new HashMap(); - private static boolean hasInit = false; - static - { - init(); - } - - private static void init() - { - if (hasInit) - { - return; - } - - hasInit = true; - // This causes the classes static initializers to run - new WorldGenDungeons(); - new JunglePyramid(); - WorldServer.fillChestHook(); - } - - // INTERNAL DO NO USE - public static void init(String category, List items, int min, int max) - { - chestInfo.put(category, new ChestGenHooks(category, items, min, max)); - } - - static void addDungeonLoot(ChestGenHooks dungeon, ItemStack item, int weight, int min, int max) - { - dungeon.addItem(new WeightedRandomChestContent(item, min, max, weight)); - } - - /** - * Retrieves, or creates the info class for the specified category. - * - * @param category The category name - * @return A instance of ChestGenHooks for the specified category. - */ - public static ChestGenHooks getInfo(String category) - { - if (!chestInfo.containsKey(category)) - { - chestInfo.put(category, new ChestGenHooks(category)); - } - return chestInfo.get(category); - } - - /** - * Generates an array of items based on the input min/max count. - * If the stack can not hold the total amount, it will be split into - * stacks of size 1. - * - * @param rand A random number generator - * @param source Source item stack - * @param min Minimum number of items - * @param max Maximum number of items - * @return An array containing the generated item stacks - */ - public static ItemStack[] generateStacks(Random rand, ItemStack source, int min, int max) - { - int count = min + (rand.nextInt(max - min + 1)); - - ItemStack[] ret; - if (source.getItem() == null) - { - ret = new ItemStack[0]; - } - else if (count > source.getMaxStackSize()) - { - ret = new ItemStack[count]; - for (int x = 0; x < count; x++) - { - ret[x] = source.copy(); - ret[x].stackSize = 1; - } - } - else - { - ret = new ItemStack[1]; - ret[0] = source.copy(); - ret[0].stackSize = count; - } - return ret; - } - - //shortcut functions, See the non-static versions below - public static List getItems(String category, Random rnd){ return getInfo(category).getItems(rnd); } - public static int getCount(String category, Random rand){ return getInfo(category).getCount(rand); } - public static void addItem(String category, WeightedRandomChestContent item){ getInfo(category).addItem(item); } - public static void removeItem(String category, ItemStack item){ getInfo(category).removeItem(item); } - public static ItemStack getOneItem(String category, Random rand){ return getInfo(category).getOneItem(rand); } - - @SuppressWarnings("unused") - private String category; - private int countMin = 0; - private int countMax = 0; - private ArrayList contents = new ArrayList(); - - public ChestGenHooks(String category) - { - this.category = category; - } - - public ChestGenHooks(String category, List items, int min, int max) - { - this(category); - for (WeightedRandomChestContent item : items) - { - contents.add(item); - } - countMin = min; - countMax = max; - } - - /** - * Adds a new entry into the possible items to generate. - * - * @param item The item to add. - */ - public void addItem(WeightedRandomChestContent item) - { - contents.add(item); - } - - /** - * Removes all items that match the input item stack, Only metadata and item ID are checked. - * If the input item has a metadata of -1, all metadatas will match. - * - * @param item The item to check - */ - public void removeItem(ItemStack item) - { - Iterator itr = contents.iterator(); - while(itr.hasNext()) - { - WeightedRandomChestContent cont = itr.next(); - if (item.isItemEqual(cont.theItemId) || (item.getItemDamage() == OreDictionary.WILDCARD_VALUE && item.getItem() == cont.theItemId.getItem())) - { - itr.remove(); - } - } - } - - /** - * Gets an array of all random objects that are associated with this category. - * - * @return The random objects - */ - public List getItems(Random rnd) - { - ArrayList ret = new ArrayList(); - - for (WeightedRandomChestContent orig : contents) - { - Item item = orig.theItemId.getItem(); - - if (item != null) - { - WeightedRandomChestContent n = item.getChestGenBase(this, rnd, orig); - if (n != null) - { - ret.add(n); - } - } - } - - return ret; - } - - /** - * Gets a random number between countMin and countMax. - * - * @param rand A RNG - * @return A random number where countMin <= num <= countMax - */ - public int getCount(Random rand) - { - return countMin < countMax ? countMin + rand.nextInt(countMax - countMin) : countMin; - } - - /** - * Returns a single ItemStack from the possible items in this registry, - * Useful if you just want a quick and dirty random Item. - * - * @param rand A Random Number gen - * @return A single ItemStack, or null if it could not get one. - */ - public ItemStack getOneItem(Random rand) - { - WeightedRandomChestContent item = (WeightedRandomChestContent)WeightedRandom.getRandomItem(rand, getItems(rand)); - ItemStack[] stacks = ChestGenHooks.generateStacks(rand, item.theItemId, item.minStackSize, item.maxStackSize); - return (stacks.length > 0 ? stacks[0] : null); - } - - //Accessors - public int getMin(){ return countMin; } - public int getMax(){ return countMax; } - public void setMin(int value){ countMin = value; } - public void setMax(int value){ countMax = value; } -} diff --git a/src/main/java/net/minecraftforge/common/chunkio/ChunkIOProvider.java b/src/main/java/net/minecraftforge/common/chunkio/ChunkIOProvider.java index 8e7c904fd..b7534633c 100644 --- a/src/main/java/net/minecraftforge/common/chunkio/ChunkIOProvider.java +++ b/src/main/java/net/minecraftforge/common/chunkio/ChunkIOProvider.java @@ -45,11 +45,11 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider