--- ../src-base/minecraft/net/minecraft/util/WeightedRandomChestContent.java
+++ ../src-work/minecraft/net/minecraft/util/WeightedRandomChestContent.java
@@ -38,23 +38,12 @@
         for (int j = 0; j < p_177630_3_; ++j)
         {
             WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.func_76271_a(p_177630_0_, p_177630_1_);
-            int k = weightedrandomchestcontent.field_76295_d + p_177630_0_.nextInt(weightedrandomchestcontent.field_76296_e - weightedrandomchestcontent.field_76295_d + 1);
+            ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(p_177630_0_, p_177630_2_);
 
-            if (weightedrandomchestcontent.field_76297_b.func_77976_d() >= k)
+            for (ItemStack itemstack : stacks)
             {
-                ItemStack itemstack = weightedrandomchestcontent.field_76297_b.func_77946_l();
-                itemstack.field_77994_a = k;
                 p_177630_2_.func_70299_a(p_177630_0_.nextInt(p_177630_2_.func_70302_i_()), itemstack);
             }
-            else
-            {
-                for (int l = 0; l < k; ++l)
-                {
-                    ItemStack itemstack1 = weightedrandomchestcontent.field_76297_b.func_77946_l();
-                    itemstack1.field_77994_a = 1;
-                    p_177630_2_.func_70299_a(p_177630_0_.nextInt(p_177630_2_.func_70302_i_()), itemstack1);
-                }
-            }
         }
     }
 
@@ -63,23 +52,12 @@
         for (int j = 0; j < p_177631_3_; ++j)
         {
             WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.func_76271_a(p_177631_0_, p_177631_1_);
-            int k = weightedrandomchestcontent.field_76295_d + p_177631_0_.nextInt(weightedrandomchestcontent.field_76296_e - weightedrandomchestcontent.field_76295_d + 1);
+            ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(p_177631_0_, p_177631_2_);
 
-            if (weightedrandomchestcontent.field_76297_b.func_77976_d() >= k)
+            for (ItemStack itemstack : stacks)
             {
-                ItemStack itemstack = weightedrandomchestcontent.field_76297_b.func_77946_l();
-                itemstack.field_77994_a = k;
                 p_177631_2_.func_70299_a(p_177631_0_.nextInt(p_177631_2_.func_70302_i_()), itemstack);
             }
-            else
-            {
-                for (int l = 0; l < k; ++l)
-                {
-                    ItemStack itemstack1 = weightedrandomchestcontent.field_76297_b.func_77946_l();
-                    itemstack1.field_77994_a = 1;
-                    p_177631_2_.func_70299_a(p_177631_0_.nextInt(p_177631_2_.func_70302_i_()), itemstack1);
-                }
-            }
         }
     }
 
@@ -89,4 +67,17 @@
         Collections.addAll(arraylist, p_177629_1_);
         return arraylist;
     }
+
+    // -- 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 net.minecraftforge.common.ChestGenHooks.generateStacks(random, field_76297_b, field_76295_d, field_76296_e);
+    }
 }
