Jump to content

Recommended Posts

Posted

Hey all,

I am making a mod and would like to know how to read an int from a block's tile entity from it's Gui***** file. I have declared a variable in the tile entity which is a public static int. I need to know how to access this variable in my Gui***** file's drawGuiContainerBackgroundLayer method in order to render a graph representing this int. Any ideas on how to do this?

 

Thanks for reading this, hope you can help  :)

Posted

Wait, if it's "public static int" you can just do TileEntityMine.myinteger and get the value.

 

Also, when you create a Gui you always have an TileEntity instance stored and a Container, so you have everything you need.

Posted

Well, I tried using TileEntity*****.variable but this seems to gt the same value for every block which is placed with this GUI, meaning when a block is placed and there have been previous blocks placed also, it will start by rendering the same value as the other block. I want each block to have an individual variable for its GUI.

 

Edit: When I try to access my GUI***** file's tile_entity parameter, I get an error saying it does not exist.

Posted

You need to do all item handling in a GuiContainer, not a client side visual gui. It will be in three layers:

 

 

[Tile_Entity_Storage]

-----------|-------------

----------\/------------

[CommonSidedGuiContainer]

-----------|-------------

----------\/------------

[ClientSidedVisualGui]

The container will access the tile entity, and the client side visual gui only adds the textures and stuff.

Posted

Okay, so I have added a variable to my Container***** file which sets itself to the tile entity's variable, now how do I pass this variable along to my Gui***** file? I am confused as what to reference, for example should I put Container*****.variable or what? Please help, I know I'm so close to the solution.

Posted

Extend Tile Entity of course for your tile entity(mostly server side).

Extend Container for your server+Client inventory handling 'proxy'. This is where all your slots and ItemStack handling will go.

Extend GuiContainer for your ClientSide only UI for visualizing the Container.

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.