cn.nukkit.nbt.tag.IntTag Java Examples
The following examples show how to use
cn.nukkit.nbt.tag.IntTag.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockEntityPistonArm.java From Jupiter with GNU General Public License v3.0 | 5 votes |
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")); } }
Example #2
Source File: ItemBanner.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public void correctNBT() { CompoundTag tag = this.getNamedTag() != null ? this.getNamedTag() : new CompoundTag(); if (!tag.contains("Base") || !(tag.get("Base") instanceof IntTag)) { tag.putInt("Base", this.meta); } this.setNamedTag(tag); }
Example #3
Source File: BlockBanner.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (face != BlockFace.DOWN) { if (face == BlockFace.UP) { this.setDamage(NukkitMath.floorDouble(((player.yaw + 180) * 16 / 360) + 0.5) & 0x0f); this.getLevel().setBlock(block, this, true); } else { this.setDamage(face.getIndex()); this.getLevel().setBlock(block, Block.get(BlockID.WALL_BANNER, this.getDamage()), true); } CompoundTag nbt = BlockEntity.getDefaultCompound(this, BlockEntity.BANNER) .putInt("Base", item.getDamage() & 0xf); Tag type = item.getNamedTagEntry("Type"); if (type instanceof IntTag) { nbt.put("Type", type); } Tag patterns = item.getNamedTagEntry("Patterns"); if (patterns instanceof ListTag) { nbt.put("Patterns", patterns); } BlockEntityBanner banner = (BlockEntityBanner) BlockEntity.createBlockEntity(BlockEntity.BANNER, this.getChunk(), nbt); return banner != null; } return false; }
Example #4
Source File: BlockEntityPistonArm.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override protected void initBlockEntity() { if (namedTag.contains("Progress")) { this.progress = namedTag.getFloat("Progress"); } if (namedTag.contains("LastProgress")) { this.lastProgress = (float) namedTag.getInt("LastProgress"); } if (namedTag.contains("Sticky")) { this.sticky = namedTag.getBoolean("Sticky"); } if (namedTag.contains("Extending")) { this.extending = namedTag.getBoolean("Extending"); } if (namedTag.contains("powered")) { this.powered = namedTag.getBoolean("powered"); } if (namedTag.contains("AttachedBlocks")) { ListTag blocks = namedTag.getList("AttachedBlocks", IntTag.class); if (blocks != null && blocks.size() > 0) { this.attachedBlock = new Vector3((double) ((IntTag) blocks.get(0)).getData(), (double) ((IntTag) blocks.get(1)).getData(), (double) ((IntTag) blocks.get(2)).getData()); } } else { namedTag.putList(new ListTag("AttachedBlocks")); } super.initBlockEntity(); }
Example #5
Source File: BlockEntityPistonArm.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override protected void initBlockEntity() { if (namedTag.contains("Progress")) { this.progress = namedTag.getFloat("Progress"); } if (namedTag.contains("LastProgress")) { this.lastProgress = (float) namedTag.getInt("LastProgress"); } if (namedTag.contains("Sticky")) { this.sticky = namedTag.getBoolean("Sticky"); } if (namedTag.contains("Extending")) { this.extending = namedTag.getBoolean("Extending"); } if (namedTag.contains("powered")) { this.powered = namedTag.getBoolean("powered"); } if (namedTag.contains("AttachedBlocks")) { ListTag blocks = namedTag.getList("AttachedBlocks", IntTag.class); if (blocks != null && blocks.size() > 0) { this.attachedBlock = new Vector3((double) ((IntTag) blocks.get(0)).getData(), (double) ((IntTag) blocks.get(1)).getData(), (double) ((IntTag) blocks.get(2)).getData()); } } else { namedTag.putList(new ListTag("AttachedBlocks")); } super.initBlockEntity(); }