#need some help porting a script from 1.20.1 to 1.21.1
19 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Paste version of salt_water_breathing.js from @cyan meteor
I think NBT compound tags can't be accessed like a JS object now
Here's the documentation for NBT compound tags (Persistent data is a common example, so docs are temporarily here)
sorry was busy and only just saw this now
Hey! I know this is a month-late but Im having a very similar issue regarding NBT access on 1.21.1
If you can't access entity NBT like you could in versions prior, how can you? serializeNBT no longer works how it did before
You can't access it like a JS object, however you can still access it via methods on CompoundTag
I understand that, I'm moreso asking how you get nbt data from an entity in the first place so that you can run said methods on that object
So, instead of:
nbt.answerToLife = 42;
const answerToLife = nbt.answerToLife
use:
nbt.putInt("answerToLife", 42);
const answerToLife = nbt.getInt("answerToLife")
entity.getNbt()
serializeNBT is deprecated btw
You can also set NBT:
entity.setNbt()
And both are combined into a single bean:
entity.nbt
Also:
Please avoid re-opening/necroing old solved tickets.
If you're experiencing a similar issue, open a new ticket instead. You can link or reference the old thread if it's relevant. This helps keep support organized and ensures your specific problem gets proper attention.
👍🏾 👍🏾
(although this one wasn't technically "solved")