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

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

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.

  • Author
6 hours ago, ChampionAsh5357 said:

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.

I'm embarrassed it was something so obvious, thanks for the help.

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

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.