diff --git a/IronChests2/client/cpw/mods/ironchest/client/ClientProxy.java b/IronChests2/client/cpw/mods/ironchest/client/ClientProxy.java index ee289b0..205156c 100644 --- a/IronChests2/client/cpw/mods/ironchest/client/ClientProxy.java +++ b/IronChests2/client/cpw/mods/ironchest/client/ClientProxy.java @@ -4,81 +4,47 @@ * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html - * + * * Contributors: * cpw - initial API and implementation ******************************************************************************/ package cpw.mods.ironchest.client; -import java.io.File; - -import net.minecraft.client.Minecraft; import net.minecraft.src.ChestItemRenderHelper; -import net.minecraft.src.EntityItem; import net.minecraft.src.EntityPlayer; import net.minecraft.src.ModLoader; -import net.minecraft.src.NBTTagCompound; import net.minecraft.src.TileEntity; import net.minecraft.src.World; -import net.minecraft.src.forge.MinecraftForgeClient; -import cpw.mods.ironchest.ChestChangerType; -import cpw.mods.ironchest.IProxy; +import net.minecraftforge.client.MinecraftForgeClient; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.ironchest.ContainerIronChestBase; +import cpw.mods.ironchest.CommonProxy; import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.TileEntityIronChest; -public class ClientProxy implements IProxy { - @Override - public void registerRenderInformation() { - ChestItemRenderHelper.instance = new IronChestRenderHelper(); - MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/block_textures.png"); - MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/item_textures.png"); - } +public class ClientProxy extends CommonProxy { + @Override + public void registerRenderInformation() { + ChestItemRenderHelper.instance = new IronChestRenderHelper(); + MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/block_textures.png"); + MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/item_textures.png"); + } - @Override - public void registerTileEntities() { - for (IronChestType typ : IronChestType.values()) { - ModLoader.registerTileEntity(typ.clazz, typ.name(), new TileEntityIronChestRenderer()); - } - } + @Override + public boolean isRemote() { + return ModLoader.getMinecraftInstance().theWorld.isRemote; + } - @Override - public void registerTranslations() { - for (IronChestType typ : IronChestType.values()) { - ModLoader.addLocalization(typ.name() + ".name", typ.friendlyName); - } - for (ChestChangerType typ : ChestChangerType.values()) { - ModLoader.addLocalization("item." + typ.itemName + ".name", typ.descriptiveName); - } - } + @Override + public void registerTileEntitySpecialRenderer(IronChestType typ) { + ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer()); + } - @Override - public File getMinecraftDir() { - return Minecraft.getMinecraftDir(); - } - - @Override - public void applyExtraDataToDrops(EntityItem entityitem, NBTTagCompound data) { - entityitem.item.setTagCompound(data); - - } - - @Override - public boolean isRemote() { - return ModLoader.getMinecraftInstance().theWorld.isRemote; - } - - @Override - public World getCurrentWorld() { - return ModLoader.getMinecraftInstance().theWorld; - } - - @Override - public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - TileEntity te = world.getBlockTileEntity(x, y, z); - if (te != null && te instanceof TileEntityIronChest) { - return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te); - } else { - return null; - } - } + @Override + public World getClientWorld() { + return FMLClientHandler.instance().getClient().theWorld; + } } diff --git a/IronChests2/client/cpw/mods/ironchest/client/IronChestRenderHelper.java b/IronChests2/client/cpw/mods/ironchest/client/IronChestRenderHelper.java index 1fbcfb6..fcadba1 100644 --- a/IronChests2/client/cpw/mods/ironchest/client/IronChestRenderHelper.java +++ b/IronChests2/client/cpw/mods/ironchest/client/IronChestRenderHelper.java @@ -4,13 +4,13 @@ * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html - * + * * Contributors: * cpw - initial API and implementation ******************************************************************************/ package cpw.mods.ironchest.client; -import cpw.mods.ironchest.mod_IronChest; +import cpw.mods.ironchest.IronChest; import net.minecraft.src.Block; import net.minecraft.src.ChestItemRenderHelper; import net.minecraft.src.TileEntityRenderer; @@ -18,8 +18,8 @@ import net.minecraft.src.TileEntityRenderer; public class IronChestRenderHelper extends ChestItemRenderHelper { @Override public void renderChest(Block block, int i, float f) { - if (block==mod_IronChest.ironChestBlock) { - TileEntityRenderer.instance.renderTileEntityAt(block.getTileEntity(i), 0.0D, 0.0D, 0.0D, 0.0F); + if (block==IronChest.ironChestBlock) { + TileEntityRenderer.instance.renderTileEntityAt(block.createTileEntity(null,i), 0.0D, 0.0D, 0.0D, 0.0F); } else { super.renderChest(block, i, f); } diff --git a/IronChests2/client/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java b/IronChests2/client/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java index 7164ab6..fcec8e9 100644 --- a/IronChests2/client/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java +++ b/IronChests2/client/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java @@ -37,13 +37,13 @@ import net.minecraft.src.RenderBlocks; import net.minecraft.src.Tessellator; import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntitySpecialRenderer; -import net.minecraft.src.forge.ForgeHooksClient; -import net.minecraft.src.forge.IItemRenderer; -import net.minecraft.src.forge.MinecraftForgeClient; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.MappableItemStackWrapper; import cpw.mods.ironchest.TileEntityIronChest; -import cpw.mods.ironchest.mod_IronChest; +import cpw.mods.ironchest.IronChest; public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { private static Map renderList = new HashMap(); @@ -76,10 +76,10 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { } int facing = 3; IronChestType type = tile.getType(); - if (tile != null && tile.worldObj != null) { + if (tile != null && tile.func_70314_l() != null) { facing = tile.getFacing(); type = tile.getType(); - int typ = tile.worldObj.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); + int typ = tile.func_70314_l().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); type = IronChestType.values()[typ]; } bindTextureByName(type.getModelTexture()); @@ -154,7 +154,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { glPushMatrix(); glTranslatef(shiftX, shiftY, shiftZ); glScalef(localScale, localScale, localScale); - for (int miniBlocks = 0; miniBlocks < (item.stackSize / 32) + 1; miniBlocks++) { +/* for (int miniBlocks = 0; miniBlocks < (item.stackSize / 32) + 1; miniBlocks++) { glPushMatrix(); glRotatef(timeD, 0.0F, 1.0F, 0.0F); if (miniBlocks > 0) { @@ -164,8 +164,8 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { glTranslatef(minishiftX, minishiftY, minishiftZ); } MappableItemStackWrapper mis = new MappableItemStackWrapper(item); - if (!mod_IronChest.CACHE_RENDER || !renderList.containsKey(mis)) { // Added support for using only old system. - if (mod_IronChest.CACHE_RENDER) { + if (!IronChest.CACHE_RENDER || !renderList.containsKey(mis)) { // Added support for using only old system. + if (IronChest.CACHE_RENDER) { int render = glGenLists(1); renderList.put(mis, render); glNewList(render, GL_COMPILE_AND_EXECUTE); @@ -213,7 +213,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10); tessellator.draw(); } - if (mod_IronChest.CACHE_RENDER) { + if (IronChest.CACHE_RENDER) { glEndList(); } } else { @@ -224,7 +224,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { } glPopMatrix(); } - glPopMatrix(); +*/ glPopMatrix(); } glDisable(32826 /* GL_RESCALE_NORMAL_EXT */); glEnable(2896 /* GL_LIGHTING */); diff --git a/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java b/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java index 9ecdcc8..049e1ec 100644 --- a/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java +++ b/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java @@ -25,9 +25,9 @@ import net.minecraft.src.MathHelper; import net.minecraft.src.NBTTagCompound; import net.minecraft.src.TileEntity; import net.minecraft.src.World; -import net.minecraft.src.forge.ITextureProvider; +import net.minecraftforge.common.Orientation; -public class BlockIronChest extends BlockContainer implements ITextureProvider { +public class BlockIronChest extends BlockContainer { private Random random; @@ -44,7 +44,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider { } @Override - public TileEntity getBlockEntity() { + public TileEntity createNewTileEntity(World w) { return null; } @@ -69,7 +69,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider { } @Override - public TileEntity getBlockEntity(int metadata) { + public TileEntity createNewTileEntity(World world, int metadata) { return IronChestType.makeEntity(metadata); } @@ -105,7 +105,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider { } @Override - public boolean blockActivated(World world, int i, int j, int k, EntityPlayer player) { + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3) { TileEntity te = world.getBlockTileEntity(i, j, k); if (te == null || !(te instanceof TileEntityIronChest)) @@ -113,7 +113,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider { return true; } - if (world.isBlockSolidOnSide(i, j + 1, k, 0)) + if (world.isBlockSolidOnSide(i, j + 1, k, Orientation.DOWN)) { return true; } @@ -122,7 +122,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider { return true; } - player.openGui(mod_IronChest.instance, ((TileEntityIronChest) te).getType().ordinal(), world, i, j, k); + player.openGui(IronChest.instance, ((TileEntityIronChest) te).getType().ordinal(), world, i, j, k); return true; } @@ -160,14 +160,15 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider { return i; } - public void onBlockRemoval(World world, int i, int j, int k) + @Override + public void breakBlock(World world, int i, int j, int k, int i1, int i2) { TileEntityIronChest tileentitychest = (TileEntityIronChest) world.getBlockTileEntity(i, j, k); if (tileentitychest != null) { dropContent(0, tileentitychest, world, tileentitychest.xCoord, tileentitychest.yCoord, tileentitychest.zCoord); } - super.onBlockRemoval(world, i, j, k); + super.breakBlock(world, i, j, k, i1, i2); } public void dropContent(int newSize, IInventory chest, World world, int xCoord, int yCoord, int zCoord) { @@ -197,7 +198,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider { entityitem.motionZ = (float) random.nextGaussian() * f3; if (itemstack.hasTagCompound()) { - mod_IronChest.proxy.applyExtraDataToDrops(entityitem, (NBTTagCompound) itemstack.getTagCompound().copy()); + entityitem.item.setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); } world.spawnEntityInWorld(entityitem); } diff --git a/IronChests2/common/cpw/mods/ironchest/ChestChangerType.java b/IronChests2/common/cpw/mods/ironchest/ChestChangerType.java index a92c5f8..62e7fe8 100644 --- a/IronChests2/common/cpw/mods/ironchest/ChestChangerType.java +++ b/IronChests2/common/cpw/mods/ironchest/ChestChangerType.java @@ -16,7 +16,7 @@ import static cpw.mods.ironchest.IronChestType.WOOD; import net.minecraft.src.Block; import net.minecraft.src.ItemStack; -import net.minecraft.src.forge.Configuration; +import net.minecraftforge.common.Configuration; public enum ChestChangerType { IRONGOLD(IRON, GOLD, "ironGoldUpgrade", "Iron to Gold Chest Upgrade", "mmm", "msm", "mmm"), diff --git a/IronChests2/common/cpw/mods/ironchest/CommonProxy.java b/IronChests2/common/cpw/mods/ironchest/CommonProxy.java new file mode 100644 index 0000000..b53c52c --- /dev/null +++ b/IronChests2/common/cpw/mods/ironchest/CommonProxy.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2012 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * cpw - initial API and implementation + ******************************************************************************/ +package cpw.mods.ironchest; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.TileEntity; +import net.minecraft.src.World; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.ironchest.client.GUIChest; + + +public class CommonProxy implements IGuiHandler { + public void registerRenderInformation() + { + + } + + public boolean isRemote() + { + return true; + } + + public void registerTileEntitySpecialRenderer(IronChestType typ) + { + + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + TileEntity te = world.getBlockTileEntity(x, y, z); + if (te != null && te instanceof TileEntityIronChest) { + return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te); + } else { + return null; + } + } + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z) { + TileEntity te = world.getBlockTileEntity(X, Y, Z); + if (te != null && te instanceof TileEntityIronChest) { + TileEntityIronChest icte = (TileEntityIronChest) te; + return new ContainerIronChestBase(player.inventory, icte, icte.getType(), 0, 0); + } else { + return null; + } + } + + public World getClientWorld() { + return null; + } + +} diff --git a/IronChests2/common/cpw/mods/ironchest/ContainerIronChestBase.java b/IronChests2/common/cpw/mods/ironchest/ContainerIronChestBase.java index 3e4d623..0f17f21 100644 --- a/IronChests2/common/cpw/mods/ironchest/ContainerIronChestBase.java +++ b/IronChests2/common/cpw/mods/ironchest/ContainerIronChestBase.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html - * + * * Contributors: * cpw - initial API and implementation ******************************************************************************/ @@ -75,7 +75,7 @@ public class ContainerIronChestBase extends Container { { for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++) { - addSlot(new Slot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18)); + addSlotToContainer(new Slot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18)); } } @@ -85,21 +85,17 @@ public class ContainerIronChestBase extends Container { { for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++) { - addSlot(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10)); + addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10)); } } for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++) { - addSlot(new Slot(playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, ySize - 24)); + addSlotToContainer(new Slot(playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, ySize - 24)); } } public EntityPlayer getPlayer() { return player; } - - public IInventory getInventory() { - return chest; - } } diff --git a/IronChests2/common/cpw/mods/ironchest/IProxy.java b/IronChests2/common/cpw/mods/ironchest/IProxy.java deleted file mode 100644 index 04555cc..0000000 --- a/IronChests2/common/cpw/mods/ironchest/IProxy.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 cpw. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * cpw - initial API and implementation - ******************************************************************************/ -package cpw.mods.ironchest; - -import java.io.File; - -import net.minecraft.src.EntityItem; -import net.minecraft.src.NBTTagCompound; -import net.minecraft.src.World; -import net.minecraft.src.forge.IGuiHandler; - -public interface IProxy extends IGuiHandler { - - public abstract void registerRenderInformation(); - - public abstract void registerTileEntities(); - - public abstract void registerTranslations(); - - public abstract File getMinecraftDir(); - - public abstract void applyExtraDataToDrops(EntityItem item, NBTTagCompound data); - - public abstract boolean isRemote(); - - public abstract World getCurrentWorld(); -} diff --git a/IronChests2/common/cpw/mods/ironchest/IronChest.java b/IronChests2/common/cpw/mods/ironchest/IronChest.java new file mode 100644 index 0000000..4c8fb48 --- /dev/null +++ b/IronChests2/common/cpw/mods/ironchest/IronChest.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2012 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * cpw - initial API and implementation + ******************************************************************************/ +package cpw.mods.ironchest; + +import java.lang.reflect.Method; +import java.util.logging.Level; + +import net.minecraftforge.common.Configuration; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.Init; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.Mod.PostInit; +import cpw.mods.fml.common.Mod.PreInit; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; + +@Mod(modid = "IronChest", name = "Iron Chests", version = "4.0") +@NetworkMod(channels = { "IronChest" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) +public class IronChest { + + public static BlockIronChest ironChestBlock; + @SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.common.CommonProxy") + public static CommonProxy proxy; + @Instance + public static IronChest instance; + public static boolean CACHE_RENDER = true; + public static boolean OCELOTS_SITONCHESTS = true; + + @PreInit + public void preInit(FMLPreInitializationEvent event) { + Configuration cfg = new Configuration(event.getSuggestedConfigurationFile()); + event.getModMetadata().version = Version.fullVersionString(); + try { + cfg.load(); + int bId = cfg.getOrCreateBlockIdProperty("ironChests", 181).getInt(181); + ironChestBlock = new BlockIronChest(bId); + ChestChangerType.buildItems(cfg, 29501); + CACHE_RENDER = cfg.getOrCreateBooleanProperty("cacheRenderingInformation", Configuration.CATEGORY_GENERAL, true).getBoolean(true); + OCELOTS_SITONCHESTS = cfg.getOrCreateBooleanProperty("ocelotsSitOnChests", Configuration.CATEGORY_GENERAL, true).getBoolean(true); + } catch (Exception e) { + FMLLog.log(Level.SEVERE, e, "IronChest has a problem loading it's configuration"); + } finally { + cfg.save(); + } + } + + @Init + public void load(FMLInitializationEvent evt) { + GameRegistry.registerBlock(ironChestBlock); + for (IronChestType typ : IronChestType.values()) { + GameRegistry.registerTileEntity(typ.clazz, typ.name()); + LanguageRegistry.instance().addStringLocalization(typ.name() + ".name", "en_US", typ.friendlyName); + proxy.registerTileEntitySpecialRenderer(typ); + } + for (ChestChangerType typ : ChestChangerType.values()) { + LanguageRegistry.instance().addStringLocalization("item." + typ.itemName + ".name", "en_US", typ.descriptiveName); + } + IronChestType.generateTieredRecipes(ironChestBlock); + ChestChangerType.generateRecipes(); + NetworkRegistry.instance().registerGuiHandler(instance, proxy); + proxy.registerRenderInformation(); + } + + @PostInit + public void modsLoaded(FMLPostInitializationEvent evt) { + try { + Class equivexmaps = Class.forName("ee.EEMaps"); + Method addEMC = equivexmaps.getMethod("addEMC", int.class, int.class, int.class); + Method addMeta = equivexmaps.getMethod("addMeta", int.class, int.class); + int[] chestEMCValues = new int[] { 8 * 8 + 256 * 8, /* iron chest */ + 8 * 8 + 256 * 8 + 2048 * 8, /* gold chest */ + 2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6, /* diamond chest */ + 85 * 8 + 8 * 8, /* copper chest */ + 85 * 8 + 8 * 8 + 512 * 8, /* silver chest */ + 2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6 + 8 /* crystal chest */ + }; + for (IronChestType icType : IronChestType.values()) { + if (icType.ordinal() >= chestEMCValues.length) + break; + addEMC.invoke(null, ironChestBlock.blockID, icType.ordinal(), chestEMCValues[icType.ordinal()]); + } + addMeta.invoke(null, ironChestBlock.blockID, IronChestType.values().length - 1); + FMLLog.fine("mod_IronChest registered chests with Equivalent Exchange"); + } catch (Exception ex) { + FMLLog.fine("mod_IronChest unable to load Equivalent Exchange integration"); + } + } +} diff --git a/IronChests2/common/cpw/mods/ironchest/IronChestAIOcelotSit.java b/IronChests2/common/cpw/mods/ironchest/IronChestAIOcelotSit.java index 167f894..4104b36 100644 --- a/IronChests2/common/cpw/mods/ironchest/IronChestAIOcelotSit.java +++ b/IronChests2/common/cpw/mods/ironchest/IronChestAIOcelotSit.java @@ -126,7 +126,7 @@ public class IronChestAIOcelotSit extends EntityAIBase { } private boolean isBlockAChestBlock(World world, int x, int y, int z) { - if (world.getBlockId(x, y, z)==mod_IronChest.ironChestBlock.blockID) { + if (world.getBlockId(x, y, z)==IronChest.ironChestBlock.blockID) { return true; } try { diff --git a/IronChests2/common/cpw/mods/ironchest/IronChestType.java b/IronChests2/common/cpw/mods/ironchest/IronChestType.java index 347b73e..8a2ca52 100644 --- a/IronChests2/common/cpw/mods/ironchest/IronChestType.java +++ b/IronChests2/common/cpw/mods/ironchest/IronChestType.java @@ -18,7 +18,7 @@ import net.minecraft.src.Block; import net.minecraft.src.CraftingManager; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; -import net.minecraft.src.forge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapedOreRecipe; public enum IronChestType { IRON(54, 9, true, "Iron Chest", "ironchest.png", 0, Arrays.asList("ingotIron","ingotRefinedIron"), TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"), diff --git a/IronChests2/common/cpw/mods/ironchest/ItemChestChanger.java b/IronChests2/common/cpw/mods/ironchest/ItemChestChanger.java index 9cce995..7f386fc 100644 --- a/IronChests2/common/cpw/mods/ironchest/ItemChestChanger.java +++ b/IronChests2/common/cpw/mods/ironchest/ItemChestChanger.java @@ -10,16 +10,15 @@ ******************************************************************************/ package cpw.mods.ironchest; -import cpw.mods.fml.common.ReflectionHelper; +import cpw.mods.fml.common.ObfuscationReflectionHelper; import net.minecraft.src.EntityPlayer; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntityChest; import net.minecraft.src.World; -import net.minecraft.src.forge.ITextureProvider; -public class ItemChestChanger extends Item implements ITextureProvider { +public class ItemChestChanger extends Item { private ChestChangerType type; @@ -52,9 +51,9 @@ public class ItemChestChanger extends Item implements ITextureProvider { // Force old TE out of the world so that adjacent chests can update newchest = IronChestType.makeEntity(getTargetChestOrdinal(IronChestType.WOOD.ordinal())); int newSize = newchest.chestContents.length; - ItemStack[] chestContents = ReflectionHelper.getPrivateValue(TileEntityChest.class, tec, 0); + ItemStack[] chestContents = ObfuscationReflectionHelper.getPrivateValue(TileEntityChest.class, tec, 0); System.arraycopy(chestContents, 0, newchest.chestContents, 0, Math.min(newSize, chestContents.length)); - BlockIronChest block = mod_IronChest.ironChestBlock; + BlockIronChest block = IronChest.ironChestBlock; block.dropContent(newSize, tec, world, tec.xCoord, tec.yCoord, tec.zCoord); newchest.setFacing((byte)tec.getBlockMetadata()); newchest.sortTopStacks(); diff --git a/IronChests2/common/cpw/mods/ironchest/ItemIronChest.java b/IronChests2/common/cpw/mods/ironchest/ItemIronChest.java index e8aad0d..53812a2 100644 --- a/IronChests2/common/cpw/mods/ironchest/ItemIronChest.java +++ b/IronChests2/common/cpw/mods/ironchest/ItemIronChest.java @@ -31,8 +31,4 @@ public class ItemIronChest extends ItemBlock { public String getItemNameIS(ItemStack itemstack) { return IronChestType.values()[itemstack.getItemDamage()].name(); } - - @Override - public void addCreativeItems(@SuppressWarnings("rawtypes") ArrayList itemList) { - } } diff --git a/IronChests2/common/cpw/mods/ironchest/PacketHandler.java b/IronChests2/common/cpw/mods/ironchest/PacketHandler.java index 1042d7d..29639e3 100644 --- a/IronChests2/common/cpw/mods/ironchest/PacketHandler.java +++ b/IronChests2/common/cpw/mods/ironchest/PacketHandler.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html - * + * * Contributors: * cpw - initial API and implementation ******************************************************************************/ @@ -16,91 +16,71 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteStreams; + +import cpw.mods.fml.common.network.IPacketHandler; +import cpw.mods.fml.common.network.Player; + import net.minecraft.src.NetworkManager; import net.minecraft.src.Packet; import net.minecraft.src.Packet1Login; import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.TileEntity; import net.minecraft.src.World; -import net.minecraft.src.forge.IConnectionHandler; -import net.minecraft.src.forge.IPacketHandler; -import net.minecraft.src.forge.MessageManager; -public class PacketHandler implements IPacketHandler, IConnectionHandler { +public class PacketHandler implements IPacketHandler { @Override - public void onConnect(NetworkManager network) { - MessageManager.getInstance().registerChannel(network, this, "IronChest"); - } - - @Override - public void onLogin(NetworkManager network, Packet1Login login) { - } - - @Override - public void onDisconnect(NetworkManager network, String message, Object[] args) { - MessageManager.getInstance().removeConnection(network); - } - - @Override - public void onPacketData(NetworkManager network, String channel, byte[] data) { - DataInputStream dis=new DataInputStream(new ByteArrayInputStream(data)); - int x; - int y; - int z; - int typ; - boolean hasStacks; - int[] items=null; - try { - x = dis.readInt(); - y = dis.readInt(); - z = dis.readInt(); - typ=dis.readByte(); - hasStacks=dis.readByte()!=0; - if (hasStacks) { - items = new int[24]; - for (int i=0; i equivexmaps = Class.forName("ee.EEMaps"); - Method addEMC = equivexmaps.getMethod("addEMC", int.class, int.class, int.class); - Method addMeta = equivexmaps.getMethod("addMeta", int.class, int.class); - int[] chestEMCValues = new int[] - { - 8 * 8 + 256 * 8, /* iron chest */ - 8 * 8 + 256 * 8 + 2048 * 8, /* gold chest */ - 2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6, /* diamond chest */ - 85 * 8 + 8 * 8, /* copper chest */ - 85 * 8 + 8 * 8 + 512 * 8, /* silver chest */ - 2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6 + 8 /* crystal chest */ - }; - for (IronChestType icType : IronChestType.values()) { - if (icType.ordinal()>=chestEMCValues.length) - break; - addEMC.invoke(null, ironChestBlock.blockID, icType.ordinal(), chestEMCValues[icType.ordinal()]); - } - addMeta.invoke(null, ironChestBlock.blockID, IronChestType.values().length - 1); - ModLoader.getLogger().fine("mod_IronChest registered chests with Equivalent Exchange"); - } catch (Exception ex) { - ModLoader.getLogger().fine("mod_IronChest unable to load Equivalent Exchange integration"); - } - } - - @Override - public boolean clientSideRequired() { - return true; - } - - @Override - public boolean serverSideRequired() { - return false; - } -} diff --git a/IronChests2/server/cpw/mods/ironchest/server/ServerProxy.java b/IronChests2/server/cpw/mods/ironchest/server/ServerProxy.java index e25380e..9958121 100644 --- a/IronChests2/server/cpw/mods/ironchest/server/ServerProxy.java +++ b/IronChests2/server/cpw/mods/ironchest/server/ServerProxy.java @@ -4,7 +4,7 @@ * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html - * + * * Contributors: * cpw - initial API and implementation ******************************************************************************/ @@ -57,17 +57,6 @@ public class ServerProxy implements IProxy { return false; } - @Override - public Object getGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z) { - TileEntity te=world.getBlockTileEntity(X, Y, Z); - if (te!=null && te instanceof TileEntityIronChest) { - TileEntityIronChest icte=(TileEntityIronChest) te; - return new ContainerIronChestBase(player.inventory, icte, icte.getType(), 0, 0); - } else { - return null; - } - } - @Override public World getCurrentWorld() { // NOOP on server: there's lots