Jump to content

Recommended Posts

Posted

Hello guys, recently I was trying to create a GUI that has 3 different containers. The GuiContainer class wound have 3 different tileentities, which are get from the surroundings, and their respective containers.

 

So, I would like to change the containers using buttons. The reason I don't want to create multiple tileentities is that some items have to be in another tileentity. I tried something like to change the pages/containers (without success, if I save the currentGuiID/page for the next openGUI. I also noticed that the itens are only client side [not sure if that is right, propably not]):

 

 

 

switch (guiID)

{

case 0:

this.inventorySlots = this.containerTile1;

this.disableButtonsTile2();

this.disableButtonsTile3();

break;

case 1:

if (this.hasValidItem && this.tile2 != null && this.containerTile2 != null)

{

this.inventorySlots = this.containerTile2;

        this.disableButtonsTile1();

        this.disableButtonsTile3();

}

break;

case 2:

if (this.hasValidItem && this.tile3 != null && this.containerTile3 != null)

{

this.inventorySlots = this.containerCultivator;

        this.disableButtonsTile1();

        this.disableButtonsTile2();

}

break;

default:

this.inventorySlots = this.containerTile1;

this.disableButtonsTile2();

this.disableButtonsTile3();

}

this.setCurrentGUI(guiID);

this.mc.thePlayer.openContainer = this.inventorySlots;

 

 

 

Basically, I would like to do something similar to the creativeTabs, where the player can dynamically change the pages and containers easily.

 

 

Posted

Right, I got the idea. I just have a question: how would I change the position of the slots? Changing a field in the container class, maybe?

Posted

Hi

 

This project has an example of a container with two inventories; it's for 1.8 but the comments should help you out a lot because they haven't really changed from 1.7

 

https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe30_inventory_basic

 

and a bit of extra info here

http://greyminecraftcoder.blogspot.com.au/2015/01/gui-containers.html

 

-TGG

 

---------

MBE30_INVENTORY_BASIC

Code by Brandon3055

 

This example shows how to make an inventory block similar to a chest, with less storage space (a Footlocker)

 

The example will show you

1) how to create a simple Block with a linked TileEntity that will store items permanently

2) how to set up a Container, linked GuiContainer, and IGuiHandler to add/remove items from the TileEntity.

-------------

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



×
×
  • Create New...

Important Information

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