Class NbtHelper

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

public final class NbtHelper extends Object
Helper methods for handling NBT.
Mappings:
Namespace Name
named net/minecraft/nbt/NbtHelper
intermediary net/minecraft/class_2512
official uq
  • Field Details

    • BLOCK_POS_COMPARATOR

      private static final Comparator<NbtList> BLOCK_POS_COMPARATOR
      Mappings:
      Namespace Name Mixin selector
      named BLOCK_POS_COMPARATOR Lnet/minecraft/nbt/NbtHelper;BLOCK_POS_COMPARATOR:Ljava/util/Comparator;
      intermediary field_27816 Lnet/minecraft/class_2512;field_27816:Ljava/util/Comparator;
      official b Luq;b:Ljava/util/Comparator;
    • ENTITY_POS_COMPARATOR

      private static final Comparator<NbtList> ENTITY_POS_COMPARATOR
      Mappings:
      Namespace Name Mixin selector
      named ENTITY_POS_COMPARATOR Lnet/minecraft/nbt/NbtHelper;ENTITY_POS_COMPARATOR:Ljava/util/Comparator;
      intermediary field_27817 Lnet/minecraft/class_2512;field_27817:Ljava/util/Comparator;
      official c Luq;c:Ljava/util/Comparator;
    • DATA_KEY

      public static final String DATA_KEY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named DATA_KEY Lnet/minecraft/nbt/NbtHelper;DATA_KEY:Ljava/lang/String;
      intermediary field_33224 Lnet/minecraft/class_2512;field_33224:Ljava/lang/String;
      official a Luq;a:Ljava/lang/String;
    • LEFT_CURLY_BRACKET

      private static final char LEFT_CURLY_BRACKET
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named LEFT_CURLY_BRACKET Lnet/minecraft/nbt/NbtHelper;LEFT_CURLY_BRACKET:C
      intermediary field_33225 Lnet/minecraft/class_2512;field_33225:C
      official d Luq;d:C
    • RIGHT_CURLY_BRACKET

      private static final char RIGHT_CURLY_BRACKET
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named RIGHT_CURLY_BRACKET Lnet/minecraft/nbt/NbtHelper;RIGHT_CURLY_BRACKET:C
      intermediary field_33226 Lnet/minecraft/class_2512;field_33226:C
      official e Luq;e:C
    • COMMA

      private static final String COMMA
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named COMMA Lnet/minecraft/nbt/NbtHelper;COMMA:Ljava/lang/String;
      intermediary field_33227 Lnet/minecraft/class_2512;field_33227:Ljava/lang/String;
      official f Luq;f:Ljava/lang/String;
    • COLON

      private static final char COLON
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named COLON Lnet/minecraft/nbt/NbtHelper;COLON:C
      intermediary field_33228 Lnet/minecraft/class_2512;field_33228:C
      official g Luq;g:C
    • COMMA_SPLITTER

      private static final Splitter COMMA_SPLITTER
      Mappings:
      Namespace Name Mixin selector
      named COMMA_SPLITTER Lnet/minecraft/nbt/NbtHelper;COMMA_SPLITTER:Lcom/google/common/base/Splitter;
      intermediary field_27818 Lnet/minecraft/class_2512;field_27818:Lcom/google/common/base/Splitter;
      official h Luq;h:Lcom/google/common/base/Splitter;
    • COLON_SPLITTER

      private static final Splitter COLON_SPLITTER
      Mappings:
      Namespace Name Mixin selector
      named COLON_SPLITTER Lnet/minecraft/nbt/NbtHelper;COLON_SPLITTER:Lcom/google/common/base/Splitter;
      intermediary field_27819 Lnet/minecraft/class_2512;field_27819:Lcom/google/common/base/Splitter;
      official i Luq;i:Lcom/google/common/base/Splitter;
    • LOGGER

      private static final Logger LOGGER
      Mappings:
      Namespace Name Mixin selector
      named LOGGER Lnet/minecraft/nbt/NbtHelper;LOGGER:Lorg/slf4j/Logger;
      intermediary field_11582 Lnet/minecraft/class_2512;field_11582:Lorg/slf4j/Logger;
      official j Luq;j:Lorg/slf4j/Logger;
    • field_33229

      private static final int field_33229
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named field_33229 Lnet/minecraft/nbt/NbtHelper;field_33229:I
      intermediary field_33229 Lnet/minecraft/class_2512;field_33229:I
      official k Luq;k:I
    • field_33230

      private static final int field_33230
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named field_33230 Lnet/minecraft/nbt/NbtHelper;field_33230:I
      intermediary field_33230 Lnet/minecraft/class_2512;field_33230:I
      official l Luq;l:I
  • Constructor Details

    • NbtHelper

      private NbtHelper()
  • Method Details

    • matches

      public static boolean matches(@Nullable @Nullable NbtElement standard, @Nullable @Nullable NbtElement subject, boolean ignoreListOrder)
      Returns whether standard is a subset of subject.

      Elements are matched based on the following order:

      1. Passing the same reference to both parameters will return true.
      2. If standard is null, return true.
      3. If subject is null, return false.
      4. If the types of standard and subject are different, return false.
      5. If standard is NbtCompound, return true if all keys in the standard exist in subject and the values match (comparing recursively.)
      6. If standard is NbtList and ignoreListOrder is true, return true if both lists are empty, or if there exists a "matching" value in subject for all values of standard (that is, if standard is a subset of subject, ignoring duplicates.), otherwise false. This means that the comparison ignores the ordering of the lists.
      7. Otherwise, return standard.equals(subject).
      Parameters:
      standard - the standard (also called as "template" or "schema") element
      subject - the element to test
      ignoreListOrder - whether to ignore ordering for NbtList
      Returns:
      whether standard is a subset of subject
      Mappings:
      Namespace Name Mixin selector
      named matches Lnet/minecraft/nbt/NbtHelper;matches(Lnet/minecraft/nbt/NbtElement;Lnet/minecraft/nbt/NbtElement;Z)Z
      intermediary method_10687 Lnet/minecraft/class_2512;method_10687(Lnet/minecraft/class_2520;Lnet/minecraft/class_2520;Z)Z
      official a Luq;a(Luy;Luy;Z)Z
    • fromUuid

      public static NbtIntArray fromUuid(UUID uuid)
      Serializes a UUID into its equivalent NBT representation.
      Since:
      20w10a
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named fromUuid Lnet/minecraft/nbt/NbtHelper;fromUuid(Ljava/util/UUID;)Lnet/minecraft/nbt/NbtIntArray;
      intermediary method_25929 Lnet/minecraft/class_2512;method_25929(Ljava/util/UUID;)Lnet/minecraft/class_2495;
      official a Luq;a(Ljava/util/UUID;)Luf;
    • toUuid

      public static UUID toUuid(NbtElement element)
      Deserializes an NBT element into a UUID. The NBT element's data must have the same structure as the output of fromUuid(java.util.UUID).
      Throws:
      IllegalArgumentException - if element is not a valid representation of a UUID
      Since:
      20w10a
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named toUuid Lnet/minecraft/nbt/NbtHelper;toUuid(Lnet/minecraft/nbt/NbtElement;)Ljava/util/UUID;
      intermediary method_25930 Lnet/minecraft/class_2512;method_25930(Lnet/minecraft/class_2520;)Ljava/util/UUID;
      official a Luq;a(Luy;)Ljava/util/UUID;
    • toBlockPos

      public static Optional<BlockPos> toBlockPos(NbtCompound nbt, String key)
      Returns the block position from the nbt.
      Returns:
      the block position from the nbt
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named toBlockPos Lnet/minecraft/nbt/NbtHelper;toBlockPos(Lnet/minecraft/nbt/NbtCompound;Ljava/lang/String;)Ljava/util/Optional;
      intermediary method_10691 Lnet/minecraft/class_2512;method_10691(Lnet/minecraft/class_2487;Ljava/lang/String;)Ljava/util/Optional;
      official a Luq;a(Lub;Ljava/lang/String;)Ljava/util/Optional;
    • fromBlockPos

      public static NbtElement fromBlockPos(BlockPos pos)
      Returns the serialized block position.
      Returns:
      the serialized block position
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named fromBlockPos Lnet/minecraft/nbt/NbtHelper;fromBlockPos(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10692 Lnet/minecraft/class_2512;method_10692(Lnet/minecraft/class_2338;)Lnet/minecraft/class_2520;
      official a Luq;a(Ljd;)Luy;
    • toBlockState

      public static BlockState toBlockState(RegistryEntryLookup<Block> blockLookup, NbtCompound nbt)
      Returns the block state from the nbt.

      This returns the default state for Blocks.AIR if the block name is not present.

      Returns:
      the block state from the nbt
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named toBlockState Lnet/minecraft/nbt/NbtHelper;toBlockState(Lnet/minecraft/registry/RegistryEntryLookup;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/block/BlockState;
      intermediary method_10681 Lnet/minecraft/class_2512;method_10681(Lnet/minecraft/class_7871;Lnet/minecraft/class_2487;)Lnet/minecraft/class_2680;
      official a Luq;a(Ljn;Lub;)Ldtc;
    • withProperty

      private static <S extends State<?, S>, T extends Comparable<T>> S withProperty(S state, Property<T> property, String key, NbtCompound properties, NbtCompound root)
      Mappings:
      Namespace Name Mixin selector
      named withProperty Lnet/minecraft/nbt/NbtHelper;withProperty(Lnet/minecraft/state/State;Lnet/minecraft/state/property/Property;Ljava/lang/String;Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/state/State;
      intermediary method_10682 Lnet/minecraft/class_2512;method_10682(Lnet/minecraft/class_2688;Lnet/minecraft/class_2769;Ljava/lang/String;Lnet/minecraft/class_2487;Lnet/minecraft/class_2487;)Lnet/minecraft/class_2688;
      official a Luq;a(Ldte;Lduf;Ljava/lang/String;Lub;Lub;)Ldte;
    • fromBlockState

      public static NbtCompound fromBlockState(BlockState state)
      Returns the serialized block state.
      Returns:
      the serialized block state
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named fromBlockState Lnet/minecraft/nbt/NbtHelper;fromBlockState(Lnet/minecraft/block/BlockState;)Lnet/minecraft/nbt/NbtCompound;
      intermediary method_10686 Lnet/minecraft/class_2512;method_10686(Lnet/minecraft/class_2680;)Lnet/minecraft/class_2487;
      official a Luq;a(Ldtc;)Lub;
    • fromFluidState

      public static NbtCompound fromFluidState(FluidState state)
      Returns the serialized fluid state.
      Returns:
      the serialized fluid state
      Mappings:
      Namespace Name Mixin selector
      named fromFluidState Lnet/minecraft/nbt/NbtHelper;fromFluidState(Lnet/minecraft/fluid/FluidState;)Lnet/minecraft/nbt/NbtCompound;
      intermediary method_36115 Lnet/minecraft/class_2512;method_36115(Lnet/minecraft/class_3610;)Lnet/minecraft/class_2487;
      official a Luq;a(Lepe;)Lub;
    • nameValue

      private static <T extends Comparable<T>> String nameValue(Property<T> property, Comparable<?> value)
      Mappings:
      Namespace Name Mixin selector
      named nameValue Lnet/minecraft/nbt/NbtHelper;nameValue(Lnet/minecraft/state/property/Property;Ljava/lang/Comparable;)Ljava/lang/String;
      intermediary method_10685 Lnet/minecraft/class_2512;method_10685(Lnet/minecraft/class_2769;Ljava/lang/Comparable;)Ljava/lang/String;
      official a Luq;a(Lduf;Ljava/lang/Comparable;)Ljava/lang/String;
    • toFormattedString

      public static String toFormattedString(NbtElement nbt)
      Returns the human-readable, non-deserializable representation of nbt.

      This does not include contents of NbtByteArray, NbtIntArray, and NbtLongArray. To include them, call toFormattedString(NbtElement, boolean) with withArrayContents parameter set to true.

      Returns:
      the human-readable, non-deserializable representation of nbt
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named toFormattedString Lnet/minecraft/nbt/NbtHelper;toFormattedString(Lnet/minecraft/nbt/NbtElement;)Ljava/lang/String;
      intermediary method_36118 Lnet/minecraft/class_2512;method_36118(Lnet/minecraft/class_2520;)Ljava/lang/String;
      official b Luq;b(Luy;)Ljava/lang/String;
    • toFormattedString

      public static String toFormattedString(NbtElement nbt, boolean withArrayContents)
      Returns the human-readable, non-deserializable representation of nbt.
      Parameters:
      withArrayContents - whether to include contents of NbtByteArray, NbtIntArray, and NbtLongArray
      Returns:
      the human-readable, non-deserializable representation of nbt
      Mappings:
      Namespace Name Mixin selector
      named toFormattedString Lnet/minecraft/nbt/NbtHelper;toFormattedString(Lnet/minecraft/nbt/NbtElement;Z)Ljava/lang/String;
      intermediary method_36117 Lnet/minecraft/class_2512;method_36117(Lnet/minecraft/class_2520;Z)Ljava/lang/String;
      official a Luq;a(Luy;Z)Ljava/lang/String;
    • appendFormattedString

      public static StringBuilder appendFormattedString(StringBuilder stringBuilder, NbtElement nbt, int depth, boolean withArrayContents)
      Mappings:
      Namespace Name Mixin selector
      named appendFormattedString Lnet/minecraft/nbt/NbtHelper;appendFormattedString(Ljava/lang/StringBuilder;Lnet/minecraft/nbt/NbtElement;IZ)Ljava/lang/StringBuilder;
      intermediary method_36116 Lnet/minecraft/class_2512;method_36116(Ljava/lang/StringBuilder;Lnet/minecraft/class_2520;IZ)Ljava/lang/StringBuilder;
      official a Luq;a(Ljava/lang/StringBuilder;Luy;IZ)Ljava/lang/StringBuilder;
    • appendIndent

      private static StringBuilder appendIndent(int depth, StringBuilder stringBuilder)
      Mappings:
      Namespace Name Mixin selector
      named appendIndent Lnet/minecraft/nbt/NbtHelper;appendIndent(ILjava/lang/StringBuilder;)Ljava/lang/StringBuilder;
      intermediary method_36114 Lnet/minecraft/class_2512;method_36114(ILjava/lang/StringBuilder;)Ljava/lang/StringBuilder;
      official a Luq;a(ILjava/lang/StringBuilder;)Ljava/lang/StringBuilder;
    • toPrettyPrintedText

      public static Text toPrettyPrintedText(NbtElement element)
      Returns the pretty-printed text representation of element.
      Returns:
      the pretty-printed text representation of element
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named toPrettyPrintedText Lnet/minecraft/nbt/NbtHelper;toPrettyPrintedText(Lnet/minecraft/nbt/NbtElement;)Lnet/minecraft/text/Text;
      intermediary method_32270 Lnet/minecraft/class_2512;method_32270(Lnet/minecraft/class_2520;)Lnet/minecraft/class_2561;
      official c Luq;c(Luy;)Lwz;
    • toNbtProviderString

      public static String toNbtProviderString(NbtCompound compound)
      Returns the string representation of compound as used by the NBT provider in the data generator.

      The passed compound will be sorted and modified in-place to make it more human-readable e.g. by converting NbtCompound in the palettes NbtList to its short string representation. Therefore the returned value is not an accurate representation of the original NBT.

      Returns:
      the string representation of compound as used by the NBT provider in the data generator
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named toNbtProviderString Lnet/minecraft/nbt/NbtHelper;toNbtProviderString(Lnet/minecraft/nbt/NbtCompound;)Ljava/lang/String;
      intermediary method_32271 Lnet/minecraft/class_2512;method_32271(Lnet/minecraft/class_2487;)Ljava/lang/String;
      official a Luq;a(Lub;)Ljava/lang/String;
    • fromNbtProviderString

      public static NbtCompound fromNbtProviderString(String string) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Returns the string parsed as an NBT provider-formatted NBT compound.

      This method first parses the string as an NBT, then performs several conversions from human-readable NbtCompound items to the actual values used in-game.

      Returns:
      the string parsed as an NBT provider-formatted NBT compound
      Throws:
      com.mojang.brigadier.exceptions.CommandSyntaxException
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named fromNbtProviderString Lnet/minecraft/nbt/NbtHelper;fromNbtProviderString(Ljava/lang/String;)Lnet/minecraft/nbt/NbtCompound;
      intermediary method_32260 Lnet/minecraft/class_2512;method_32260(Ljava/lang/String;)Lnet/minecraft/class_2487;
      official a Luq;a(Ljava/lang/String;)Lub;
    • toNbtProviderFormat

      static NbtCompound toNbtProviderFormat(NbtCompound compound)
      Mappings:
      Namespace Name Mixin selector
      named toNbtProviderFormat Lnet/minecraft/nbt/NbtHelper;toNbtProviderFormat(Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/nbt/NbtCompound;
      intermediary method_32273 Lnet/minecraft/class_2512;method_32273(Lnet/minecraft/class_2487;)Lnet/minecraft/class_2487;
      official b Luq;b(Lub;)Lub;
    • fromNbtProviderFormat

      static NbtCompound fromNbtProviderFormat(NbtCompound compound)
      Mappings:
      Namespace Name Mixin selector
      named fromNbtProviderFormat Lnet/minecraft/nbt/NbtHelper;fromNbtProviderFormat(Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/nbt/NbtCompound;
      intermediary method_32275 Lnet/minecraft/class_2512;method_32275(Lnet/minecraft/class_2487;)Lnet/minecraft/class_2487;
      official c Luq;c(Lub;)Lub;
    • toNbtProviderFormattedPalette

      static String toNbtProviderFormattedPalette(NbtCompound compound)
      Mappings:
      Namespace Name Mixin selector
      named toNbtProviderFormattedPalette Lnet/minecraft/nbt/NbtHelper;toNbtProviderFormattedPalette(Lnet/minecraft/nbt/NbtCompound;)Ljava/lang/String;
      intermediary method_32277 Lnet/minecraft/class_2512;method_32277(Lnet/minecraft/class_2487;)Ljava/lang/String;
      official d Luq;d(Lub;)Ljava/lang/String;
    • fromNbtProviderFormattedPalette

      static NbtCompound fromNbtProviderFormattedPalette(String string)
      Mappings:
      Namespace Name Mixin selector
      named fromNbtProviderFormattedPalette Lnet/minecraft/nbt/NbtHelper;fromNbtProviderFormattedPalette(Ljava/lang/String;)Lnet/minecraft/nbt/NbtCompound;
      intermediary method_32267 Lnet/minecraft/class_2512;method_32267(Ljava/lang/String;)Lnet/minecraft/class_2487;
      official b Luq;b(Ljava/lang/String;)Lub;
    • putDataVersion

      public static NbtCompound putDataVersion(NbtCompound nbt)
      Mappings:
      Namespace Name Mixin selector
      named putDataVersion Lnet/minecraft/nbt/NbtHelper;putDataVersion(Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/nbt/NbtCompound;
      intermediary method_48310 Lnet/minecraft/class_2512;method_48310(Lnet/minecraft/class_2487;)Lnet/minecraft/class_2487;
      official e Luq;e(Lub;)Lub;
    • putDataVersion

      public static NbtCompound putDataVersion(NbtCompound nbt, int dataVersion)
      Mappings:
      Namespace Name Mixin selector
      named putDataVersion Lnet/minecraft/nbt/NbtHelper;putDataVersion(Lnet/minecraft/nbt/NbtCompound;I)Lnet/minecraft/nbt/NbtCompound;
      intermediary method_48308 Lnet/minecraft/class_2512;method_48308(Lnet/minecraft/class_2487;I)Lnet/minecraft/class_2487;
      official a Luq;a(Lub;I)Lub;
    • getDataVersion

      public static int getDataVersion(NbtCompound nbt, int fallback)
      Mappings:
      Namespace Name Mixin selector
      named getDataVersion Lnet/minecraft/nbt/NbtHelper;getDataVersion(Lnet/minecraft/nbt/NbtCompound;I)I
      intermediary method_48309 Lnet/minecraft/class_2512;method_48309(Lnet/minecraft/class_2487;I)I
      official b Luq;b(Lub;I)I