Jump to content

Recommended Posts

Posted

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 :D

 

The real diamond spade and iron hammer

H6MXZ.png

 

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.

VNFeL.png

 

The repairing still happens and the diamond spade is repaired but creates a duplicate spade which when clicked/shift clicked disappears as well.

vY56b.png

 

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);

    }

}

 

 

Posted

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.

Posted

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?

Posted

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.

Posted

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
Posted

Never noticed I had furnace code xD, 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;

            }

        }

    }

 

 

Posted

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.

Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi there! I'm looking for a mod that will randomly determine if someone will keep their items on death or lose them all. Does anyone know of a mod like this?
    • Recently I feel like the time taken for a response in the Modder Support forum is slower than what it was when I first joined the forum (9 months ago), which feels odd due to the amount of views many posts get (my most recent one is currently sitting at 19.6k views with no replies; though I understand that not everyone viewing may have an account or be able to help). I would usually get replies only a few days after originally posting, but with my most recent post I have been waiting for two weeks. I even saw a post a few days ago where someone got a reply six months after they posted.    In my case, I am quite an inexperienced modder that is relying on tutorials to learn my modding. With my inexperience there are some issues, like two that I am having now where things are going wrong with my code yet my code matches perfectly with the tutorial, that I am simply clueless on and am put in quite a roadblock. The help here on the forums is excellent and I usually don't mind waiting a few days, but I would also really like to progress with my mod and release it to the public. I am not trying to complain with this post, I am just wanting to mention something bothering me to see if anyone else is the same.
    • Hi I'm currently making an addon mods to add compatibility between tacz and the Vault Hunters Modpack. I added a new item that is a extend of the kineticgun class from tacz and implements the vaultgear classes from Vault Hunters. The texture and other functionnality of the guns in tacz comes from the gunId nbt so once i add the nbt my new item works perfectly. My problem is when in debug the texture from tacz works and i can see the gun in every place but once i export the mod i can only see the gun in my hand in first person, in third person and the inventory i get the error texture. If you can help please leave a message. Thank you   ps1: src https://github.com/Pixyde/tacz_x_vault_hunters ps2: this is my first mod
    • Yea, I disabled the mod and still crashed in the same spot
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.