Social Icons

Wednesday 14 August 2013

[TUT] Chest Steal/Store Buttons [TUT]

So I am making this tutorials for BEGGINERS AT MINECRAFT MODDING, don't be a smart ass and get all pissy at me for making simple tutorials like these. So any way, as I was saying, this tutorials will be about the steal/store buttons found in many clients, I coded this one my self (But I took the button cords from someone else :3 (don't worry not a skid)) so here it is:

So first you need to make the buttons them selves inside the chests gui, so can you guess which class we are editing? XD so, go into GuiChest.java and go to the very bottom, the first thing you have to do is make the buttons so here is the code:
Code:
public void initGui()
    {
    super.initGui();
    int posY = (height - ySize)/2 + 2;
    this.buttonList.add(new GuiButton(1, width /2-5, posY,40, 14, "Steal"));
    this.buttonList.add(new GuiButton(2, width /2+40, posY,40, 14, "Store"));
    }
This has made the buttons inside the chest, but they don't do anything yet, so we have to make them do something, so right under that method we are going to put an actionperformed method like this:
Code:
protected void actionPerformed(GuiButton par1)
    {
        if(par1.id == 1)
        {
            try{
                for(int x = 0; x < lowerChestInventory.getSizeInventory(); x++)
                    mc.playerController.windowClick(inventorySlots.windowId, x, 0, 1, mc.thePlayer);
            }catch(Exception e){e.printStackTrace();}
        }
This is the steal button, it basicly says if you press this button it tells the chest to give you what ever is in its slots so for the store button you have to make another if statement and type this code in:
Code:
if(par1.id == 2)
        {
            try{
                for(int x = 0; x < inventorySlots.inventorySlots.size(); x++)
                    mc.playerController.windowClick(inventorySlots.windowId, x, 0, 1, mc.thePlayer);
            }catch(Exception e){e.printStackTrace();}
        }
}
that is it, I hope it works for you! Enjoy your hack :)!

No comments:

Post a Comment