本文整理汇总了Java中cn.nukkit.nbt.tag.CompoundTag.putList方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundTag.putList方法的具体用法?Java CompoundTag.putList怎么用?Java CompoundTag.putList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.nbt.tag.CompoundTag
的用法示例。
在下文中一共展示了CompoundTag.putList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EntityArmorStand
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的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);
}
示例2: getSpawnCompound
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
@Override
public CompoundTag getSpawnCompound() {
CompoundTag nbt = new CompoundTag()
.putString("id", BlockEntity.SHULKER_BOX)
.putInt("x", (int) this.x)
.putInt("y", (int) this.y)
.putInt("z", (int) this.z);
if (this.namedTag.contains("Items")){
nbt.putList(this.namedTag.getList("Items"));
}
if (this.hasName()) {
nbt.put("CustomName", this.namedTag.get("CustomName"));
}
return nbt;
}
示例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 = (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"));
}
}
示例4: place
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
this.getLevel().setBlock(block, this, true, true);
CompoundTag nbt = new CompoundTag("")
.putString("id", BlockEntity.SHULKER_BOX)
.putInt("x", (int) this.x)
.putInt("y", (int) this.y)
.putInt("z", (int) this.z);
if (item.getNamedTag() != null && item.getNamedTag().contains("List")){
nbt.putList(item.getNamedTag().getList("Items"));
}
if (item.hasCustomName()) {
nbt.putString("CustomName", item.getCustomName());
}
if (item.hasCustomBlockData()) {
Map<String, Tag> customData = item.getCustomBlockData().getTags();
for (Map.Entry<String, Tag> tag : customData.entrySet()) {
nbt.put(tag.getKey(), tag.getValue());
}
}
new BlockEntityShulkerBox(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
return true;
}
示例5: place
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
if (face == BlockFace.DOWN) {
return false;
}
CompoundTag nbt = new CompoundTag()
.putString("id", BlockEntity.BANNER)
.putInt("x", (int) block.x)
.putInt("y", (int) block.y)
.putInt("z", (int) block.z)
.putInt("Base", item.getDamage());
if (item.hasCompoundTag()) {
CompoundTag tag = item.getNamedTag();
if (tag.contains("Patterns")) {
nbt.putList(tag.getList("Patterns"));
}
}
if (face == BlockFace.UP) {
meta = (int) Math.floor(((player.yaw + 180) * 16 / 360) + 0.5) & 0x0f;
getLevel().setBlock(block, new BlockBannerStanding(meta), true);
} else {
meta = face.getIndex();
getLevel().setBlock(block, new BlockBannerWall(meta), true);
}
new BlockEntityBanner(getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt);
return true;
}
示例6: BlockEntityBanner
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityBanner(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (!nbt.contains("Base")) {
nbt.putInt("Base", 0);
}
if (!nbt.contains("Patterns")) {
nbt.putList(new ListTag<>("Patterns"));
}
}
示例7: 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"));
}
}
示例8: place
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
this.getLevel().setBlock(block, this, true, true);
CompoundTag nbt = new CompoundTag("")
.putString("id", BlockEntity.SHULKER_BOX)
.putInt("x", (int) this.x)
.putInt("y", (int) this.y)
.putInt("z", (int) this.z);
if (item.getNamedTag() != null && item.getNamedTag().contains("List")){
nbt.putList(item.getNamedTag().getList("Items"));
}
if (item.hasCustomName()) {
nbt.putString("CustomName", item.getCustomName());
}
if (item.hasCustomBlockData()) {
Map<String, Tag> customData = item.getCustomBlockData().getTags();
for (Map.Entry<String, Tag> tag : customData.entrySet()) {
nbt.put(tag.getKey(), tag.getValue());
}
}
new BlockEntityShulkerBox(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
return true;
}
示例9: toBinary
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
@Override
public byte[] toBinary() {
CompoundTag nbt = this.getNBT().copy();
nbt.putInt("xPos", this.x);
nbt.putInt("zPos", this.z);
if (this.isGenerated()) {
nbt.putByteArray("Blocks", this.getBlockIdArray());
nbt.putByteArray("Data", this.getBlockDataArray());
nbt.putByteArray("SkyLight", this.getBlockSkyLightArray());
nbt.putByteArray("BlockLight", this.getBlockLightArray());
nbt.putIntArray("BiomeColors", this.getBiomeColorArray());
nbt.putIntArray("HeightMap", this.getHeightMapArray());
}
ArrayList<CompoundTag> entities = new ArrayList<>();
for (Entity entity : this.getEntities().values()) {
if (!(entity instanceof Player) && !entity.closed) {
entity.saveNBT();
entities.add(entity.namedTag);
}
}
ListTag<CompoundTag> entityListTag = new ListTag<>("Entities");
entityListTag.setAll(entities);
nbt.putList(entityListTag);
ArrayList<CompoundTag> tiles = new ArrayList<>();
for (BlockEntity blockEntity : this.getBlockEntities().values()) {
blockEntity.saveNBT();
tiles.add(blockEntity.namedTag);
}
ListTag<CompoundTag> tileListTag = new ListTag<>("TileEntities");
tileListTag.setAll(tiles);
nbt.putList(tileListTag);
BinaryStream extraData = new BinaryStream();
Map<Integer, Integer> extraDataArray = this.getBlockExtraDataArray();
extraData.putInt(extraDataArray.size());
for (Integer key : extraDataArray.keySet()) {
extraData.putInt(key);
extraData.putShort(extraDataArray.get(key));
}
nbt.putByteArray("ExtraData", extraData.getBuffer());
CompoundTag chunk = new CompoundTag("");
chunk.putCompound("Level", nbt);
try {
return Zlib.deflate(NBTIO.write(chunk, ByteOrder.BIG_ENDIAN), RegionLoader.COMPRESSION_LEVEL);
} catch (Exception e) {
throw new RuntimeException(e);
}
}