Package net.minecraft.nbt
Class NbtHelper
java.lang.Object
net.minecraft.nbt.NbtHelper
public final class NbtHelper extends Object
-
Field Summary
-
Constructor Summary
Constructors Constructor Description NbtHelper()
-
Method Summary
Modifier and Type Method Description static CompoundTag
fromBlockPos(BlockPos pos)
static CompoundTag
fromBlockState(BlockState state)
static CompoundTag
fromGameProfile(CompoundTag tag, com.mojang.authlib.GameProfile profile)
static IntArrayTag
fromUuid(UUID uuid)
Serializes aUUID
into its equivalent NBT representation.static boolean
matches(Tag standard, Tag subject, boolean equalValue)
private static <T extends Comparable<T>>
StringnameValue(Property<T> property, Comparable<?> value)
static BlockPos
toBlockPos(CompoundTag tag)
static BlockState
toBlockState(CompoundTag tag)
static com.mojang.authlib.GameProfile
toGameProfile(CompoundTag tag)
static UUID
toUuid(Tag tag)
Deserializes a tag into aUUID
.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.static CompoundTag
update(com.mojang.datafixers.DataFixer fixer, DataFixTypes fixTypes, CompoundTag tag, int oldVersion, int targetVersion)
Uses the data fixer to update a tag.private static <S extends State<?, S>, T extends Comparable<T>>
SwithProperty(S state, Property<T> property, String key, CompoundTag propertiesTag, CompoundTag mainTag)
-
Field Details
-
LOGGER
-
-
Constructor Details
-
NbtHelper
public NbtHelper()
-
-
Method Details
-
toGameProfile
-
fromGameProfile
-
matches
-
fromUuid
Serializes aUUID
into its equivalent NBT representation.- Since:
- 20w10a
-
toUuid
Deserializes a tag into aUUID
. The tag's data must have the same structure as the output offromUuid(java.util.UUID)
.- Throws:
IllegalArgumentException
- iftag
is not a valid representation of a UUID- Since:
- 20w10a
-
toBlockPos
-
fromBlockPos
-
toBlockState
-
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
-
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 fixerfixTypes
- the fix typestag
- the tag to fixoldVersion
- 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 fixerfixTypes
- the fix typestag
- the tag to fixoldVersion
- the data version of the compound tagtargetVersion
- the data version to update the tag to
-