From a7caad10ba7644b0184930ecb1fe55a9b47d718a Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 26 Jun 2012 15:40:30 -0400 Subject: [PATCH] Add in bukkit support for recipe change --- fml/bukkit/net/minecraft/server/BaseMod.java | 56 +++++++++---------- .../net/minecraft/server/BukkitRegistry.java | 27 ++++++--- fml/bukkit/net/minecraft/src/IRecipe.java | 5 ++ 3 files changed, 51 insertions(+), 37 deletions(-) create mode 100644 fml/bukkit/net/minecraft/src/IRecipe.java diff --git a/fml/bukkit/net/minecraft/server/BaseMod.java b/fml/bukkit/net/minecraft/server/BaseMod.java index ec07d13022..6adfaf6bc3 100644 --- a/fml/bukkit/net/minecraft/server/BaseMod.java +++ b/fml/bukkit/net/minecraft/server/BaseMod.java @@ -65,7 +65,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod public final void onServerLogin(Object handler) { // NOOP } - + public final void onServerLogout() { // NOOP } @@ -80,7 +80,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod { onClientLogout((EntityHuman)player); } - + @Override public final void onPlayerChangedDimension(Object player) { @@ -129,16 +129,16 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod public void onRegisterAnimations() { // NOOP on servers } - + @Override - public void onRenderHarvest(Map renderers) { + public void onRenderHarvest(@SuppressWarnings("rawtypes") Map renderers) { // NOOP on servers } - + // BASEMOD API /** * Override if you wish to provide a fuel item for the furnace and return the fuel value of the item - * + * * @param id * @param metadata * @return @@ -155,7 +155,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Override if you wish to perform some action other than just dispensing the item from the dispenser - * + * * @param world * @param x * @param y @@ -172,7 +172,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Override if you wish to generate Nether (Hell biome) blocks - * + * * @param world * @param random * @param chunkX @@ -184,7 +184,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Override if you wish to generate Overworld (not hell or the end) blocks - * + * * @param world * @param random * @param chunkX @@ -196,7 +196,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Return the name of your mod. Defaults to the class name - * + * * @return */ public String getName() @@ -206,7 +206,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Get your mod priorities - * + * * @return */ public String getPriorities() @@ -216,7 +216,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Return the version of your mod - * + * * @return */ public abstract String getVersion(); @@ -240,7 +240,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Handle item pickup - * + * * @param player * @param item */ @@ -250,7 +250,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)} - * + * * @param minecraftServer the server * @return true to continue receiving ticks */ @@ -267,23 +267,23 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Only implemented on the client side * {@link #onChatMessageReceived(EntityPlayer, Packet3Chat)} - * + * * @param text */ public void receiveChatPacket(String text) { - + } /** * Only called on the client side * {@link #onPacket250Received(EntityPlayer, Packet250CustomPayload)} - * + * * @param packet */ public void receiveCustomPacket(Packet250CustomPayload packet) { - + } public void registerAnimation(Object game) @@ -304,7 +304,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Called when someone crafts an item from a crafting table - * + * * @param player * @param item * @param matrix @@ -344,7 +344,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Called when a chat message is received. Return true to stop further processing - * + * * @param source * @param chat * @return true if you want to consume the message so it is not available for further processing @@ -365,8 +365,8 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Called when a new client logs in. - * - * @param player + * + * @param player */ public void onClientLogin(EntityHuman player) { @@ -374,23 +374,23 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod /** * Called when a client logs out of the server. - * + * * @param player */ public void onClientLogout(EntityHuman player) { - + } /** - * + * * Called when a client changes dimensions on the server. - * + * * @param player */ public void onClientDimensionChanged(EntityHuman player) { - + } // Spare client junk @@ -401,7 +401,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod // boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID); // boolean onTickInGUI(float tick, Minecraft game, GuiScreen gui); // void keyboardEvent(KeyBinding event); - + @Override public void keyBindingEvent(Object keybinding) { // NOOP on server diff --git a/fml/bukkit/net/minecraft/server/BukkitRegistry.java b/fml/bukkit/net/minecraft/server/BukkitRegistry.java index 101ad9a558..3b2c0e3cdb 100644 --- a/fml/bukkit/net/minecraft/server/BukkitRegistry.java +++ b/fml/bukkit/net/minecraft/server/BukkitRegistry.java @@ -1,6 +1,5 @@ package net.minecraft.server; -import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -24,6 +23,13 @@ public class BukkitRegistry implements IMinecraftRegistry CraftingManager.getInstance().registerShapelessRecipe((ItemStack) output, params); } + @SuppressWarnings("unchecked") + @Override + public void addRecipe(net.minecraft.src.IRecipe recipe) + { + CraftingManager.getInstance().getRecipies().add(recipe); + } + @Override public void addSmelting(int input, net.minecraft.src.ItemStack output) { @@ -52,19 +58,22 @@ public class BukkitRegistry implements IMinecraftRegistry } } - @Override + @SuppressWarnings("unchecked") + @Override public void registerEntityID(Class entityClass, String entityName, int id) { EntityTypes.addNewEntityListMapping((Class) entityClass, entityName, id); } - @Override + @SuppressWarnings("unchecked") + @Override public void registerEntityID(Class entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour) { EntityTypes.addNewEntityListMapping((Class) entityClass, entityName, id, backgroundEggColour, foregroundEggColour); } - @Override + @SuppressWarnings("unchecked") + @Override public void registerTileEntity(Class tileEntityClass, String id) { TileEntity.addNewTileEntityMapping((Class) tileEntityClass, id); @@ -84,7 +93,7 @@ public class BukkitRegistry implements IMinecraftRegistry { @SuppressWarnings("unchecked") List spawns = ((BiomeBase)biome).getMobs((EnumCreatureType)typeOfCreature); - + for (BiomeMeta entry : spawns) { //Adjusting an existing spawn entry @@ -96,7 +105,7 @@ public class BukkitRegistry implements IMinecraftRegistry break; } } - + spawns.add(new BiomeMeta(entityClass, weightedProb, min, max)); } } @@ -106,7 +115,7 @@ public class BukkitRegistry implements IMinecraftRegistry public void addSpawn(String entityName, int weightedProb, int min, int max, net.minecraft.src.EnumCreatureType spawnList, BiomeGenBase... biomes) { Class entityClazz = EntityTypes.getEntityToClassMapping().get(entityName); - + if (EntityLiving.class.isAssignableFrom(entityClazz)) { addSpawn((Class ) entityClazz, weightedProb, min, max, spawnList, biomes); @@ -127,7 +136,7 @@ public class BukkitRegistry implements IMinecraftRegistry { @SuppressWarnings("unchecked") List spawns = ((BiomeBase)biome).getMobs((EnumCreatureType) typeOfCreature); - + Iterator entries = spawns.iterator(); while (entries.hasNext()) { @@ -145,7 +154,7 @@ public class BukkitRegistry implements IMinecraftRegistry public void removeSpawn(String entityName, net.minecraft.src.EnumCreatureType spawnList, BiomeGenBase... biomes) { Class entityClazz = EntityTypes.getEntityToClassMapping().get(entityName); - + if (EntityLiving.class.isAssignableFrom(entityClazz)) { removeSpawn((Class ) entityClazz, spawnList, biomes); diff --git a/fml/bukkit/net/minecraft/src/IRecipe.java b/fml/bukkit/net/minecraft/src/IRecipe.java new file mode 100644 index 0000000000..eaa3caedc8 --- /dev/null +++ b/fml/bukkit/net/minecraft/src/IRecipe.java @@ -0,0 +1,5 @@ +package net.minecraft.src; + +public interface IRecipe { + +}