Jump to content

[SOLVED] How do I modify BlockEntity data from the Screen?


Tenth

Recommended Posts

I'm making a tech mod which will have several machines with a circuit slot (like GregTech) which is controlled by an int called circuitNumber which is apart of a ContainerData variable in the BlockEntity. This int will control the amount of an ItemStack in a slot of my custom circuit item.

I tried modifying the data through the passed-in blockEntity in the menu class. (The #setCircuit and #getCircuit functions just used ContainerData#set and ContainerData#get using the passed-in ContainerData in the menu class) No dice, the data never gets changed.

I then tried to make a packed called CircuitSyncC2SPacket which would tell the server to modify the data using a function in the BlockEntity class. Zilch, no effect whatsoever.

I couldn't find anything when searching for this online, and the one I did was from 2013 that said to use Packets. If this is the solution, then I must be doing something wrong. Any help would be appreciated, thank you. The project's GitHub.

Edited by Tenth
Solved
Link to comment
Share on other sites

12 hours ago, Tenth said:

I tried modifying the data through the passed-in blockEntity in the menu class. (The #setCircuit and #getCircuit functions just used ContainerData#set and ContainerData#get using the passed-in ContainerData in the menu class) No dice, the data never gets changed.

If you mean the screen, then yes, you would need a packet to send that information to the server which then gets updated on the client.

12 hours ago, Tenth said:

I then tried to make a packed called CircuitSyncC2SPacket which would tell the server to modify the data using a function in the BlockEntity class. Zilch, no effect whatsoever.

Ah yes, you send a packet to the server, so the first thing you do is set data on the client. Since you are on the server, you can get the server level instance by grabbing it from the sender in the context event.

  • Thanks 1
Link to comment
Share on other sites

  • Tenth changed the title to [SOLVED] How do I modify BlockEntity data from the Screen?

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.