Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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.

  • Author

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.

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.

  • Author

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.