当前位置: 首页>>代码示例>>Java>>正文


Java CompoundTag.putCompound方法代码示例

本文整理汇总了Java中cn.nukkit.nbt.tag.CompoundTag.putCompound方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundTag.putCompound方法的具体用法?Java CompoundTag.putCompound怎么用?Java CompoundTag.putCompound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cn.nukkit.nbt.tag.CompoundTag的用法示例。


在下文中一共展示了CompoundTag.putCompound方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:19,代码来源:EntityArmorStand.java

示例2: putItemHelper

import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public static CompoundTag putItemHelper(Item item, Integer slot) {
    CompoundTag tag = new CompoundTag(null)
            .putShort("id", item.getId())
            .putByte("Count", item.getCount())
            .putShort("Damage", item.getDamage());
    if (slot != null) {
        tag.putByte("Slot", slot);
    }

    if (item.hasCompoundTag()) {
        tag.putCompound("tag", item.getNamedTag());
    }

    return tag;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:16,代码来源:NBTIO.java

示例3: BlockEntityItemFrame

import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityItemFrame(FullChunk chunk, CompoundTag nbt) {
    super(chunk, nbt);
    if (!nbt.contains("Item")) {
        nbt.putCompound("Item", NBTIO.putItemHelper(new ItemBlock(new BlockAir())));
    }
    if (!nbt.contains("ItemRotation")) {
        nbt.putByte("ItemRotation", 0);
    }
    if (!nbt.contains("ItemDropChance")) {
        nbt.putFloat("ItemDropChance", 1.0f);
    }

    this.level.updateComparatorOutputLevel(this);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:15,代码来源:BlockEntityItemFrame.java

示例4: 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);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:57,代码来源:Chunk.java


注:本文中的cn.nukkit.nbt.tag.CompoundTag.putCompound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。