本文整理汇总了Java中com.comphenix.protocol.wrappers.nbt.NbtFactory.setItemTag方法的典型用法代码示例。如果您正苦于以下问题:Java NbtFactory.setItemTag方法的具体用法?Java NbtFactory.setItemTag怎么用?Java NbtFactory.setItemTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.comphenix.protocol.wrappers.nbt.NbtFactory
的用法示例。
在下文中一共展示了NbtFactory.setItemTag方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSkullTexture
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static ItemStack setSkullTexture(ItemStack itemStack, String value) {
ItemStack newStack = itemStack;
if (!MinecraftReflection.isCraftItemStack(itemStack)) {
newStack = MinecraftReflection.getBukkitItemStack(itemStack);
}
NbtCompound tag = (NbtCompound) NbtFactory.fromItemTag(newStack);
NbtCompound skullOwner = NbtFactory.ofCompound("SkullOwner");
NbtCompound properties = NbtFactory.ofCompound("Properties");
NbtCompound compound = NbtFactory.ofCompound("");
compound.put("Value", value);
NbtList<NbtCompound> textures = NbtFactory.ofList("textures", compound);
properties.put(textures);
skullOwner.put("Id", UUID.randomUUID().toString());
skullOwner.put(properties);
tag.put(skullOwner);
NbtFactory.setItemTag(newStack, tag);
return newStack;
}
示例2: saveDeathTime
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static void saveDeathTime(ItemStack item, long deathTime) {
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
if (deathTime == 0) {
nbt.remove(DEATH_TIME_TAG);
} else {
nbt.put(DEATH_TIME_TAG, deathTime);
}
NbtFactory.setItemTag(item, nbt);
}
示例3: saveHealth
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static void saveHealth(ItemStack item, double health) {
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
if (health == 0) {
nbt.remove("pet.health");
} else {
nbt.put("pet.health", health);
}
NbtFactory.setItemTag(item, nbt);
}
示例4: setTag
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static ItemStack setTag(ItemStack item, String tag, String value) {
item = toBukkitItemStack(item);
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
if (!nbt.containsKey(tag)) {
if (UNBREAKABLE_TAG.equals(tag) || HIDE_FLAGS_TAG.equals(tag)) {
nbt.put(tag, Integer.parseInt(value));
} else {
nbt.put(tag, value);
}
}
NbtFactory.setItemTag(item, nbt);
return item;
}
示例5: nbtToItemStack
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static ItemStack nbtToItemStack(NbtCompound nbt) {
ItemStack item = new ItemStack(Material.valueOf(nbt.getString("material")));
if (!ItemUtils.isEmpty(item)) {
item.setAmount(nbt.getInteger("amount"));
item.setDurability(nbt.getShort("data"));
if (nbt.containsKey("tag")) {
item = toBukkitItemStack(item);
NbtFactory.setItemTag(item, nbt.getCompound("tag"));
}
}
return item;
}
示例6: addGlow
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
private void addGlow(ItemStack[] stacks) {
for (ItemStack stack : stacks) {
if (stack != null && stack.hasItemMeta()) {
if(stack.containsEnchantment(GLOW_ENCHANT_INDICATOR) && stack.getEnchantmentLevel(GLOW_ENCHANT_INDICATOR) == GLOW_ENCHANT_LEVEL){
// If our custom enchant exists and is set to the appropriate value, overwrite enchantment glow so it will render as glow w/o enchants
NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(stack);
compound.put(NbtFactory.ofList("ench"));
NbtFactory.setItemTag(stack, compound);
}
}
}
}
示例7: setTag
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public void setTag(@NonNull NbtCompound tag) {
NbtFactory.setItemTag(this.item, tag);
}