public final class NbtHelper extends Object
Constructor and Description |
---|
NbtHelper() |
Modifier and Type | Method and 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 a
UUID into its equivalent NBT representation. |
static boolean |
matches(Tag standard,
Tag subject,
boolean equalValue) |
private static <T extends Comparable<T>> |
nameValue(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 a
UUID . |
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>> |
withProperty(S state,
Property<T> property,
String key,
CompoundTag propertiesTag,
CompoundTag mainTag) |
private static final Logger LOGGER
@Nullable public static com.mojang.authlib.GameProfile toGameProfile(CompoundTag tag)
public static CompoundTag fromGameProfile(CompoundTag tag, com.mojang.authlib.GameProfile profile)
public static boolean matches(@Nullable Tag standard, @Nullable Tag subject, boolean equalValue)
public static IntArrayTag fromUuid(UUID uuid)
UUID
into its equivalent NBT representation.public static UUID toUuid(Tag tag)
UUID
.
The tag's data must have the same structure as the output of fromUuid(java.util.UUID)
.IllegalArgumentException
- if tag
is not a valid representation of a UUIDpublic static BlockPos toBlockPos(CompoundTag tag)
public static CompoundTag fromBlockPos(BlockPos pos)
public static BlockState toBlockState(CompoundTag tag)
private static <S extends State<?,S>,T extends Comparable<T>> S withProperty(S state, Property<T> property, String key, CompoundTag propertiesTag, CompoundTag mainTag)
public static CompoundTag fromBlockState(BlockState state)
private static <T extends Comparable<T>> String nameValue(Property<T> property, Comparable<?> value)
public static CompoundTag update(com.mojang.datafixers.DataFixer fixer, DataFixTypes fixTypes, CompoundTag tag, int oldVersion)
fixer
- the data fixerfixTypes
- the fix typestag
- the tag to fixoldVersion
- the data version of the compound tagpublic static CompoundTag update(com.mojang.datafixers.DataFixer fixer, DataFixTypes fixTypes, CompoundTag tag, int oldVersion, int targetVersion)
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