Class NbtHelper

java.lang.Object
net.minecraft.nbt.NbtHelper

public final class NbtHelper
extends Object
  • Field Details

    • LOGGER

      private static final Logger LOGGER
  • Constructor Details

    • NbtHelper

      public NbtHelper()
  • Method Details

    • toGameProfile

      @Nullable public static com.mojang.authlib.GameProfile toGameProfile​(CompoundTag tag)
    • fromGameProfile

      public static CompoundTag fromGameProfile​(CompoundTag tag, com.mojang.authlib.GameProfile profile)
    • matches

      public static boolean matches​(@Nullable Tag standard, @Nullable Tag subject, boolean equalValue)
    • fromUuid

      public static IntArrayTag fromUuid​(UUID uuid)
      Serializes a UUID into its equivalent NBT representation.
      Since:
      20w10a
    • toUuid

      public static UUID toUuid​(Tag tag)
      Deserializes a tag into a UUID. The tag's data must have the same structure as the output of fromUuid(java.util.UUID).
      Throws:
      IllegalArgumentException - if tag is not a valid representation of a UUID
      Since:
      20w10a
    • toBlockPos

      public static BlockPos toBlockPos​(CompoundTag tag)
    • fromBlockPos

      public static CompoundTag fromBlockPos​(BlockPos pos)
    • toBlockState

      public static BlockState toBlockState​(CompoundTag tag)
    • withProperty

      private static <S extends State<?,​ S>,​ T extends Comparable<T>> S withProperty​(S state, Property<T> property, String key, CompoundTag propertiesTag, CompoundTag mainTag)
    • fromBlockState

      public static CompoundTag fromBlockState​(BlockState state)
    • nameValue

      private static <T extends Comparable<T>> String nameValue​(Property<T> property, Comparable<?> value)
    • update

      public static CompoundTag update​(com.mojang.datafixers.DataFixer fixer, DataFixTypes fixTypes, CompoundTag tag, int oldVersion)
      Uses the data fixer to update a tag to the latest data version.
      Parameters:
      fixer - the data fixer
      fixTypes - the fix types
      tag - the tag to fix
      oldVersion - the data version of the compound tag
    • update

      public static CompoundTag update​(com.mojang.datafixers.DataFixer fixer, DataFixTypes fixTypes, CompoundTag tag, int oldVersion, int targetVersion)
      Uses the data fixer to update a tag.
      Parameters:
      fixer - the data fixer
      fixTypes - the fix types
      tag - the tag to fix
      oldVersion - the data version of the compound tag
      targetVersion - the data version to update the tag to