diff --git a/forge_common/net/minecraft/src/forge/oredict/OreDictionary.java b/common/net/minecraftforge/oredict/OreDictionary.java similarity index 80% rename from forge_common/net/minecraft/src/forge/oredict/OreDictionary.java rename to common/net/minecraftforge/oredict/OreDictionary.java index 78ddc848f..83d63b5b2 100644 --- a/forge_common/net/minecraft/src/forge/oredict/OreDictionary.java +++ b/common/net/minecraftforge/oredict/OreDictionary.java @@ -1,4 +1,4 @@ -package net.minecraft.src.forge.oredict; +package net.minecraftforge.oredict; import java.util.ArrayList; import java.util.HashMap; @@ -10,14 +10,14 @@ import java.util.Map.Entry; import net.minecraft.src.Block; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; -import net.minecraft.src.forge.IOreHandler; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.Event; public class OreDictionary { private static int maxID = 0; private static HashMap oreIDs = new HashMap(); private static HashMap> oreStacks = new HashMap>(); - private static ArrayList oreHandlers = new ArrayList(); /** * Gets the integer ID for the specified ore name. @@ -68,6 +68,16 @@ public class OreDictionary return getOres(getOreID(name)); } + /** + * Retrieves a list of all unique ore names that are already registered. + * + * @return All unique ore names that are currently registered. + */ + public static String[] getOreNames() + { + return oreIDs.keySet().toArray(new String[0]); + } + /** * Retrieves the ArrayList of items that are registered to this ore type. * Creates the list as empty if it did not exist. @@ -86,28 +96,6 @@ public class OreDictionary return val; } - /** - * Register a new ore handler. - * This will automatically call the handler with all current ores during - * registration, and every time a new ore is added later. - * - * @param handler The Ore Handler - */ - public static void registerOreHandler(IOreHandler handler) - { - oreHandlers.add(handler); - - HashMap tmp = (HashMap)oreIDs.clone(); - - for(Map.Entry entry : tmp.entrySet()) - { - for(ItemStack stack : getOres(entry.getValue())) - { - handler.registerOre(entry.getKey(), stack); - } - } - } - //Convenience functions that make for cleaner code mod side. They all drill down to registerOre(String, int, ItemStack) public static void registerOre(String name, Item ore){ registerOre(name, new ItemStack(ore)); } public static void registerOre(String name, Block ore){ registerOre(name, new ItemStack(ore)); } @@ -129,10 +117,18 @@ public class OreDictionary ArrayList ores = getOres(id); ore = ore.copy(); ores.add(ore); + MinecraftForge.eventBus.post(new OreRegisterEvent(name, ore)); + } + + public static class OreRegisterEvent extends Event + { + public final String Name; + public final ItemStack Ore; - for (IOreHandler handler : oreHandlers) + public OreRegisterEvent(String name, ItemStack ore) { - handler.registerOre(name, ore); + this.Name = name; + this.Ore = ore; } } } diff --git a/forge_common/net/minecraft/src/forge/oredict/ShapedOreRecipe.java b/common/net/minecraftforge/oredict/ShapedOreRecipe.java similarity index 99% rename from forge_common/net/minecraft/src/forge/oredict/ShapedOreRecipe.java rename to common/net/minecraftforge/oredict/ShapedOreRecipe.java index 2214ca8d8..eb04970a0 100644 --- a/forge_common/net/minecraft/src/forge/oredict/ShapedOreRecipe.java +++ b/common/net/minecraftforge/oredict/ShapedOreRecipe.java @@ -1,4 +1,4 @@ -package net.minecraft.src.forge.oredict; +package net.minecraftforge.oredict; import java.util.ArrayList; import java.util.HashMap; diff --git a/forge_common/net/minecraft/src/forge/oredict/ShapelessOreRecipe.java b/common/net/minecraftforge/oredict/ShapelessOreRecipe.java similarity index 98% rename from forge_common/net/minecraft/src/forge/oredict/ShapelessOreRecipe.java rename to common/net/minecraftforge/oredict/ShapelessOreRecipe.java index bf0c5e9d7..9e8365a7d 100644 --- a/forge_common/net/minecraft/src/forge/oredict/ShapelessOreRecipe.java +++ b/common/net/minecraftforge/oredict/ShapelessOreRecipe.java @@ -1,4 +1,4 @@ -package net.minecraft.src.forge.oredict; +package net.minecraftforge.oredict; import java.util.ArrayList; import java.util.Iterator; diff --git a/forge_common/net/minecraft/src/forge/IArrowLooseHandler.java b/forge_common/net/minecraft/src/forge/IArrowLooseHandler.java deleted file mode 100644 index 9646b9e6d..000000000 --- a/forge_common/net/minecraft/src/forge/IArrowLooseHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This software is provided under the terms of the Minecraft Forge Public - * License v1.0. - */ -package net.minecraft.src.forge; - -import net.minecraft.src.EntityPlayer; -import net.minecraft.src.ItemStack; -import net.minecraft.src.World; - -public interface IArrowLooseHandler -{ - /** - * This is called before a bow tries to shoot an arrow. If it - * returns a true result, then the normal arrow will not be shot. - * - * @param itemstack The ItemStack for the bow doing the firing - * @param world The current world - * @param player The player that is firing the bow - * @param heldTime The amount of ticks the bow was held ready. - * @return True if the event should be canceled. - */ - public boolean onArrowLoose(ItemStack itemstack, World world, EntityPlayer player, int heldTime); -} diff --git a/forge_common/net/minecraft/src/forge/IArrowNockHandler.java b/forge_common/net/minecraft/src/forge/IArrowNockHandler.java deleted file mode 100644 index 9c5e9197b..000000000 --- a/forge_common/net/minecraft/src/forge/IArrowNockHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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; -import net.minecraft.src.World; -import net.minecraft.src.EntityPlayer; - -public interface IArrowNockHandler -{ - - /** - * This is called before a player tries to load an arrow. If it returns - * a non-null result, then the normal arrow will not be loaded and the - * bow will be changed to the returned value. - * - * @param itemstack The ItemStack for the bow doing the firing - * @param world The current world - * @param player The player that is using the bow - * @return The new bow item, or null to continue normally. - */ - public ItemStack onArrowNock(ItemStack itemstack, World world, EntityPlayer player); - -} \ No newline at end of file diff --git a/forge_common/net/minecraft/src/forge/IOreHandler.java b/forge_common/net/minecraft/src/forge/IOreHandler.java deleted file mode 100644 index 088d2f42b..000000000 --- a/forge_common/net/minecraft/src/forge/IOreHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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; - -/** The current list of known classes. - * oreTin, oreCopper, oreSilver, oreUranium - * ingotTin, ingotCopper, ingotSilver, ingotBrass, ingotBronze - * ingotUranium, ingotRefinedIron - * dyeBlue - * gemRuby, gemEmerald, gemSapphire - * itemDropUranium - * woodRubber - * itemRubber - */ - -public interface IOreHandler -{ - /** Called when a new ore is registered with the ore dictionary. - * @param oreClass The string class of the ore. - * @param ore The ItemStack for the ore. - */ - public void registerOre(String oreClass, ItemStack ore); -} diff --git a/forge_common/net/minecraft/src/forge/MinecraftForge.java b/forge_common/net/minecraft/src/forge/MinecraftForge.java index 40cce8e6b..d0c51c7e6 100644 --- a/forge_common/net/minecraft/src/forge/MinecraftForge.java +++ b/forge_common/net/minecraft/src/forge/MinecraftForge.java @@ -28,308 +28,6 @@ import java.util.Map.Entry; public class MinecraftForge { - private static LinkedList bucketHandlers = new LinkedList(); - - /** - * Register a new custom bucket handler. - * @param handler The Handler to be registered - */ - public static void registerCustomBucketHandler(IBucketHandler handler) - { - bucketHandlers.add(handler); - } - - /** - * Registers a new sleeping handler. - * @param handler The Handler to be registered - */ - public static void registerSleepHandler(ISleepHandler handler) - { - ForgeHooks.sleepHandlers.add(handler); - } - - /** - * Registers a new bonemeal handler. - * @param handler The Handler to be registered - */ - public static void registerBonemealHandler(IBonemealHandler handler) - { - ForgeHooks.bonemealHandlers.add(handler); - } - - /** - * Registers a new hoe handler. - * @param handler The Handler to be registered - */ - public static void registerHoeHandler(IHoeHandler handler) - { - ForgeHooks.hoeHandlers.add(handler); - } - - /** - * Registers a new destroy tool handler. - * @param handler The Handler to be registered - */ - public static void registerDestroyToolHandler(IDestroyToolHandler handler) - { - ForgeHooks.destroyToolHandlers.add(handler); - } - - /** - * Registers a new crafting handler. - * @param handler The Handler to be registered - */ - public static void registerCraftingHandler(ICraftingHandler handler) - { - ForgeHooks.craftingHandlers.add(handler); - } - - /** - * Registers a new minecart handler - * @param handler The Handler to be registered - */ - public static void registerMinecartHandler(IMinecartHandler handler) - { - ForgeHooks.minecartHandlers.add(handler); - } - - /** - * Registers a new Connection event handler - * @param handler The Handler to be registered - */ - public static void registerConnectionHandler(IConnectionHandler handler) - { - ForgeHooks.connectionHandlers.add(handler); - } - - /** - * Registers a new Chunk Load event handler - * @param handler The Handler to be registered - */ - public static void registerChunkLoadHandler(IChunkLoadHandler handler) - { - ForgeHooks.chunkLoadHandlers.add(handler); - } - - /** - * Registers a new Item Pickup event handler - * @param handler The Handler to be registered - */ - public static void registerPickupHandler(IPickupHandler handler) - { - ForgeHooks.pickupHandlers.add(handler); - } - - /** - * Register a new entity interact handler. - * @param handler The Handler to be registered - */ - public static void registerEntityInteractHandler(IEntityInteractHandler handler) - { - ForgeHooks.entityInteractHandlers.add(handler); - } - - /** - * Registers a new chat handler. - * @param handler The Handler to be registered - */ - public static void registerChatHandler(IChatHandler handler) - { - ForgeHooks.chatHandlers.add(handler); - } - - /** - * Register a new Save handler - * @param handler The handler to be registered - */ - public static void registerSaveHandler(ISaveEventHandler handler) - { - 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); - } - - /** - * Register a new Special Mob Spawn handler - * @param handler The handler to be registered - */ - @Deprecated - public static void registerSpecialMobSpawnHandler(ISpecialMobSpawnHandler handler) - { - if (EntityLiving.class.getPackage() != null) - { - throw new RuntimeException("Still using deprecated method/interface MinecraftForge.registerSpecialModSpawnHandler()"); - } - ForgeHooks.specialMobSpawnHandlers.add(handler); - } - - /** - * Register a new EntityLiving Handler - * @param handler The handler to be registered - */ - public static void registerEntityLivingHandler(IEntityLivingHandler handler) - { - ForgeHooks.entityLivingHandlers.add(handler); - } - - - /** - * This is not supposed to be called outside of Minecraft internals. - */ - public static ItemStack fillCustomBucket(World world, int X, int Y, int Z) - { - for (IBucketHandler handler : bucketHandlers) - { - ItemStack stack = handler.fillCustomBucket(world, X, Y, Z); - - if (stack != null) - { - return stack; - } - } - - return null; - } - - // Ore Dictionary - // ------------------------------------------------------------ - //Deprecated in favor of OreDictionary.registerOreHandler - @Deprecated - public static void registerOreHandler(IOreHandler handler) - { - OreDictionary.registerOreHandler(handler); - } - - //Deprecated in favor of OreDictionary.registerOre - @Deprecated - public static void registerOre(String oreClass, ItemStack ore) - { - OreDictionary.registerOre(oreClass, ore); - } - - //Deprecated in favor of OreDictionary.getOres - @Deprecated - public static List getOreClass(String oreClass) - { - return OreDictionary.getOres(oreClass); - } - - //Deprecated in favor of the Ore recipes, and because it is ugly as heck. - @Deprecated - public static class OreQuery implements Iterable - { - Object[] proto; - - public class OreQueryIterator implements Iterator - { - LinkedList itering = new LinkedList(); - LinkedList output = new LinkedList(); - - private OreQueryIterator() - { - for (Object input : proto) - { - if (input instanceof Collection) - { - Iterator it = ((Collection)input).iterator(); - if (!it.hasNext()) - { - output = null; - break; - } - itering.addLast(it); - output.addLast(it.next()); - } - else - { - itering.addLast(input); - output.addLast(input); - } - } - } - - public boolean hasNext() - { - return output != null; - } - - public Object[] next() - { - Object[] tr = output.toArray(); - Object to; - while (true) - { - if (itering.size() == 0) - { - output = null; - return tr; - } - to = itering.getLast(); - output.removeLast(); - if (to instanceof Iterator) - { - Iterator it = (Iterator)to; - if (it.hasNext()) - { - output.addLast(it.next()); - break; - } - } - itering.removeLast(); - } - for (int i = itering.size(); i < proto.length; i++) - { - if (proto[i] instanceof Collection) - { - Iterator it = ((Collection)proto[i]).iterator(); - if (!it.hasNext()) - { - output = null; - break; - } - itering.addLast(it); - output.addLast(it.next()); - } - else - { - itering.addLast(proto[i]); - output.addLast(proto[i]); - } - } - return tr; - } - - public void remove() {} - } - - private OreQuery(Object[] pattern) - { - proto = pattern; - } - - public Iterator iterator() - { - return new OreQueryIterator(); - } - } - - /** Generate all valid legal recipe combinations. Any Lists in pattern - * will be fully expanded to all valid combinations. - */ - //Deprecated in favor of the new Ore Recipe system - @Deprecated - public static OreQuery generateRecipes(Object... pattern) - { - return new OreQuery(pattern); - } - // ------------------------------------------------------------ /** Register a new plant to be planted when bonemeal is used on grass.