本文整理汇总了Java中cn.nukkit.nbt.tag.CompoundTag.setName方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundTag.setName方法的具体用法?Java CompoundTag.setName怎么用?Java CompoundTag.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.nbt.tag.CompoundTag
的用法示例。
在下文中一共展示了CompoundTag.setName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpawnCompound
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
@Override
public CompoundTag getSpawnCompound() {
if (!this.namedTag.contains("Item")) {
this.setItem(new ItemBlock(new BlockAir()), false);
}
CompoundTag NBTItem = namedTag.getCompound("Item").copy();
NBTItem.setName("Item");
boolean item = NBTItem.getShort("id") == Item.AIR;
return new CompoundTag()
.putString("id", BlockEntity.ITEM_FRAME)
.putInt("x", (int) this.x)
.putInt("y", (int) this.y)
.putInt("z", (int) this.z)
.putCompound("Item", item ? NBTIO.putItemHelper(new ItemBlock(new BlockAir())) : NBTItem)
.putByte("ItemRotation", item ? 0 : this.getItemRotation());
// TODO: This crashes the client, why?
// .putFloat("ItemDropChance", this.getItemDropChance());
}
示例2: getSpawnCompound
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
@Override
public CompoundTag getSpawnCompound() {
if (!this.namedTag.contains("Item")) {
this.setItem(new ItemBlock(new BlockAir()), false);
}
CompoundTag NBTItem = namedTag.getCompound("Item").copy();
NBTItem.setName("Item");
boolean item = NBTItem.getShort("id") == Item.AIR;
return new CompoundTag()
.putString("id", BlockEntity.ITEM_FRAME)
.putInt("x", (int) this.x)
.putInt("y", (int) this.y)
.putInt("z", (int) this.z)
.putCompound("Item", item ? NBTIO.putItemHelper(new ItemBlock(new BlockAir())) : NBTItem)
.putByte("ItemRotation", item ? 0 : this.getItemRotation());
// TODO: This crashes the client, why?
// .putFloat("ItemDropChance", this.getItemDropChance());
}
示例3: setNamedTag
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public Item setNamedTag(CompoundTag tag) {
if (tag.isEmpty()) {
return this.clearNamedTag();
}
tag.setName(null);
this.cachedNBT = tag;
this.tags = writeCompoundTag(tag);
return this;
}
示例4: writeCompoundTag
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public byte[] writeCompoundTag(CompoundTag tag) {
try {
tag.setName("");
return NBTIO.write(tag, ByteOrder.LITTLE_ENDIAN);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例5: getItemHelper
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public static Item getItemHelper(CompoundTag tag) {
if (!tag.contains("id") || !tag.contains("Count")) {
return Item.get(0);
}
Item item = Item.get(tag.getShort("id"), !tag.contains("Damage") ? 0 : tag.getShort("Damage"), tag.getByte("Count"));
if (tag.contains("tag") && tag.get("tag") instanceof CompoundTag) {
CompoundTag nbt = tag.getCompound("tag").clone();
nbt.setName("");
item.setNamedTag(nbt);
}
return item;
}