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

If I have, for example, a Minecraft:cake item with an nbt on it, and I'd like to be able to place the cake block in the world, and have that nbt available when interacting with the block or to put back on the item if the block is broken and retrieved, can it be done? If I understand correctly, I can only put nbts on a block entity, but is there some way I can sneakily get similar functionality on a block? Maybe storing its information into metadata on the chunk when its placed or something like that?

On 6/2/2023 at 8:34 PM, TaeoG said:

Maybe storing its information into metadata on the chunk when its placed or something like that?

Yup, exactly like that. You can add a capability to the level or levelchunk which you store nbt data on add and write to item stack on break.

  • Author
14 hours ago, ChampionAsh5357 said:

Yup, exactly like that. You can add a capability to the level or levelchunk which you store nbt data on add and write to item stack on break.

what are the pitfalls? I'm worried there is infinite edge cases from block placer/breaker machines from various mods like create that would make this approach untenable

if you keep things simple, there likely won't be issues.

i wouldn't attach this to a chunk because it doesn't logically belong to a chunk. for example a flag saying whether players have visited a chunk, whether your retrogen is finished on a chunk, whether your special slimes should spawn in a chunk? that i would store with a chunk. in short, things i would access in "entity enters section" event. your list of special block positions belongs to the world - either use world saved data (use this for simple and private data) or world capabilities (more convoluted but nice inter-mod interaction).

you keep the data in memory (for example a list of locations (BlockPos) or some map), you tell the game how to write it into a given nbt and that's that. when you change the data, you mark is as dirty but the game won't write it to hard drive then. only later (usually when you hit esc to get the menu), will the data be written to storage.

again, you just maintain you list/map and not worry about storage.

 

  • Author
On 6/6/2023 at 4:13 AM, MFMods said:

if you keep things simple, there likely won't be issues.

i wouldn't attach this to a chunk because it doesn't logically belong to a chunk. for example a flag saying whether players have visited a chunk, whether your retrogen is finished on a chunk, whether your special slimes should spawn in a chunk? that i would store with a chunk. in short, things i would access in "entity enters section" event. your list of special block positions belongs to the world - either use world saved data (use this for simple and private data) or world capabilities (more convoluted but nice inter-mod interaction).

you keep the data in memory (for example a list of locations (BlockPos) or some map), you tell the game how to write it into a given nbt and that's that. when you change the data, you mark is as dirty but the game won't write it to hard drive then. only later (usually when you hit esc to get the menu), will the data be written to storage.

again, you just maintain you list/map and not worry about storage.

 

The proof of concept works! Thank you both for the advice. My only complaint is that since the data is server side, If I want to cancel a RightClickBlock event based on the stored data, its only blocked serverside and the right click appears to work for just a moment before it syncs up again. Is there some way I can make it work properly on both sides?

  • Author

I guess the more straightforward question is, is there a way to sync the SavedData from the server to the client?

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.