diff --git a/forge/forge_common/net/minecraft/src/forge/ForgeHooks.java b/forge/forge_common/net/minecraft/src/forge/ForgeHooks.java index fc81213af..875283580 100644 --- a/forge/forge_common/net/minecraft/src/forge/ForgeHooks.java +++ b/forge/forge_common/net/minecraft/src/forge/ForgeHooks.java @@ -323,6 +323,20 @@ public class ForgeHooks } static LinkedList saveHandlers = new LinkedList(); + public static int getItemBurnTime(ItemStack stack) + { + for (IFuelHandler handler : fuelHandlers) + { + int ret = handler.getItemBurnTime(stack); + if (ret > 0) + { + return ret; + } + } + return 0; + } + static LinkedList fuelHandlers = new LinkedList(); + // Plant Management // ------------------------------------------------------------ static class ProbableItem diff --git a/forge/forge_common/net/minecraft/src/forge/IFuelHandler.java b/forge/forge_common/net/minecraft/src/forge/IFuelHandler.java new file mode 100644 index 000000000..9c46fb5e1 --- /dev/null +++ b/forge/forge_common/net/minecraft/src/forge/IFuelHandler.java @@ -0,0 +1,16 @@ +/** + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ + +package net.minecraft.src.forge; + +import net.minecraft.src.ItemStack; + +public interface IFuelHandler +{ + /** Called when a furnace gains fuel to get its burn time. + * @return fuel burn time in ticks or 0 to continue processing + */ + public int getItemBurnTime(ItemStack stack); +} \ No newline at end of file diff --git a/forge/forge_common/net/minecraft/src/forge/MinecraftForge.java b/forge/forge_common/net/minecraft/src/forge/MinecraftForge.java index 346b78bad..a55e05f2d 100755 --- a/forge/forge_common/net/minecraft/src/forge/MinecraftForge.java +++ b/forge/forge_common/net/minecraft/src/forge/MinecraftForge.java @@ -138,6 +138,15 @@ public class MinecraftForge ForgeHooks.saveHandlers.add(handler); } + /** + * Register a new Fuel handler + * @param handler The handler to be registered + */ + public static void registerFuelHandler(IFuelHandler handler) + { + ForgeHooks.fuelHandlers.add(handler); + } + /** * This is not supposed to be called outside of Minecraft internals. */ diff --git a/forge/patches/minecraft/net/minecraft/src/TileEntityFurnace.java.patch b/forge/patches/minecraft/net/minecraft/src/TileEntityFurnace.java.patch index 8f8a499b2..7f0ca593d 100644 --- a/forge/patches/minecraft/net/minecraft/src/TileEntityFurnace.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/TileEntityFurnace.java.patch @@ -1,16 +1,17 @@ --- ../src_base/minecraft/net/minecraft/src/TileEntityFurnace.java 0000-00-00 00:00:00.000000000 -0000 +++ ../src_work/minecraft/net/minecraft/src/TileEntityFurnace.java 0000-00-00 00:00:00.000000000 -0000 -@@ -1,6 +1,8 @@ +@@ -1,6 +1,9 @@ package net.minecraft.src; -public class TileEntityFurnace extends TileEntity implements IInventory ++import net.minecraft.src.forge.ForgeHooks; +import net.minecraft.src.forge.ISidedInventory; + +public class TileEntityFurnace extends TileEntity implements IInventory, ISidedInventory { /** * The ItemStacks that hold the items currently being used in the furnace -@@ -279,8 +281,12 @@ +@@ -279,8 +282,12 @@ } else { @@ -25,7 +26,7 @@ } } -@@ -291,13 +297,13 @@ +@@ -291,13 +298,13 @@ { if (this.canSmelt()) { @@ -41,7 +42,23 @@ { this.furnaceItemStacks[2].stackSize += var1.stackSize; } -@@ -351,4 +357,18 @@ +@@ -331,7 +338,14 @@ + else + { + int var1 = par1ItemStack.getItem().shiftedIndex; +- return var1 < 256 && Block.blocksList[var1].blockMaterial == Material.wood ? 300 : (var1 == Item.stick.shiftedIndex ? 100 : (var1 == Item.coal.shiftedIndex ? 1600 : (var1 == Item.bucketLava.shiftedIndex ? 20000 : (var1 == Block.sapling.blockID ? 100 : (var1 == Item.blazeRod.shiftedIndex ? 2400 : ModLoader.addAllFuel(par1ItemStack.itemID, par1ItemStack.getItemDamage())))))); ++ if (var1 < 256 && Block.blocksList[var1].blockMaterial == Material.wood) return 300; ++ if (var1 == Item.stick.shiftedIndex) return 100; ++ if (var1 == Item.coal.shiftedIndex) return 1600; ++ if (var1 == Item.bucketLava.shiftedIndex) return 20000; ++ if (var1 == Block.sapling.blockID) return 100; ++ if (var1 == Item.blazeRod.shiftedIndex) return 2400; ++ int ret = ForgeHooks.getItemBurnTime(par1ItemStack); ++ return (ret > 0 ? ret : ModLoader.addAllFuel(par1ItemStack.itemID, par1ItemStack.getItemDamage())); + } + } + +@@ -351,4 +365,18 @@ public void openChest() {} public void closeChest() {} diff --git a/forge/patches/minecraft_server/net/minecraft/src/TileEntityFurnace.java.patch b/forge/patches/minecraft_server/net/minecraft/src/TileEntityFurnace.java.patch index 98e89f8b8..27711ac28 100644 --- a/forge/patches/minecraft_server/net/minecraft/src/TileEntityFurnace.java.patch +++ b/forge/patches/minecraft_server/net/minecraft/src/TileEntityFurnace.java.patch @@ -1,17 +1,18 @@ --- ../src_base/minecraft_server/net/minecraft/src/TileEntityFurnace.java 0000-00-00 00:00:00.000000000 -0000 +++ ../src_work/minecraft_server/net/minecraft/src/TileEntityFurnace.java 0000-00-00 00:00:00.000000000 -0000 -@@ -2,7 +2,9 @@ +@@ -2,7 +2,10 @@ import cpw.mods.fml.server.FMLServerHandler; -public class TileEntityFurnace extends TileEntity implements IInventory ++import net.minecraft.src.forge.ForgeHooks; +import net.minecraft.src.forge.ISidedInventory; + +public class TileEntityFurnace extends TileEntity implements IInventory, ISidedInventory { /** * The ItemStacks that hold the items currently being used in the furnace -@@ -251,8 +253,12 @@ +@@ -251,8 +254,12 @@ } else { @@ -26,7 +27,7 @@ } } -@@ -263,13 +269,13 @@ +@@ -263,13 +270,13 @@ { if (this.canSmelt()) { @@ -42,7 +43,23 @@ { ++this.furnaceItemStacks[2].stackSize; } -@@ -316,4 +322,18 @@ +@@ -296,7 +303,14 @@ + else + { + int var1 = par1ItemStack.getItem().shiftedIndex; +- return var1 < 256 && Block.blocksList[var1].blockMaterial == Material.wood ? 300 : (var1 == Item.stick.shiftedIndex ? 100 : (var1 == Item.coal.shiftedIndex ? 1600 : (var1 == Item.bucketLava.shiftedIndex ? 20000 : (var1 == Block.sapling.blockID ? 100 : (var1 == Item.blazeRod.shiftedIndex ? 2400 : FMLServerHandler.instance().fuelLookup(var1, par1ItemStack.getItemDamage())))))); ++ if (var1 < 256 && Block.blocksList[var1].blockMaterial == Material.wood) return 300; ++ if (var1 == Item.stick.shiftedIndex) return 100; ++ if (var1 == Item.coal.shiftedIndex) return 1600; ++ if (var1 == Item.bucketLava.shiftedIndex) return 20000; ++ if (var1 == Block.sapling.blockID) return 100; ++ if (var1 == Item.blazeRod.shiftedIndex) return 2400; ++ int ret = ForgeHooks.getItemBurnTime(par1ItemStack); ++ return (ret > 0 ? ret : FMLServerHandler.instance().fuelLookup(var1, par1ItemStack.getItemDamage())); + } + } + +@@ -316,4 +330,18 @@ public void openChest() {} public void closeChest() {}