Posted September 9, 201213 yr Hi I don't normally ask for help but after updating CampCraft to 1.3 I've been hit by a few strange bugs which I think its caused by the new lan feature in minecraft. I made some pictures illustrating the bug as I'm dyslexic I'm not the best at explaining things The real diamond spade and iron hammer I place both diamond spade and iron hammer in the right slots but creates duplicate items and I'm still left with the real items in the purple boxes *when the duplicate items are clicked they disappear. The repairing still happens and the diamond spade is repaired but creates a duplicate spade which when clicked/shift clicked disappears as well. The main code *not all the code. left out the code for the anvil but can post more if needed CampCraft package CampCraft; @Mod( modid = "CampCraft", name="CampCraftMod", version="[1.3.2] CampCraft ModPack V 1.01") @NetworkMod( clientSideRequired = true, serverSideRequired = false, channels = {"CampCraftMod"}, packetHandler = PacketHandler.class //connectionHandler = yourConnectionHandler.class, // TODO //versionBounds = "[1.3]" ) public class CampCraft { @SidedProxy(clientSide = "CampCraft.ClientProxy", serverSide = "CampCraft.CommonProxy") public static CommonProxy proxy; @Instance public static CampCraft instance; @Init public void load(FMLInitializationEvent evt) { NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler()); proxy.initializeEntityRendering(); loadAnvil(); } public void loadAnvil() { //Anvil Anvil = (new BlockAnvil(500, 16, TileEntityAnvil.class)).setHardness(0.5F).setResistance(10F).setBlockName("Anvil"); AnvilItem = (new ItemAnvil(5000, Anvil)).setIconCoord(4, 1).setItemName("AnvilItem"); LanguageRegistry.addName(AnvilItem, "Anvil"); } ClientProxy package CampCraft; public class ClientProxy extends CommonProxy { public void initializeEntityRendering() { TileEntityAnvilRenderer anvilRenderer = new TileEntityAnvilRenderer(); ClientRegistry.registerTileEntity(TileEntityAnvil.class, "TileEntityAnvil", anvilRenderer); } @Override public World getClientWorld() { return Minecraft.getMinecraft().theWorld; } @Override public EntityPlayer getClientPlayer() { return Minecraft.getMinecraft().thePlayer; } } GuiHandler package CampCraft; public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (!world.blockExists(x, y, z)) { return null; } else { if(ID == 1) { TileEntityAnvil tileAnvil = (TileEntityAnvil)world.getBlockTileEntity(x, y, z); return new ContainerAnvil(player.inventory, tileAnvil); } else { return null; } } } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world,int x, int y, int z) { if (!world.blockExists(x, y, z)) { return null; } else { if(ID == 1) { TileEntityAnvil tileAnvil = (TileEntityAnvil)world.getBlockTileEntity(x, y, z); return new GuiAnvil(player.inventory, tileAnvil); } else { return null; } } } } Anvil Container package CampCraft.common.AnvilPart; public class ContainerAnvil extends Container { private TileEntityAnvil anvil; private int RepairTime = 0; private int HammerTime = 0; private int temp = 0; public ContainerAnvil(InventoryPlayer inventoryplayer, TileEntityAnvil tileentityanvil) { anvil = tileentityanvil; addSlotToContainer(new Slot(tileentityanvil, 0, 48, 17)); //Item to Repair addSlotToContainer(new Slot(tileentityanvil, 1, 74, 42)); //Hammer addSlotToContainer(new SlotAnvilOutput(inventoryplayer.player, tileentityanvil, 2, 137, 35));//Item Created addSlotToContainer(new Slot(tileentityanvil, 3, 22, 42)); //Material int var3; for (var3 = 0; var3 < 3; ++var3) { for (int var4 = 0; var4 < 9; ++var4) { this.addSlotToContainer(new Slot(inventoryplayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); } } for (var3 = 0; var3 < 9; ++var3) { this.addSlotToContainer(new Slot(inventoryplayer, var3, 8 + var3 * 18, 142)); } } public void addCraftingToCrafters(ICrafting par1ICrafting) { super.addCraftingToCrafters(par1ICrafting); par1ICrafting.updateCraftingInventoryInfo(this, 0, this.anvil.AnvilHammerTime); par1ICrafting.updateCraftingInventoryInfo(this, 1, this.anvil.AnvilRepairTime); par1ICrafting.updateCraftingInventoryInfo(this, 2, this.anvil.temp); } public void updateCraftingResults() { super.updateCraftingResults(); Iterator var1 = this.crafters.iterator(); while (var1.hasNext()) { ICrafting var2 = (ICrafting)var1.next(); if (RepairTime != anvil.AnvilRepairTime) { var2.updateCraftingInventoryInfo(this, 0, anvil.AnvilRepairTime); } if (HammerTime != anvil.AnvilHammerTime) { var2.updateCraftingInventoryInfo(this, 1, anvil.AnvilHammerTime); } if (temp != anvil.temp) { var2.updateCraftingInventoryInfo(this, 2, anvil.temp); } } } @SideOnly(Side.CLIENT) public void updateProgressBar(int i, int j) { if(i == 0) { anvil.AnvilRepairTime = j; } if(i == 1) { anvil.AnvilHammerTime = j; } if(i == 2) { anvil.temp = j; } } public boolean canInteractWith(EntityPlayer entityplayer) { return anvil.isUseableByPlayer(entityplayer); } public ItemStack transferStackInSlot(int par1) { ItemStack var2 = null; Slot var3 = (Slot)this.inventorySlots.get(par1); if (var3 != null && var3.getHasStack()) { ItemStack var4 = var3.getStack(); var2 = var4.copy(); if (par1 == 2) { if (!this.mergeItemStack(var4, 3, 39, true)) { return null; } var3.onSlotChange(var4, var2); } else if (par1 != 1 && par1 != 0) { if (FurnaceRecipes.smelting().getSmeltingResult(var4) != null) { if (!this.mergeItemStack(var4, 0, 1, false)) { return null; } } else if (TileEntityFurnace.isItemFuel(var4)) { if (!this.mergeItemStack(var4, 1, 2, false)) { return null; } } else if (par1 >= 3 && par1 < 30) { if (!this.mergeItemStack(var4, 30, 39, false)) { return null; } } else if (par1 >= 30 && par1 < 39 && !this.mergeItemStack(var4, 3, 30, false)) { return null; } } else if (!this.mergeItemStack(var4, 3, 39, false)) { return null; } if (var4.stackSize == 0) { var3.putStack((ItemStack)null); } else { var3.onSlotChanged(); } if (var4.stackSize == var2.stackSize) { return null; } var3.onPickupFromSlot(var4); } return var2; } } AnvilGui package CampCraft.src.AnvilPart; public class GuiAnvil extends GuiContainer { private TileEntityAnvil anvilInventory; public GuiAnvil(InventoryPlayer inventoryplayer, TileEntityAnvil tileentityanvil) { super(new ContainerAnvil(inventoryplayer, tileentityanvil)); anvilInventory = tileentityanvil; } protected void drawGuiContainerForegroundLayer() { fontRenderer.drawString("Anvil", 70, 6, 0x404040); fontRenderer.drawString("Item", 23, 28, 0x404040); fontRenderer.drawString("Material", 8, 61, 0x404040); fontRenderer.drawString("Hammer", 70, 61, 0x404040); fontRenderer.drawString("Inventory", 60, 71, 0x404040); } protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { int var4 = this.mc.renderEngine.getTexture("/Texture/GUIanvil.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(var4); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); int var7; if(this.anvilInventory.isBurning()) { var7 = this.anvilInventory.getBurnTimeRemainingScaled(12); this.drawTexturedModalRect(var5 + 41, var6 + 55 - var7, 176, 12 - var7, 22, var7 + 2); } var7 = this.anvilInventory.getCookProgressScaled(24); this.drawTexturedModalRect(var5 + 101, var6 + 35, 177, 23, var7, 15); } } http://i.imgur.com/9yLz9.gif[/img]
September 9, 201213 yr Somebody else had this... Can you explain what each picture means, as I don't really understand the bug. So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.
September 9, 201213 yr Author Ya sure First picture This picture is the diamond spade I'm repairing and the iron hammer I'm using to repair the spade. Second/Third picture These two pictures are me pretty much trying to repair the diamond spade. I place the diamond spade in the item slot, but when i place the item it places a duplicate diamond spade, same with the iron hammer when placed in the hammer slot places a duplicate hammer which when i click both the duplicate items they just disappear. Does that make more sense at all? http://i.imgur.com/9yLz9.gif[/img]
September 9, 201213 yr I had this bug updating my mod. Use EntityPlayer.openGui to open your gui's if you haven't already. You must also use IGUIHandler. Minecraft needs to send packets. Also make sure your container is coded well.
September 9, 201213 yr I had this bug updating my mod. I haven't seen your Block class but use EntityPlayer.openGui to open your gui's if you haven't already. Mine would would just cause the items to disappear. Why do you have Furnace code? Though that isn't causing the Items to disappear, I suggest you remove it. From what happened to me, there should not be any problem with your Container, GUI or TileEntity, you just need the EntityPlayer.openGui
September 10, 201213 yr Author Never noticed I had furnace code , I thought that bit of code was the problem at first as mine was different to the furnace so borrowed the furnace code for shift clicking but forgot to change some names around. This is my onBlockActivated code in blockAnvil, I don't see this code being the problem as I've been using it since 1.1 part from a few edits. public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int var1, float var2, float var4, float var8) { if (world.isRemote) { return true; } else { TileEntityAnvil tileAnvil = (TileEntityAnvil)world.getBlockTileEntity(i, j, k); if (tileAnvil != null && !world.isRemote) { entityplayer.openGui(CampCraft.instance, 1, world, i, j, k); return true; } else { return true; } } } http://i.imgur.com/9yLz9.gif[/img]
September 11, 201213 yr I guess the only thing left for you to do is implement ISidedInventory on your tiles. It is one thing that I did but im not sure if that actually fixed it, cause I have no idea what that interface does except every tile implements it.
September 12, 201213 yr Author Didn't really make much different implementing ISidedInventory, Thank you anyway for all the help My best option will be to debug the code and hopefully find the solution that way http://i.imgur.com/9yLz9.gif[/img]
September 13, 201213 yr I guess the only thing left for you to do is implement ISidedInventory on your tiles. It is one thing that I did but im not sure if that actually fixed it, cause I have no idea what that interface does except every tile implements it. ISidedInventory is used so mods like Redpower, buildcraft, or my mod(Assembly line) know which slot to dump items in. Also at tomtomtom0909 you might just need to cause the TE inventory to update. Normally there is a method that the furnace uses to update all slots after doing a smelt. This way you don't get ghost items client side, also posting you TE code could help. http://i577.photobucket.com/albums/ss215/bobstrong/ModBannerMed.png[/img]
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.