本文整理汇总了Java中cn.nukkit.nbt.tag.ListTag类的典型用法代码示例。如果您正苦于以下问题:Java ListTag类的具体用法?Java ListTag怎么用?Java ListTag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListTag类属于cn.nukkit.nbt.tag包,在下文中一共展示了ListTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initEntity
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
protected void initEntity() {
if (this.namedTag.contains("ActiveEffects")) {
ListTag<CompoundTag> effects = this.namedTag.getList("ActiveEffects", CompoundTag.class);
for (CompoundTag e : effects.getAll()) {
Effect effect = Effect.getEffect(e.getByte("Id"));
if (effect == null) {
continue;
}
effect.setAmplifier(e.getByte("Amplifier")).setDuration(e.getInt("Duration")).setVisible(e.getBoolean("showParticles"));
this.addEffect(effect);
}
}
if (this.namedTag.contains("CustomName")) {
this.setNameTag(this.namedTag.getString("CustomName"));
if (this.namedTag.contains("CustomNameVisible")) {
this.setNameTagVisible(this.namedTag.getBoolean("CustomNameVisible"));
}
}
this.scheduleUpdate();
}
示例2: getEnchantments
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
public Enchantment[] getEnchantments() {
if (!this.hasEnchantments()) {
return new Enchantment[0];
}
List<Enchantment> enchantments = new ArrayList<>();
ListTag<CompoundTag> ench = this.getNamedTag().getList("ench", CompoundTag.class);
for (CompoundTag entry : ench.getAll()) {
Enchantment e = Enchantment.getEnchantment(entry.getShort("id"));
if (e != null) {
e.setLevel(entry.getShort("lvl"));
enchantments.add(e);
}
}
return enchantments.stream().toArray(Enchantment[]::new);
}
示例3: getLore
import cn.nukkit.nbt.tag.ListTag; //导入依赖的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]);
}
示例4: onActivate
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartChest minecart = new EntityMinecartChest(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例5: BlockEntityBrewingStand
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
public BlockEntityBrewingStand(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
inventory = new BrewingInventory(this);
if (!namedTag.contains("Items") || !(namedTag.get("Items") instanceof ListTag)) {
namedTag.putList(new ListTag<CompoundTag>("Items"));
}
for (int i = 0; i < getSize(); i++) {
inventory.setItem(i, this.getItem(i));
}
if (!namedTag.contains("CookTime") || namedTag.getShort("CookTime") > MAX_BREW_TIME) {
this.brewTime = MAX_BREW_TIME;
} else {
this.brewTime = namedTag.getShort("CookTime");
}
if (brewTime < MAX_BREW_TIME) {
this.scheduleUpdate();
}
}
示例6: onActivate
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartHopper minecart = new EntityMinecartHopper(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例7: prime
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
public void prime(int fuse) {
this.getLevel().setBlock(this, new BlockAir(), true);
double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2;
CompoundTag nbt = new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", this.x + 0.5))
.add(new DoubleTag("", this.y))
.add(new DoubleTag("", this.z + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", -Math.sin(mot) * 0.02))
.add(new DoubleTag("", 0.2))
.add(new DoubleTag("", -Math.cos(mot) * 0.02)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
.putByte("Fuse", fuse);
Entity tnt = new EntityPrimedTNT(
this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4),
nbt
);
tnt.spawnToAll();
this.level.addSound(new TNTPrimeSound(this));
}
示例8: place
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
if (super.place(item, block, target, face, fx, fy, fz, player)) {
CompoundTag nbt = new CompoundTag()
.putList(new ListTag<>("Items"))
.putString("id", BlockEntity.COMPARATOR)
.putInt("x", (int) this.x)
.putInt("y", (int) this.y)
.putInt("z", (int) this.z);
new BlockEntityComparator(this.level.getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
onUpdate(Level.BLOCK_UPDATE_REDSTONE);
return true;
}
return false;
}
示例9: initEntity
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
protected void initEntity() {
if (this.namedTag.contains("ActiveEffects")) {
ListTag<CompoundTag> effects = this.namedTag.getList("ActiveEffects", CompoundTag.class);
for (CompoundTag e : effects.getAll()) {
int amplifier = e.getByte("Amplifier") & 0xff; // 0-255 only
Effect effect = Effect.getEffect(e.getByte("Id"));
if (effect == null) {
continue;
}
effect.setAmplifier(amplifier).setDuration(e.getInt("Duration")).setVisible(e.getBoolean("showParticles"));
this.addEffect(effect);
}
}
if (this.namedTag.contains("CustomName")) {
this.setNameTag(this.namedTag.getString("CustomName"));
if (this.namedTag.contains("CustomNameVisible")) {
this.setNameTagVisible(this.namedTag.getBoolean("CustomNameVisible"));
}
}
this.scheduleUpdate();
}
示例10: BlockEntityBrewingStand
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
public BlockEntityBrewingStand(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
inventory = new BrewingInventory(this);
if (!namedTag.contains("Items") || !(namedTag.get("Items") instanceof ListTag)) {
namedTag.putList(new ListTag<CompoundTag>("Items"));
}
for (int i = 0; i < getSize(); i++) {
inventory.setItem(i, this.getItem(i));
}
if (!namedTag.contains("CookTime") || namedTag.getShort("CookTime") > MAX_BREW_TIME) {
this.brewTime = MAX_BREW_TIME;
} else {
this.brewTime = namedTag.getShort("CookTime");
}
this.fuelAmount = namedTag.getShort("FuelAmount");
this.fuelTotal = namedTag.getShort("FuelTotal");
if (brewTime < MAX_BREW_TIME) {
this.scheduleUpdate();
}
}
示例11: EntityArmorStand
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
public EntityArmorStand(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (!nbt.contains("HandItems")) {
nbt.putCompound("HandItems", NBTIO.putItemHelper(Item.get(0)));
}
if (!nbt.contains("ArmorItems")) {
ListTag<CompoundTag> tag = new ListTag<CompoundTag>("ArmorItems")
.add(NBTIO.putItemHelper(Item.get(0)))
.add(NBTIO.putItemHelper(Item.get(0)))
.add(NBTIO.putItemHelper(Item.get(0)))
.add(NBTIO.putItemHelper(Item.get(0)));
nbt.putList(tag);
}
this.setHealth(2);
this.setMaxHealth(2);
}
示例12: hasEnchantments
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
public boolean hasEnchantments() {
if (!this.hasCompoundTag()) {
return false;
}
CompoundTag tag = this.getNamedTag();
if (tag.contains("ench")) {
Tag enchTag = tag.get("ench");
if (enchTag instanceof ListTag) {
return true;
}
}
return false;
}
示例13: dropExpOrb
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
public void dropExpOrb(Vector3 source, int exp, Vector3 motion, int delay) {
motion = (motion == null) ? new Vector3(new java.util.Random().nextDouble() * 0.2 - 0.1, 0.2,
new java.util.Random().nextDouble() * 0.2 - 0.1) : motion;
CompoundTag nbt = new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", source.getX()))
.add(new DoubleTag("", source.getY())).add(new DoubleTag("", source.getZ())))
.putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", motion.getX()))
.add(new DoubleTag("", motion.getY())).add(new DoubleTag("", motion.getZ())))
.putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("", 0)).add(new FloatTag("", 0)));
Entity entity = new EntityXPOrb(this.getChunk(source.getFloorX() >> 4, source.getFloorZ() >> 4), nbt);
EntityXPOrb xpOrb = (EntityXPOrb) entity;
xpOrb.setExp(exp);
xpOrb.setPickupDelay(delay);
xpOrb.saveNBT();
xpOrb.spawnToAll();
}
示例14: onActivate
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartTNT minecart = new EntityMinecartTNT(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例15: onUpdate
import cn.nukkit.nbt.tag.ListTag; //导入依赖的package包/类
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_NORMAL) {
Block down = this.down();
if (down.getId() == AIR || down instanceof BlockLiquid) {
EntityFallingBlock fall = (EntityFallingBlock) Entity.createEntity("FallingSand", this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4),
new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", this.x + 0.5))
.add(new DoubleTag("", this.y))
.add(new DoubleTag("", this.z + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
.putInt("TileID", this.getId())
.putByte("Data", this.getDamage()));
fall.spawnToAll();
}
}
return type;
}