Posted September 17, 201510 yr I'm trying to set the state of a GuiButton (and save it to NBT later), but when it triggers the '<TileEntity>.buttonClicked()'-function, the variable on the TileEntity itself is not saved (I assume it saves it in the 'copied'(?) TileEntity, not the actual one).. Here's my code so far: In GuiAlertBlock.java: public void actionPerformed(GuiButton button){ ((TileEntityAlertBlock)world.getTileEntity(this.x, this.y, this.z)).buttonClicked(); List<Entity> players = world.playerEntities; for(Entity e: players){ EntityPlayer player = (EntityPlayer)e; player.addChatMessage(new ChatComponentText(player.getDisplayName())); } } In TileEntityAlertBlock: public void buttonClicked(){ if(this.buttonState == this.BUTTON_OFF) this.buttonState = this.BUTTON_ON; else if(this.buttonState == this.BUTTON_ON) this.buttonState = this.BUTTON_OFF; System.out.println(); }
September 17, 201510 yr Guis are ClientOnly. To set values in a tileentty(Both sides)from a Gui, youll need to use packethandling to send the value to the server. Diesieben07 has a nice Tutorial on that. Also for spoilers do [ spoiler ] [/ spoiler ] without the spaces
September 17, 201510 yr Guis are ClientOnly. To set values in a tileentty(Both sides)from a Gui, youll need to use packethandling to send the value to the server. Diesieben07 has a nice Tutorial on that. Also for spoilers do [ spoiler ] [/ spoiler ] without the spaces Actually, I did do something with this block and packethandling before, but at that time, it wasn't necessary. (I tried it many different ways, the only thing which I didn't do was to go back using packethandlers.. ) Edit: so yeah, it does work now; thanks
September 17, 201510 yr Well, the variable updating part works, but now it looks like it doesn't send that to the client because I either draw a red button when the value is 0, or a green one when it's 1, but in the gui the button is not updated at all. That's the line of code for drawing the button: this.drawTexturedModalRect(this.xPosition, this.yPosition, 176 + ((TileEntityAlertBlock)world.getTileEntity(this.TEx, this.TEy, this.TEz)).buttonState * 20, k * 20, this.width, this.height);
September 17, 201510 yr they need to sync the data back from the server to the client again. Look for the methods getdescription packet and on description packet. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
September 18, 201510 yr I think these are the methods I searched for, I'll try them in the afternoon. Thank you
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.