I'm currently working on making a block(Transporter Console) that, when a button is pressed in its GUI, searches for another block(Transporter Interlock), within a hundred and 20 blocks with a certain tile entity string variable attached to it, called id. I haven't had problems getting variables from Tile Entities before, but I currently get a null when I try to get the id variable of a Transporter Interlock block. My source code can be viewed below:
I'm thinking the issue is that you're trying to set the id using the GUI, which is only client side. You need to set it on the server using a packet. This is because the server will sync down the id to the client, but the same won't happen the other way automatically.
By implementing packets, it now sets the id of the transporter interlock block, but still doesn't remember the id of the transporter interlock block after you quit the world and reopen it, even though I am using NBT.
Always call markDirty() in the TileEntity when you change a value you want to persist. That tells Minecraft which chunks need to be saved again and which ones can be skipped.
I recommend making a method in your TileEntity that sets the id and calls this.markDirty() at the same time.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Hello!
I'm currently working on making a block(Transporter Console) that, when a button is pressed in its GUI, searches for another block(Transporter Interlock), within a hundred and 20 blocks with a certain tile entity string variable attached to it, called id. I haven't had problems getting variables from Tile Entities before, but I currently get a null when I try to get the id variable of a Transporter Interlock block. My source code can be viewed below:
Thank You so much for the help!
-Zorse
Do you ever set the id to anything?
Yes- in line 131 of the GuiTransportInterlock class I set the id to be a string specified by the player.
I'm thinking the issue is that you're trying to set the id using the GUI, which is only client side. You need to set it on the server using a packet. This is because the server will sync down the id to the client, but the same won't happen the other way automatically.
By implementing packets, it now sets the id of the transporter interlock block, but still doesn't remember the id of the transporter interlock block after you quit the world and reopen it, even though I am using NBT.
Interlock Handler
GuiTransporterInterlock
TileEntityTransportInterlock
TeleporterHandler
Main class(StarTrek.java)
Always call markDirty() in the TileEntity when you change a value you want to persist. That tells Minecraft which chunks need to be saved again and which ones can be skipped.
I recommend making a method in your TileEntity that sets the id and calls this.markDirty() at the same time.
Unfortunately, this still doesn't work. Below is my updated Tile Entity Class.
http://pastebin.com/R8tUsDnC
I'm confused why this still doesn't work, as I haven't had any problems with saving NBT Data before...
I call the setId() Method I created in my InterlockHandler class:
Thank you for your help!
-Zorse