User Tools

Site Tools


tutorial:blockentity_modify_data

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tutorial:blockentity_modify_data [2025/04/01 12:46] – [Modify BlockEntity data] solidblocktutorial:blockentity_modify_data [2025/04/01 12:48] (current) – [Some notes about NbtCompound] solidblock
Line 31: Line 31:
 // returns an empty compound when the field does not exist: // returns an empty compound when the field does not exist:
 NbtCompound config = nbt.getCompound("config"); NbtCompound config = nbt.getCompound("config");
 +</code>
  
 Besides, since 1.21.5, the whole NBT compound and its fields can be decoded directly with [[codec]]s, such as: Besides, since 1.21.5, the whole NBT compound and its fields can be decoded directly with [[codec]]s, such as:
Line 45: Line 46:
 Optional<ItemStack> stack = nbt.decode(ItemStack.MAP_CODEC, wrapperLookup.getOps(NbtOps.INSTANCE)); Optional<ItemStack> stack = nbt.decode(ItemStack.MAP_CODEC, wrapperLookup.getOps(NbtOps.INSTANCE));
 </code> </code>
 +
 +Besides, since 1.21.5, lists support mixing elements of different types. In previous versions, mixing elements of different types in a list results in exceptions.
  
 More information about NBT changes, see [[https://fabricmc.net/2025/03/24/1215.html|Fabric for Minecraft 1.21.5]]. More information about NBT changes, see [[https://fabricmc.net/2025/03/24/1215.html|Fabric for Minecraft 1.21.5]].
tutorial/blockentity_modify_data.txt · Last modified: 2025/04/01 12:48 by solidblock