#need some help porting a script from 1.20.1 to 1.21.1

19 messages · Page 1 of 1 (latest)

cyan meteor
#

hi, sorry if this is a bit dumb but i need help porting this to 1.21.1 for a modpack, what it does is check and entities nbt tags and applies a specific effect to them if they fall within the list written inside. thanks in advance

cobalt roseBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

smoky ospreyBOT
#

Paste version of salt_water_breathing.js from @cyan meteor

tame raven
#

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)

cyan meteor
#

sorry was busy and only just saw this now

wet veldt
tame raven
#

You can't access it like a JS object, however you can still access it via methods on CompoundTag

wet veldt
#

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

tame raven
#

So, instead of:

nbt.answerToLife = 42;
const answerToLife = nbt.answerToLife

use:

nbt.putInt("answerToLife", 42);
const answerToLife = nbt.getInt("answerToLife")
tame raven
#

serializeNBT is deprecated btw

tame raven
#

And both are combined into a single bean:
entity.nbt

#

Also:

smoky ospreyBOT
#

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.

wet veldt
#

👍🏾 👍🏾

tame raven
#

(although this one wasn't technically "solved")