本文整理汇总了Java中cn.nukkit.nbt.tag.CompoundTag.getList方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundTag.getList方法的具体用法?Java CompoundTag.getList怎么用?Java CompoundTag.getList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.nbt.tag.CompoundTag
的用法示例。
在下文中一共展示了CompoundTag.getList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLore
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public String[] getLore() {
Tag tag = this.getNamedTagEntry("display");
ArrayList<String> lines = new ArrayList<>();
if (tag instanceof CompoundTag) {
CompoundTag nbt = (CompoundTag) tag;
ListTag<StringTag> lore = nbt.getList("Lore", StringTag.class);
if (lore.size() > 0) {
for (StringTag stringTag : lore.getAll()) {
lines.add(stringTag.data);
}
}
}
return lines.toArray(new String[0]);
}
示例2: BlockEntityPistonArm
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityPistonArm(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (nbt.contains("Progress")) {
this.progress = nbt.getFloat("Progress");
}
if (nbt.contains("LastProgress")) {
this.lastProgress = (float) nbt.getInt("LastProgress");
}
if (nbt.contains("Sticky")) {
this.sticky = nbt.getBoolean("Sticky");
}
if (nbt.contains("Extending")) {
this.extending = nbt.getBoolean("Extending");
}
if (nbt.contains("powered")) {
this.powered = nbt.getBoolean("powered");
}
if (nbt.contains("AttachedBlocks")) {
ListTag blocks = nbt.getList("AttachedBlocks", IntTag.class);
if (blocks != null && blocks.size() > 0) {
this.attachedBlock = new Vector3((double) ((IntTag) blocks.get(0)).getData().intValue(), (double) ((IntTag) blocks.get(1)).getData().intValue(), (double) ((IntTag) blocks.get(2)).getData().intValue());
}
} else {
nbt.putList(new ListTag("AttachedBlocks"));
}
}
示例3: BlockEntityPistonArm
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityPistonArm(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (nbt.contains("Progress")) {
this.progress = nbt.getFloat("Progress");
}
if (nbt.contains("LastProgress")) {
this.lastProgress = nbt.getInt("LastProgress");
}
if (nbt.contains("Sticky")) {
this.sticky = nbt.getBoolean("Sticky");
}
if (nbt.contains("Extending")) {
this.extending = nbt.getBoolean("Extending");
}
if (nbt.contains("AttachedBlocks")) {
ListTag<IntTag> blocks = nbt.getList("AttachedBlocks", IntTag.class);
if (blocks != null && blocks.size() > 0) {
this.attachedBlock = new Vector3(blocks.get(0).getData(), blocks.get(1).getData(), blocks.get(2).getData());
}
} else {
nbt.putList(new ListTag<IntTag>("AttachedBlocks"));
}
}