Class NBTUtils
java.lang.Object
me.desht.pneumaticcraft.common.util.NBTUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<net.minecraft.network.chat.Component>deserializeTextComponents(net.minecraft.nbt.ListTag l) static booleanstatic floatstatic intstatic Stringstatic booleangetBoolean(net.minecraft.world.item.ItemStack itemStack, String tagName) Gets a Boolean value of the given tag from theCompoundTagof the givenItemStack.static byteGets a Byte value of the given tag from theCompoundTagof the givenItemStack.static net.minecraft.nbt.CompoundTaggetCompoundTag(net.minecraft.world.item.ItemStack itemStack, String tagName) Gets aCompoundTagvalue of the given tag from theCompoundTagof the givenItemStack.static doubleGets a Double value of the given tag from theCompoundTagof the givenItemStack.static floatGets a Float value of the given tag from theCompoundTagof the givenItemStack.static intgetInteger(net.minecraft.world.item.ItemStack itemStack, String tagName) Gets an Integer value of the given tag from theCompoundTagof the givenItemStack.static longGets a Long value of the given tag from theCompoundTagof the givenItemStack.static net.minecraft.core.BlockPosgetPos(net.minecraft.nbt.CompoundTag tag) static net.minecraft.core.BlockPosgetPos(net.minecraft.world.item.ItemStack stack) static shortGets a Short value of the given tag from theCompoundTagof the givenItemStack.static StringGets a String value of the given tag from theCompoundTagof the givenItemStack.static booleanChecks if theCompoundTagof the givenItemStackhas a given tag.static voidinitNBTTagCompound(net.minecraft.world.item.ItemStack itemStack) Initializes theCompoundTagfor the givenItemStackif it is null.static voidRemoves the given tag from theCompoundTagof the givenItemStack.static net.minecraft.nbt.ListTagserializeTextComponents(List<net.minecraft.network.chat.Component> textComponents) static voidsetBoolean(net.minecraft.world.item.ItemStack itemStack, String tagName, boolean tagValue) Sets the given boolean value for the given tag on theCompoundTagof the givenItemStack.static voidSets the given byte value for the given tag on theCompoundTagof the givenItemStack.static voidsetCompoundTag(net.minecraft.world.item.ItemStack itemStack, String tagName, net.minecraft.nbt.Tag tagValue) Sets the givenCompoundTagvalue for the given tag on theCompoundTagof the givenItemStack.static voidSets the given double value for the given tag on theCompoundTagof the givenItemStack.static voidSets the given float value for the given tag on theCompoundTagof the givenItemStack.static voidsetInteger(net.minecraft.world.item.ItemStack itemStack, String tagName, int tagValue) Sets the given integer value for the given tag on theCompoundTagof the givenItemStack.static voidSets the given long value for the given tag on theCompoundTagof the givenItemStack.static voidsetPos(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.Vec3i vec) static voidsetPos(net.minecraft.world.item.ItemStack stack, net.minecraft.core.Vec3i vec) static voidSets the given short value for the given tag on theCompoundTagof the givenItemStack.static voidSets the given String value for the given tag on theCompoundTagof the givenItemStack.
-
Constructor Details
-
NBTUtils
public NBTUtils()
-
-
Method Details
-
initNBTTagCompound
public static void initNBTTagCompound(net.minecraft.world.item.ItemStack itemStack) Initializes theCompoundTagfor the givenItemStackif it is null.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.
-
hasTag
Checks if theCompoundTagof the givenItemStackhas a given tag.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be checked.- Returns:
- True if the
CompoundTaghas the tag otherwise false.
-
removeTag
Removes the given tag from theCompoundTagof the givenItemStack.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be removed.
-
getString
Gets a String value of the given tag from theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag for which the value should be determined.- Returns:
- The value of the given tag as a String or an empty String if the NBT Tag Compound has no such key.
-
setString
public static void setString(net.minecraft.world.item.ItemStack itemStack, String tagName, String tagValue) Sets the given String value for the given tag on theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be set.tagValue- The value which should be set to the given tag as a String.
-
getBoolean
Gets a Boolean value of the given tag from theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag for which the value should be determined.- Returns:
- The value of the given tag as a Boolean or false if the NBT Tag Compound has no such key.
-
setBoolean
public static void setBoolean(net.minecraft.world.item.ItemStack itemStack, String tagName, boolean tagValue) Sets the given boolean value for the given tag on theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be set.tagValue- The value which should be set to the given tag as a boolean.
-
getByte
Gets a Byte value of the given tag from theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag for which the value should be determined.- Returns:
- The value of the given tag as a Byte or 0 if the NBT Tag Compound has no such key.
-
setByte
public static void setByte(net.minecraft.world.item.ItemStack itemStack, String tagName, byte tagValue) Sets the given byte value for the given tag on theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be set.tagValue- The value which should be set to the given tag as a byte.
-
getShort
Gets a Short value of the given tag from theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag for which the value should be determined.- Returns:
- The value of the given tag as a Short or 0 if the NBT Tag Compound has no such key.
-
setShort
public static void setShort(net.minecraft.world.item.ItemStack itemStack, String tagName, short tagValue) Sets the given short value for the given tag on theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be set.tagValue- The value which should be set to the given tag as a short.
-
getInteger
Gets an Integer value of the given tag from theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag for which the value should be determined.- Returns:
- The value of the given tag as an Integer or 0 if the NBT Tag Compound has no such key.
-
setInteger
public static void setInteger(net.minecraft.world.item.ItemStack itemStack, String tagName, int tagValue) Sets the given integer value for the given tag on theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be set.tagValue- The value which should be set to the given tag as an integer.
-
getLong
Gets a Long value of the given tag from theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag for which the value should be determined.- Returns:
- The value of the given tag as a Long or 0 if the NBT Tag Compound has no such key.
-
setLong
public static void setLong(net.minecraft.world.item.ItemStack itemStack, String tagName, long tagValue) Sets the given long value for the given tag on theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be set.tagValue- The value which should be set to the given tag as a long.
-
getFloat
Gets a Float value of the given tag from theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag for which the value should be determined.- Returns:
- The value of the given tag as a Float or 0 if the NBT Tag Compound has no such key.
-
setFloat
public static void setFloat(net.minecraft.world.item.ItemStack itemStack, String tagName, float tagValue) Sets the given float value for the given tag on theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be set.tagValue- The value which should be set to the given tag as a float.
-
getDouble
Gets a Double value of the given tag from theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag for which the value should be determined.- Returns:
- The value of the given tag as a Double or 0 if the NBT Tag Compound has no such key.
-
setDouble
public static void setDouble(net.minecraft.world.item.ItemStack itemStack, String tagName, double tagValue) Sets the given double value for the given tag on theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be set.tagValue- The value which should be set to the given tag as a double.
-
getCompoundTag
public static net.minecraft.nbt.CompoundTag getCompoundTag(net.minecraft.world.item.ItemStack itemStack, String tagName) Gets aCompoundTagvalue of the given tag from theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag for which the value should be determined.- Returns:
- The value of the given tag as a
CompoundTag.
-
setCompoundTag
public static void setCompoundTag(net.minecraft.world.item.ItemStack itemStack, String tagName, net.minecraft.nbt.Tag tagValue) Sets the givenCompoundTagvalue for the given tag on theCompoundTagof the givenItemStack. If theCompoundTagis null it will be initialized.- Parameters:
itemStack- TheItemStackwhich holds theCompoundTag.tagName- The name of the tag which should be set.tagValue- The value which should be set to the given tag as aCompoundTag.
-
setPos
public static void setPos(net.minecraft.world.item.ItemStack stack, net.minecraft.core.Vec3i vec) -
getPos
public static net.minecraft.core.BlockPos getPos(net.minecraft.world.item.ItemStack stack) -
setPos
public static void setPos(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.Vec3i vec) -
getPos
public static net.minecraft.core.BlockPos getPos(net.minecraft.nbt.CompoundTag tag) -
fromTag
-
fromTag
-
fromTag
-
fromTag
-
serializeTextComponents
public static net.minecraft.nbt.ListTag serializeTextComponents(List<net.minecraft.network.chat.Component> textComponents) -
deserializeTextComponents
public static List<net.minecraft.network.chat.Component> deserializeTextComponents(net.minecraft.nbt.ListTag l)
-