Posted November 23, 201212 yr 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
November 23, 201212 yr 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.
November 23, 201212 yr 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.
November 23, 201212 yr 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.
November 23, 201212 yr 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.
November 24, 201212 yr 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.