Topic category: User side tutorials
How to get NBT data:
For this example, we're going to get the NBT data of the target/event entity. With a custom code snippet, put this inside:CompoundTag nbtdata = entity.saveWithoutId(new CompoundTag());
(If getting data from target entity, source entity or immediate source entity, make sure it is shown under "required dependencies")
To get the value of "HurtTime", use getShort since its a short-type number
nbtdata.getShort("HurtTime")
How to set NBT data:
To set the value of something (such as HurtTime), use this:nbtdata.putShort("HurtTime", 0);
and then load the new nbtdata onto the entity:entity.load(nbtdata);
If you want to get a list of values (such as ForgeData) within the nbtdata, you can use the following:CompoundTag forgedata = nbtdata.get("ForgeData")
Okay so I currently don't actually know how to get a list of something within the nbt data, but i will try to figure it out.
hey this is cool but when reading it
is there anyway to save the data to an variable or an array or no?
Any updates on this? I need to figure out how to get the location data from a lodestone.
leo the xyz is part of the cords not the block
+
a lodestone isn't an entity last i check
I should have specified, a lodestone compass
yea leo you can use defult NBT stuff to grab it
+ an item in a inv isn't an entity.
also the NBT value name is "LodestonePos" it contain inside the X, Y and Z cords
what needs to be done to get the tag inside set compound tag(CurrentIdentity)? where exactly should I insert CompoundTag forgedata = nbtdata.get("ForgeData")?
I need to change the "friction_modifier" nbt. I don't know what exact type is it or how to write the exact code snippets. anyone to help?
What do I put as "entity"?
Unrelated but certified W profile picture
Is it possible to do this with Block Entities? I can't find an answer anywhere.