本文整理汇总了Java中cn.nukkit.nbt.tag.ListTag.add方法的典型用法代码示例。如果您正苦于以下问题:Java ListTag.add方法的具体用法?Java ListTag.add怎么用?Java ListTag.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.nbt.tag.ListTag
的用法示例。
在下文中一共展示了ListTag.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeBook
import cn.nukkit.nbt.tag.ListTag; //导入方法依赖的package包/类
public Item writeBook(String author, String title, String[] pages) {
ListTag<CompoundTag> pageList = new ListTag<>("pages");
for (String page : pages) {
pageList.add(new CompoundTag().putString("photoname", "").putString("text", page));
}
return writeBook(author, title, pageList);
}
示例2: writeBook
import cn.nukkit.nbt.tag.ListTag; //导入方法依赖的package包/类
public Item writeBook (String author, String title, String[] pages) {
ListTag<CompoundTag> pageList = new ListTag<>("pages");
for (String page : pages){
pageList.add(new CompoundTag().putString("photoname", "").putString("text", page));
}
return writeBook(author, title, pageList);
}
示例3: saveNBT
import cn.nukkit.nbt.tag.ListTag; //导入方法依赖的package包/类
public void saveNBT() {
if (!(this instanceof Player)) {
this.namedTag.putString("id", this.getSaveId());
if (!this.getNameTag().equals("")) {
this.namedTag.putString("CustomName", this.getNameTag());
this.namedTag.putBoolean("CustomNameVisible", this.isNameTagVisible());
} else {
this.namedTag.remove("CustomName");
this.namedTag.remove("CustomNameVisible");
}
}
this.namedTag.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("0", this.x))
.add(new DoubleTag("1", this.y))
.add(new DoubleTag("2", this.z))
);
this.namedTag.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("0", this.motionX))
.add(new DoubleTag("1", this.motionY))
.add(new DoubleTag("2", this.motionZ))
);
this.namedTag.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("0", (float) this.yaw))
.add(new FloatTag("1", (float) this.pitch))
);
this.namedTag.putFloat("FallDistance", this.fallDistance);
this.namedTag.putShort("Fire", this.fireTicks);
this.namedTag.putShort("Air", this.getDataPropertyShort(DATA_AIR));
this.namedTag.putBoolean("OnGround", this.onGround);
this.namedTag.putBoolean("Invulnerable", this.invulnerable);
this.namedTag.putFloat("Scale", this.scale);
if (!this.effects.isEmpty()) {
ListTag<CompoundTag> list = new ListTag<>("ActiveEffects");
for (Effect effect : this.effects.values()) {
list.add(new CompoundTag(String.valueOf(effect.getId()))
.putByte("Id", effect.getId())
.putByte("Amplifier", effect.getAmplifier())
.putInt("Duration", effect.getDuration())
.putBoolean("Ambient", false)
.putBoolean("ShowParticles", effect.isVisible())
);
}
this.namedTag.putList(list);
} else {
this.namedTag.remove("ActiveEffects");
}
}