From fe62372429e6d1dbdbdc185f93d0639e6348536a Mon Sep 17 00:00:00 2001 From: Eloraam Date: Sun, 2 Oct 2011 08:55:31 +0000 Subject: [PATCH] - Added an ItemStack parameter to IArmorTextureProvider - Added ISidedInventory - Added IBonemealHandler - Added hooks in grow-on-grass and in break tall grass. - Fixed furnace output of multiple items. - Added getBlockDropped(). - Bumped version number to 1.1.1. --- .../src/forge/IArmorTextureProvider.java | 4 +- .../net/minecraft/src/forge/ForgeHooks.java | 95 +++- .../minecraft/src/forge/IBonemealHandler.java | 18 + .../minecraft/src/forge/ISidedInventory.java | 29 + .../minecraft/src/forge/MinecraftForge.java | 44 +- minecraft.patch | 495 +++++++++++++++++- 6 files changed, 637 insertions(+), 48 deletions(-) create mode 100644 forge_common/net/minecraft/src/forge/IBonemealHandler.java create mode 100644 forge_common/net/minecraft/src/forge/ISidedInventory.java diff --git a/forge_client/src/net/minecraft/src/forge/IArmorTextureProvider.java b/forge_client/src/net/minecraft/src/forge/IArmorTextureProvider.java index 5b996c6d8a..e024e23cbd 100644 --- a/forge_client/src/net/minecraft/src/forge/IArmorTextureProvider.java +++ b/forge_client/src/net/minecraft/src/forge/IArmorTextureProvider.java @@ -5,6 +5,8 @@ package net.minecraft.src.forge; +import net.minecraft.src.ItemStack; + /** * This interface has to be implemented by an instance of ItemArmor. * It allows for the application of a custom texture file to the player skin @@ -17,7 +19,7 @@ public interface IArmorTextureProvider { * format as iron_1.png (or any of the other armor files). It will be * applied to the player skin when the armor is worn. */ - public String getArmorTextureFile(); + public String getArmorTextureFile(ItemStack itemstack); } diff --git a/forge_common/net/minecraft/src/forge/ForgeHooks.java b/forge_common/net/minecraft/src/forge/ForgeHooks.java index c6030ac91a..18815faee8 100644 --- a/forge_common/net/minecraft/src/forge/ForgeHooks.java +++ b/forge_common/net/minecraft/src/forge/ForgeHooks.java @@ -11,12 +11,16 @@ import net.minecraft.src.IInventory; import net.minecraft.src.ItemStack; import net.minecraft.src.Item; import net.minecraft.src.EnumStatus; +import net.minecraft.src.World; import java.util.*; public class ForgeHooks { // TODO: move all app-side hooks from MinecraftForge - // + + + // List Handling Hooks + // ------------------------------------------------------------ public static void onTakenFromCrafting(EntityPlayer player, ItemStack ist, IInventory craftMatrix) { for (ICraftingHandler handler : craftingHandlers) { @@ -34,6 +38,17 @@ public class ForgeHooks { static LinkedList destroyToolHandlers = new LinkedList(); + public static boolean onUseBonemeal(World world, + int bid, int i, int j, int k) { + for(IBonemealHandler handler : bonemealHandlers) { + if(handler.onUseBonemeal(world,bid,i,j,k)) + return true; + } + return false; + } + + static LinkedList bonemealHandlers = new LinkedList(); + public static EnumStatus sleepInBedAt(EntityPlayer player, int i, int j, int k) { for (ISleepHandler handler : sleepHandlers) { EnumStatus status = handler.sleepInBedAt(player, i, j, k); @@ -44,6 +59,82 @@ public class ForgeHooks { } static LinkedList sleepHandlers = new LinkedList(); + + // Plant Management + // ------------------------------------------------------------ + static class ProbableItem { + public ProbableItem(int item, int md, int q, int st, int e) { + wstart=st; wend=e; + itemid=item; meta=md; + qty=q; + } + int wstart, wend; + int itemid, meta; + int qty; + } + + static ProbableItem getRandomItem(List list, int prop) { + int n=Collections.binarySearch(list,prop,new Comparator(){ + public int compare(Object o1, Object o2) { + ProbableItem pi=(ProbableItem)o1; + Integer i1=(Integer)o2; + if(i1=pi.wend) return -1; + return 0; + } + }); + if(n<0) return null; + return list.get(n); + } + + static List plantGrassList; + static int plantGrassWeight; + + static List seedGrassList; + static int seedGrassWeight; + + static { + plantGrassList=new ArrayList(); + plantGrassList.add(new ProbableItem( + Block.plantYellow.blockID,0,1,0,30)); + plantGrassList.add(new ProbableItem( + Block.plantRed.blockID,0,1,30,40)); + plantGrassWeight=40; + + seedGrassList=new ArrayList(); + seedGrassList.add(new ProbableItem( + Item.seeds.shiftedIndex,0,1,0,10)); + seedGrassWeight=10; + } + + public static void plantGrassPlant(World world, int i, int j, int k) { + int n=world.rand.nextInt(plantGrassWeight); + ProbableItem pi=getRandomItem(plantGrassList,n); + if(pi==null) return; + world.setBlockAndMetadataWithNotify(i,j,k,pi.itemid,pi.meta); + } + + public static void addPlantGrass(int item, int md, int prop) { + plantGrassList.add(new ProbableItem( + item,md,1,plantGrassWeight,plantGrassWeight+prop)); + plantGrassWeight+=prop; + } + + public static ItemStack getGrassSeed(World world) { + int n=world.rand.nextInt(seedGrassWeight); + ProbableItem pi=getRandomItem(seedGrassList,n); + if(pi==null) return null; + return new ItemStack(pi.itemid,pi.qty,pi.meta); + } + + public static void addGrassSeed(int item, int md, int qty, int prop) { + seedGrassList.add(new ProbableItem( + item,md,qty,seedGrassWeight,seedGrassWeight+prop)); + seedGrassWeight+=prop; + } + + // Tool Path + // ------------------------------------------------------------ public static boolean canHarvestBlock(Block bl, EntityPlayer player, int md) { if(bl.blockMaterial.getIsHarvestable()) @@ -139,7 +230,7 @@ public class ForgeHooks { public static final int majorVersion=1; public static final int minorVersion=1; - public static final int revisionVersion=0; + public static final int revisionVersion=1; static { System.out.printf("MinecraftForge V%d.%d.%d Initialized\n",majorVersion,minorVersion,revisionVersion); } diff --git a/forge_common/net/minecraft/src/forge/IBonemealHandler.java b/forge_common/net/minecraft/src/forge/IBonemealHandler.java new file mode 100644 index 0000000000..ac2ae0b339 --- /dev/null +++ b/forge_common/net/minecraft/src/forge/IBonemealHandler.java @@ -0,0 +1,18 @@ +/** + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ + +package net.minecraft.src.forge; + +import net.minecraft.src.World; + +public interface IBonemealHandler { + /** Called when bonemeal is used on a block. This is also called for + * multiplayer servers, which must still return true if appropriate but + * shouldn't actually perform world manipulation. + * @return true to use up the bonemeal and stop processing. + */ + public boolean onUseBonemeal(World world, int bid, int i, int j, int k); +} + diff --git a/forge_common/net/minecraft/src/forge/ISidedInventory.java b/forge_common/net/minecraft/src/forge/ISidedInventory.java new file mode 100644 index 0000000000..c6d4755b12 --- /dev/null +++ b/forge_common/net/minecraft/src/forge/ISidedInventory.java @@ -0,0 +1,29 @@ +/** + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ + +package net.minecraft.src.forge; + +/** Inventory ranges mapped by side. This class is implemented by TileEntities + * that provide different inventory slot ranges to different sides. + */ +public interface ISidedInventory { + + /** Get the start of the side inventory. + * @param side The global side to get the start of range. + * 0: -Y (bottom side) + * 1: +Y (top side) + * 2: -Z + * 3: +Z + * 4: -X + * 5: +x + */ + int getStartInventorySide(int side); + + /** Get the size of the side inventory. + * @param side The global side. + */ + int getSizeInventorySide(int side); +} + diff --git a/forge_common/net/minecraft/src/forge/MinecraftForge.java b/forge_common/net/minecraft/src/forge/MinecraftForge.java index 6a1e92a78a..51bff0894b 100755 --- a/forge_common/net/minecraft/src/forge/MinecraftForge.java +++ b/forge_common/net/minecraft/src/forge/MinecraftForge.java @@ -16,15 +16,6 @@ public class MinecraftForge { private static LinkedList bucketHandlers = new LinkedList(); - /** - * Registers a new custom bucket handler. - * @deprecated Spelling mistake, don't use this function! It will go away - * soon. - */ - public static void registerCustomBucketHander(IBucketHandler handler) { - bucketHandlers.add(handler); - } - /** * Register a new custom bucket handler. */ @@ -39,6 +30,13 @@ public class MinecraftForge { ForgeHooks.sleepHandlers.add(handler); } + /** + * Registers a new bonemeal handler. + */ + public static void registerBonemealHandler(IBonemealHandler handler) { + ForgeHooks.bonemealHandlers.add(handler); + } + /** * Registers a new destroy tool handler. */ @@ -68,6 +66,27 @@ public class MinecraftForge { return null; } + /** Register a new plant to be planted when bonemeal is used on grass. + * @param bid The block ID to plant. + * @param md The metadata to plant. + * @param prop The relative probability of the plant, where red flowers are + * 10 and yellow flowers are 30. + */ + public static void addGrassPlant(int item, int md, int prop) { + ForgeHooks.addPlantGrass(item,md,prop); + } + + /** Register a new seed to be dropped when breaking tall grass. + * @param bid The item ID of the seeds. + * @param md The metadata of the seeds. + * @param qty The quantity of seeds to drop. + * @param prop The relative probability of the seeds, where wheat seeds are + * 10. + */ + public static void addGrassSeed(int item, int md, int qty, int prop) { + ForgeHooks.addGrassSeed(item,md,qty,prop); + } + /** Register a tool as a tool class with a given harvest level. * * @param tool The custom tool to register. @@ -158,13 +177,6 @@ public class MinecraftForge { } } - /** - * This function is deprecated and will be removed eventually. - */ - public static void addPickaxeBlockEffectiveAgainst (Block block) { - setBlockHarvestLevel(block,"pickaxe",0); - } - /** * Kill minecraft with an error message. */ diff --git a/minecraft.patch b/minecraft.patch index 2822159b1b..43597c57b2 100644 --- a/minecraft.patch +++ b/minecraft.patch @@ -175,6 +175,55 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/BlockCont public void playBlock(World world, int i, int j, int k, int l, int i1) { super.playBlock(world, i, j, k, l, i1); +diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/BlockCrops.java ../src_work/minecraft/net/minecraft/src/BlockCrops.java +--- ../src_base/minecraft/net/minecraft/src/BlockCrops.java 2011-09-26 15:46:45.000000000 -0400 ++++ ../src_work/minecraft/net/minecraft/src/BlockCrops.java 2011-10-02 03:22:32.000000000 -0400 +@@ -5,6 +5,7 @@ + package net.minecraft.src; + + import java.util.Random; ++import java.util.ArrayList; + + // Referenced classes of package net.minecraft.src: + // BlockFlower, Block, World, EntityItem, +@@ -108,27 +109,16 @@ + return 6; + } + +- public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f) +- { +- super.dropBlockAsItemWithChance(world, i, j, k, l, f); +- if(world.multiplayerWorld) +- { +- return; +- } +- for(int i1 = 0; i1 < 3; i1++) +- { +- if(world.rand.nextInt(15) <= l) +- { +- float f1 = 0.7F; +- float f2 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F; +- float f3 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F; +- float f4 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F; +- EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.seeds)); +- entityitem.delayBeforeCanPickup = 10; +- world.entityJoinedWorld(entityitem); +- } +- } +- ++ public ArrayList getBlockDropped(World world, ++ int i, int j, int k, int md) { ++ ArrayList tr=new ArrayList(); ++ if(md==7) tr.add(new ItemStack(Item.wheat)); ++ ++ for(int n=0; n<3; n++) { ++ if(world.rand.nextInt(15) <= md) ++ tr.add(new ItemStack(Item.seeds)); ++ } ++ return tr; + } + + public int idDropped(int i, Random random) diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/BlockDoor.java ../src_work/minecraft/net/minecraft/src/BlockDoor.java --- ../src_base/minecraft/net/minecraft/src/BlockDoor.java 2011-09-26 15:46:45.000000000 -0400 +++ ../src_work/minecraft/net/minecraft/src/BlockDoor.java 2011-09-28 22:34:34.000000000 -0400 @@ -198,7 +247,7 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/BlockDoor diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Block.java ../src_work/minecraft/net/minecraft/src/Block.java --- ../src_base/minecraft/net/minecraft/src/Block.java 2011-09-26 15:46:44.000000000 -0400 -+++ ../src_work/minecraft/net/minecraft/src/Block.java 2011-09-28 22:34:34.000000000 -0400 ++++ ../src_work/minecraft/net/minecraft/src/Block.java 2011-10-02 03:06:23.000000000 -0400 @@ -4,6 +4,7 @@ package net.minecraft.src; @@ -224,7 +273,7 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Block.jav } public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) -@@ -278,24 +281,24 @@ +@@ -278,24 +281,40 @@ return 1; } @@ -257,19 +306,50 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Block.jav - return entityplayer.getCurrentPlayerStrVsBlock(this) / blockHardness / 30F; - } + return blockStrength(entityplayer,0); ++ } ++ ++ /* FORGE: This function returns the complete list of drops for a block. ++ */ ++ public ArrayList getBlockDropped(World world, ++ int i, int j, int k, int md) { ++ ArrayList tr=new ArrayList(); ++ ++ int q=quantityDropped(md,world.rand); ++ for(int n=0; n0) { ++ tr.add(new ItemStack(id,1,damageDropped(md))); ++ } ++ } ++ return tr; } public final void dropBlockAsItem(World world, int i, int j, int k, int l) -@@ -309,7 +312,7 @@ +@@ -309,20 +328,12 @@ { return; } - int i1 = quantityDropped(world.rand); -+ int i1 = quantityDropped(l,world.rand); - for(int j1 = 0; j1 < i1; j1++) - { +- for(int j1 = 0; j1 < i1; j1++) +- { ++ ArrayList ar=getBlockDropped(world,i,j,k,l); ++ for(ItemStack ist : ar) { if(world.rand.nextFloat() > f) -@@ -618,6 +621,86 @@ +- { + continue; +- } +- int k1 = idDropped(l, world.rand); +- if(k1 > 0) +- { +- dropBlockAsItem_do(world, i, j, k, new ItemStack(k1, 1, damageDropped(l))); +- } ++ dropBlockAsItem_do(world, i, j, k, ist); + } +- + } + + protected void dropBlockAsItem_do(World world, int i, int j, int k, ItemStack itemstack) +@@ -618,6 +629,86 @@ return iblockaccess.isBlockNormalCube(i, j, k) ? 0.2F : 1.0F; } @@ -693,6 +773,45 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/BlockReds if(Block.blocksList[i1].canProvidePower()) { return true; +diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/BlockTallGrass.java ../src_work/minecraft/net/minecraft/src/BlockTallGrass.java +--- ../src_base/minecraft/net/minecraft/src/BlockTallGrass.java 2011-09-26 15:46:45.000000000 -0400 ++++ ../src_work/minecraft/net/minecraft/src/BlockTallGrass.java 2011-10-02 03:45:39.000000000 -0400 +@@ -4,7 +4,10 @@ + + package net.minecraft.src; + ++import net.minecraft.src.forge.ForgeHooks; ++ + import java.util.Random; ++import java.util.ArrayList; + + // Referenced classes of package net.minecraft.src: + // BlockFlower, ColorizerGrass, ColorizerFoliage, IBlockAccess, +@@ -79,13 +82,17 @@ + + public int idDropped(int i, Random random) + { +- if(random.nextInt(8) == 0) +- { +- return Item.seeds.shiftedIndex; +- } else +- { +- return -1; +- } ++ return -1; ++ } ++ ++ public ArrayList getBlockDropped(World world, ++ int i, int j, int k, int md) { ++ ArrayList tr=new ArrayList(); ++ if(world.rand.nextInt(8)!=0) ++ return tr; ++ ItemStack ist=ForgeHooks.getGrassSeed(world); ++ if(ist!=null) tr.add(ist); ++ return tr; + } + + public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/BlockTorch.java ../src_work/minecraft/net/minecraft/src/BlockTorch.java --- ../src_base/minecraft/net/minecraft/src/BlockTorch.java 2011-09-26 15:46:45.000000000 -0400 +++ ../src_work/minecraft/net/minecraft/src/BlockTorch.java 2011-09-28 22:34:34.000000000 -0400 @@ -1586,8 +1705,16 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemBucke world.setBlockWithNotify(i, j, k, 0); diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemDye.java ../src_work/minecraft/net/minecraft/src/ItemDye.java --- ../src_base/minecraft/net/minecraft/src/ItemDye.java 2011-09-26 15:46:44.000000000 -0400 -+++ ../src_work/minecraft/net/minecraft/src/ItemDye.java 2011-09-28 22:34:34.000000000 -0400 -@@ -35,7 +35,7 @@ ++++ ../src_work/minecraft/net/minecraft/src/ItemDye.java 2011-10-02 01:36:25.000000000 -0400 +@@ -3,6 +3,7 @@ + // Decompiler options: packimports(3) braces deadcode + + package net.minecraft.src; ++import net.minecraft.src.forge.ForgeHooks; + + import java.util.Random; + +@@ -35,13 +36,18 @@ public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { @@ -1596,6 +1723,32 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemDye.j { return false; } + if(itemstack.getItemDamage() == 15) + { + int i1 = world.getBlockId(i, j, k); ++ if(ForgeHooks.onUseBonemeal(world,i1,i,j,k)) { ++ if(!world.multiplayerWorld) ++ itemstack.stackSize--; ++ return true; ++ } + if(i1 == Block.sapling.blockID) + { + if(!world.multiplayerWorld) +@@ -108,13 +114,7 @@ + world.setBlockAndMetadataWithNotify(k1, l1, i2, Block.tallGrass.blockID, 1); + continue; + } +- if(itemRand.nextInt(3) != 0) +- { +- world.setBlockWithNotify(k1, l1, i2, Block.plantYellow.blockID); +- } else +- { +- world.setBlockWithNotify(k1, l1, i2, Block.plantRed.blockID); +- } ++ ForgeHooks.plantGrassPlant(world,k1,l1,i2); + } + + } diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemFlintAndSteel.java ../src_work/minecraft/net/minecraft/src/ItemFlintAndSteel.java --- ../src_base/minecraft/net/minecraft/src/ItemFlintAndSteel.java 2011-09-26 15:46:44.000000000 -0400 +++ ../src_work/minecraft/net/minecraft/src/ItemFlintAndSteel.java 2011-09-28 22:34:34.000000000 -0400 @@ -2136,7 +2289,7 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderIte float f = (float)(k1 >> 16 & 0xff) / 255F; diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderPlayer.java ../src_work/minecraft/net/minecraft/src/RenderPlayer.java --- ../src_base/minecraft/net/minecraft/src/RenderPlayer.java 2011-09-26 15:46:45.000000000 -0400 -+++ ../src_work/minecraft/net/minecraft/src/RenderPlayer.java 2011-09-28 22:34:34.000000000 -0400 ++++ ../src_work/minecraft/net/minecraft/src/RenderPlayer.java 2011-10-02 04:49:13.000000000 -0400 @@ -4,6 +4,7 @@ package net.minecraft.src; @@ -2152,7 +2305,7 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderPla - loadTexture((new StringBuilder()).append("/armor/").append(armorFilenamePrefix[itemarmor.renderIndex]).append("_").append(i != 2 ? 1 : 2).append(".png").toString()); + if ( item instanceof IArmorTextureProvider ) + { -+ loadTexture( ((IArmorTextureProvider)item).getArmorTextureFile() ); ++ loadTexture( ((IArmorTextureProvider)item).getArmorTextureFile(itemstack) ); + } + else + { @@ -2371,8 +2524,42 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Tessellat } diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/TileEntityFurnace.java ../src_work/minecraft/net/minecraft/src/TileEntityFurnace.java --- ../src_base/minecraft/net/minecraft/src/TileEntityFurnace.java 2011-09-26 15:46:44.000000000 -0400 -+++ ../src_work/minecraft/net/minecraft/src/TileEntityFurnace.java 2011-09-28 22:34:34.000000000 -0400 -@@ -196,7 +196,7 @@ ++++ ../src_work/minecraft/net/minecraft/src/TileEntityFurnace.java 2011-10-02 04:28:11.000000000 -0400 +@@ -4,6 +4,7 @@ + + package net.minecraft.src; + ++import net.minecraft.src.forge.ISidedInventory; + + // Referenced classes of package net.minecraft.src: + // TileEntity, IInventory, ItemStack, NBTTagCompound, +@@ -12,7 +13,7 @@ + // EntityPlayer + + public class TileEntityFurnace extends TileEntity +- implements IInventory ++ implements IInventory, ISidedInventory + { + + public TileEntityFurnace() +@@ -28,6 +29,16 @@ + return furnaceItemStacks.length; + } + ++ public int getStartInventorySide(int side) { ++ if(side==0) return 1; ++ if(side==1) return 0; ++ return 2; ++ } ++ ++ public int getSizeInventorySide(int side) { ++ return 1; ++ } ++ + public ItemStack getStackInSlot(int i) + { + return furnaceItemStacks[i]; +@@ -196,7 +207,7 @@ { return false; } @@ -2381,7 +2568,22 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/TileEntit if(itemstack == null) { return false; -@@ -222,12 +222,12 @@ +@@ -209,11 +220,9 @@ + { + return false; + } +- if(furnaceItemStacks[2].stackSize < getInventoryStackLimit() && furnaceItemStacks[2].stackSize < furnaceItemStacks[2].getMaxStackSize()) +- { +- return true; +- } +- return furnaceItemStacks[2].stackSize < itemstack.getMaxStackSize(); ++ int st=furnaceItemStacks[2].stackSize+itemstack.stackSize; ++ return (st<=getInventoryStackLimit() && ++ st<=itemstack.getMaxStackSize()); + } + + public void smeltItem() +@@ -222,14 +231,14 @@ { return; } @@ -2394,8 +2596,20 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/TileEntit - if(furnaceItemStacks[2].itemID == itemstack.itemID) + if(furnaceItemStacks[2].isItemEqual(itemstack)) { - furnaceItemStacks[2].stackSize++; +- furnaceItemStacks[2].stackSize++; ++ furnaceItemStacks[2].stackSize+=itemstack.stackSize; } + if(furnaceItemStacks[0].getItem().hasContainerItem()) + { +@@ -244,7 +253,7 @@ + } + } + +- private int getItemBurnTime(ItemStack itemstack) ++ public static int getItemBurnTime(ItemStack itemstack) + { + if(itemstack == null) + { diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/TileEntity.java ../src_work/minecraft/net/minecraft/src/TileEntity.java --- ../src_base/minecraft/net/minecraft/src/TileEntity.java 2011-09-26 15:46:45.000000000 -0400 +++ ../src_work/minecraft/net/minecraft/src/TileEntity.java 2011-09-28 22:34:34.000000000 -0400 @@ -2888,6 +3102,55 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Bl public void playBlock(World world, int i, int j, int k, int l, int i1) { super.playBlock(world, i, j, k, l, i1); +diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/BlockCrops.java ../src_work/minecraft_server/net/minecraft/src/BlockCrops.java +--- ../src_base/minecraft_server/net/minecraft/src/BlockCrops.java 2011-09-26 15:46:46.000000000 -0400 ++++ ../src_work/minecraft_server/net/minecraft/src/BlockCrops.java 2011-10-02 03:22:30.000000000 -0400 +@@ -5,6 +5,7 @@ + package net.minecraft.src; + + import java.util.Random; ++import java.util.ArrayList; + + // Referenced classes of package net.minecraft.src: + // BlockFlower, Block, World, EntityItem, +@@ -103,27 +104,16 @@ + return blockIndexInTexture + j; + } + +- public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f) +- { +- super.dropBlockAsItemWithChance(world, i, j, k, l, f); +- if(world.singleplayerWorld) +- { +- return; +- } +- for(int i1 = 0; i1 < 3; i1++) +- { +- if(world.rand.nextInt(15) <= l) +- { +- float f1 = 0.7F; +- float f2 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F; +- float f3 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F; +- float f4 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F; +- EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.seeds)); +- entityitem.delayBeforeCanPickup = 10; +- world.entityJoinedWorld(entityitem); +- } +- } +- ++ public ArrayList getBlockDropped(World world, ++ int i, int j, int k, int md) { ++ ArrayList tr=new ArrayList(); ++ if(md==7) tr.add(new ItemStack(Item.wheat)); ++ ++ for(int n=0; n<3; n++) { ++ if(world.rand.nextInt(15) <= md) ++ tr.add(new ItemStack(Item.seeds)); ++ } ++ return tr; + } + + public int idDropped(int i, Random random) diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/BlockDoor.java ../src_work/minecraft_server/net/minecraft/src/BlockDoor.java --- ../src_base/minecraft_server/net/minecraft/src/BlockDoor.java 2011-09-26 15:46:46.000000000 -0400 +++ ../src_work/minecraft_server/net/minecraft/src/BlockDoor.java 2011-09-28 22:34:34.000000000 -0400 @@ -2911,7 +3174,7 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Bl diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Block.java ../src_work/minecraft_server/net/minecraft/src/Block.java --- ../src_base/minecraft_server/net/minecraft/src/Block.java 2011-09-26 15:46:45.000000000 -0400 -+++ ../src_work/minecraft_server/net/minecraft/src/Block.java 2011-09-28 22:34:34.000000000 -0400 ++++ ../src_work/minecraft_server/net/minecraft/src/Block.java 2011-10-02 03:06:26.000000000 -0400 @@ -3,6 +3,7 @@ // Decompiler options: packimports(3) braces deadcode @@ -2920,7 +3183,7 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Bl import java.util.ArrayList; import java.util.Random; -@@ -218,24 +219,24 @@ +@@ -218,24 +219,40 @@ return 1; } @@ -2953,19 +3216,50 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Bl - return entityplayer.getCurrentPlayerStrVsBlock(this) / blockHardness / 30F; - } + return blockStrength(entityplayer,0); ++ } ++ ++ /* FORGE: This function returns the complete list of drops for a block. ++ */ ++ public ArrayList getBlockDropped(World world, ++ int i, int j, int k, int md) { ++ ArrayList tr=new ArrayList(); ++ ++ int q=quantityDropped(md,world.rand); ++ for(int n=0; n0) { ++ tr.add(new ItemStack(id,1,damageDropped(md))); ++ } ++ } ++ return tr; } public final void dropBlockAsItem(World world, int i, int j, int k, int l) -@@ -249,7 +250,7 @@ +@@ -249,20 +266,12 @@ { return; } - int i1 = quantityDropped(world.rand); -+ int i1 = quantityDropped(l,world.rand); - for(int j1 = 0; j1 < i1; j1++) - { +- for(int j1 = 0; j1 < i1; j1++) +- { ++ ArrayList ar=getBlockDropped(world,i,j,k,l); ++ for(ItemStack ist : ar) { if(world.rand.nextFloat() > f) -@@ -529,6 +530,86 @@ +- { + continue; +- } +- int k1 = idDropped(l, world.rand); +- if(k1 > 0) +- { +- dropBlockAsItem_do(world, i, j, k, new ItemStack(k1, 1, damageDropped(l))); +- } ++ dropBlockAsItem_do(world, i, j, k, ist); + } +- + } + + protected void dropBlockAsItem_do(World world, int i, int j, int k, ItemStack itemstack) +@@ -529,6 +538,86 @@ return blockMaterial.getMaterialMobility(); } @@ -3389,6 +3683,44 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Bl if(Block.blocksList[i1].canProvidePower()) { return true; +diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/BlockTallGrass.java ../src_work/minecraft_server/net/minecraft/src/BlockTallGrass.java +--- ../src_base/minecraft_server/net/minecraft/src/BlockTallGrass.java 2011-09-26 15:46:46.000000000 -0400 ++++ ../src_work/minecraft_server/net/minecraft/src/BlockTallGrass.java 2011-10-02 03:45:35.000000000 -0400 +@@ -4,7 +4,10 @@ + + package net.minecraft.src; + ++import net.minecraft.src.forge.ForgeHooks; ++ + import java.util.Random; ++import java.util.ArrayList; + + // Referenced classes of package net.minecraft.src: + // BlockFlower, Item, World, EntityPlayer, +@@ -41,13 +44,17 @@ + + public int idDropped(int i, Random random) + { +- if(random.nextInt(8) == 0) +- { +- return Item.seeds.shiftedIndex; +- } else +- { + return -1; +- } ++ } ++ ++ public ArrayList getBlockDropped(World world, ++ int i, int j, int k, int md) { ++ ArrayList tr=new ArrayList(); ++ if(world.rand.nextInt(8)!=0) ++ return tr; ++ ItemStack ist=ForgeHooks.getGrassSeed(world); ++ if(ist!=null) tr.add(ist); ++ return tr; + } + + public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/BlockTorch.java ../src_work/minecraft_server/net/minecraft/src/BlockTorch.java --- ../src_base/minecraft_server/net/minecraft/src/BlockTorch.java 2011-09-26 15:46:46.000000000 -0400 +++ ../src_work/minecraft_server/net/minecraft/src/BlockTorch.java 2011-09-28 22:34:34.000000000 -0400 @@ -4045,8 +4377,16 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/It return itemstack; diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/ItemDye.java ../src_work/minecraft_server/net/minecraft/src/ItemDye.java --- ../src_base/minecraft_server/net/minecraft/src/ItemDye.java 2011-09-26 15:46:45.000000000 -0400 -+++ ../src_work/minecraft_server/net/minecraft/src/ItemDye.java 2011-09-28 22:34:34.000000000 -0400 -@@ -29,7 +29,7 @@ ++++ ../src_work/minecraft_server/net/minecraft/src/ItemDye.java 2011-10-02 01:36:28.000000000 -0400 +@@ -3,6 +3,7 @@ + // Decompiler options: packimports(3) braces deadcode + + package net.minecraft.src; ++import net.minecraft.src.forge.ForgeHooks; + + import java.util.Random; + +@@ -29,13 +30,18 @@ public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { @@ -4055,6 +4395,32 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/It { return false; } + if(itemstack.getItemDamage() == 15) + { + int i1 = world.getBlockId(i, j, k); ++ if(ForgeHooks.onUseBonemeal(world,i1,i,j,k)) { ++ if(!world.singleplayerWorld) ++ itemstack.stackSize--; ++ return true; ++ } + if(i1 == Block.sapling.blockID) + { + if(!world.singleplayerWorld) +@@ -102,13 +108,7 @@ + world.setBlockAndMetadataWithNotify(k1, l1, i2, Block.tallGrass.blockID, 1); + continue; + } +- if(itemRand.nextInt(3) != 0) +- { +- world.setBlockWithNotify(k1, l1, i2, Block.plantYellow.blockID); +- } else +- { +- world.setBlockWithNotify(k1, l1, i2, Block.plantRed.blockID); +- } ++ ForgeHooks.plantGrassPlant(world,k1,l1,i2); + } + + } diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/ItemFlintAndSteel.java ../src_work/minecraft_server/net/minecraft/src/ItemFlintAndSteel.java --- ../src_base/minecraft_server/net/minecraft/src/ItemFlintAndSteel.java 2011-09-26 15:46:45.000000000 -0400 +++ ../src_work/minecraft_server/net/minecraft/src/ItemFlintAndSteel.java 2011-09-28 22:34:34.000000000 -0400 @@ -4304,8 +4670,42 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Sl ItemStack itemstack1 = craftMatrix.getStackInSlot(i); diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/TileEntityFurnace.java ../src_work/minecraft_server/net/minecraft/src/TileEntityFurnace.java --- ../src_base/minecraft_server/net/minecraft/src/TileEntityFurnace.java 2011-09-26 15:46:45.000000000 -0400 -+++ ../src_work/minecraft_server/net/minecraft/src/TileEntityFurnace.java 2011-09-28 22:34:34.000000000 -0400 -@@ -176,7 +176,7 @@ ++++ ../src_work/minecraft_server/net/minecraft/src/TileEntityFurnace.java 2011-10-02 04:22:11.000000000 -0400 +@@ -4,6 +4,7 @@ + + package net.minecraft.src; + ++import net.minecraft.src.forge.ISidedInventory; + + // Referenced classes of package net.minecraft.src: + // TileEntity, IInventory, ItemStack, NBTTagCompound, +@@ -12,7 +13,7 @@ + // EntityPlayer + + public class TileEntityFurnace extends TileEntity +- implements IInventory ++ implements IInventory, ISidedInventory + { + + public TileEntityFurnace() +@@ -28,6 +29,16 @@ + return furnaceItemStacks.length; + } + ++ public int getStartInventorySide(int side) { ++ if(side==0) return 1; ++ if(side==1) return 0; ++ return 2; ++ } ++ ++ public int getSizeInventorySide(int side) { ++ return 1; ++ } ++ + public ItemStack getStackInSlot(int i) + { + return furnaceItemStacks[i]; +@@ -176,7 +187,7 @@ { return false; } @@ -4314,7 +4714,24 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Ti if(itemstack == null) { return false; -@@ -204,12 +204,12 @@ +@@ -189,13 +200,9 @@ + { + return false; + } +- if(furnaceItemStacks[2].stackSize < getInventoryStackLimit() && furnaceItemStacks[2].stackSize < furnaceItemStacks[2].getMaxStackSize()) +- { +- return true; +- } else +- { +- return furnaceItemStacks[2].stackSize < itemstack.getMaxStackSize(); +- } ++ int st=furnaceItemStacks[2].stackSize+itemstack.stackSize; ++ return (st<=getInventoryStackLimit() && ++ st<=itemstack.getMaxStackSize()); + } + + public void smeltItem() +@@ -204,23 +211,29 @@ { return; } @@ -4326,9 +4743,29 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Ti } else - if(furnaceItemStacks[2].itemID == itemstack.itemID) + if(furnaceItemStacks[2].isItemEqual(itemstack)) ++ { ++ furnaceItemStacks[2].stackSize+=itemstack.stackSize; ++ } ++ if(furnaceItemStacks[0].getItem().hasContainerItem()) ++ { ++ furnaceItemStacks[0] = new ItemStack(furnaceItemStacks[0].getItem().getContainerItem()); ++ } else { - furnaceItemStacks[2].stackSize++; +- furnaceItemStacks[2].stackSize++; ++ furnaceItemStacks[0].stackSize--; } +- furnaceItemStacks[0].stackSize--; + if(furnaceItemStacks[0].stackSize <= 0) + { + furnaceItemStacks[0] = null; + } + } + +- private int getItemBurnTime(ItemStack itemstack) ++ public static int getItemBurnTime(ItemStack itemstack) + { + if(itemstack == null) + { diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/TileEntity.java ../src_work/minecraft_server/net/minecraft/src/TileEntity.java --- ../src_base/minecraft_server/net/minecraft/src/TileEntity.java 2011-09-26 15:46:46.000000000 -0400 +++ ../src_work/minecraft_server/net/minecraft/src/TileEntity.java 2011-09-28 22:34:34.000000000 -0400 @@ -4348,7 +4785,7 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Ti TileEntity tileentity = null; diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/World.java ../src_work/minecraft_server/net/minecraft/src/World.java --- ../src_base/minecraft_server/net/minecraft/src/World.java 2011-09-26 15:46:45.000000000 -0400 -+++ ../src_work/minecraft_server/net/minecraft/src/World.java 2011-09-28 22:34:34.000000000 -0400 ++++ ../src_work/minecraft_server/net/minecraft/src/World.java 2011-10-01 20:06:23.000000000 -0400 @@ -183,7 +183,11 @@ public boolean isAirBlock(int i, int j, int k)