Java Code Examples for cn.nukkit.block.Block#get()
The following examples show how to use
cn.nukkit.block.Block#get() .
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: BlockEntityMovingBlock.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override protected void initBlockEntity() { if (namedTag.contains("movingBlockData") && namedTag.contains("movingBlockId")) { this.block = Block.get(namedTag.getInt("movingBlockId"), namedTag.getInt("movingBlockData")); } else { this.close(); } if (namedTag.contains("pistonPosX") && namedTag.contains("pistonPosY") && namedTag.contains("pistonPosZ")) { this.piston = new BlockVector3(namedTag.getInt("pistonPosX"), namedTag.getInt("pistonPosY"), namedTag.getInt("pistonPosZ")); } else { this.close(); } super.initBlockEntity(); }
Example 2
Source File: BlockEntityMovingBlock.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public BlockEntityMovingBlock(FullChunk chunk, CompoundTag nbt) { super(chunk, nbt); if (nbt.contains("movingBlockData") && nbt.contains("movingBlockId")) { this.block = Block.get(nbt.getInt("movingBlockId"), nbt.getInt("movingBlockData")); } else { this.close(); } if (nbt.contains("pistonPosX") && nbt.contains("pistonPosY") && nbt.contains("pistonPosZ")) { this.piston = new BlockVector3(nbt.getInt("pistonPosX"), nbt.getInt("pistonPosY"), nbt.getInt("pistonPosZ")); } else { this.close(); } this.isMovable = nbt.getBoolean("isMovable"); }
Example 3
Source File: BlockEntityShulkerBox.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public Item getItem(int index) { int i = this.getSlotIndex(index); if (i < 0) { return new ItemBlock(Block.get(BlockID.AIR), 0, 0); } else { CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i); return NBTIO.getItemHelper(data); } }
Example 4
Source File: PlayerInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public Item getItemInHand() { Item item = this.getItem(this.getHeldItemIndex()); if (item != null) { return item; } else { return new ItemBlock(Block.get(BlockID.AIR), 0, 0); } }
Example 5
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public Block getAndSetBlock(int x, int y, int z, Block block) { int i = (x << 11) | (z << 7) | y; boolean changed = false; byte id = (byte) block.getId(); byte previousId = this.blocks[i]; if (previousId != id) { this.blocks[i] = id; changed = true; } int previousData; i >>= 1; int old = this.data[i] & 0xff; if ((y & 1) == 0) { previousData = old & 0x0f; if (Block.hasMeta[block.getId()]) { this.data[i] = (byte) ((old & 0xf0) | (block.getDamage() & 0x0f)); if (block.getDamage() != previousData) { changed = true; } } } else { previousData = old >> 4; if (Block.hasMeta[block.getId()]) { this.data[i] = (byte) (((block.getDamage() & 0x0f) << 4) | (old & 0x0f)); if (block.getDamage() != previousData) { changed = true; } } } if (changed) { setChanged(); } return Block.get(previousId, previousData); }
Example 6
Source File: EntityLightning.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override protected void initEntity() { super.initEntity(); this.setHealth(4); this.setMaxHealth(4); this.state = 2; this.liveTime = ThreadLocalRandom.current().nextInt(3) + 1; if (isEffect && this.level.gameRules.getBoolean(GameRule.DO_FIRE_TICK) && (this.server.getDifficulty() >= 2)) { Block block = this.getLevelBlock(); if (block.getId() == 0 || block.getId() == Block.TALL_GRASS) { BlockFire fire = (BlockFire) Block.get(BlockID.FIRE); fire.x = block.x; fire.y = block.y; fire.z = block.z; fire.level = level; this.getLevel().setBlock(fire, fire, true); if (fire.isBlockTopFacingSurfaceSolid(fire.down()) || fire.canNeighborBurn()) { BlockIgniteEvent e = new BlockIgniteEvent(block, null, this, BlockIgniteEvent.BlockIgniteCause.LIGHTNING); getServer().getPluginManager().callEvent(e); if (!e.isCancelled()) { level.setBlock(fire, fire, true); level.scheduleUpdate(fire, fire.tickRate() + ThreadLocalRandom.current().nextInt(10)); } } } } }
Example 7
Source File: BlockEntityHopper.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public Item getItem(int index) { int i = this.getSlotIndex(index); if (i < 0) { return new ItemBlock(Block.get(BlockID.AIR), 0, 0); } else { CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i); return NBTIO.getItemHelper(data); } }
Example 8
Source File: ItemDye.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public ItemDye(Integer meta, int amount) { super(DYE, meta, amount, DyeColor.getByDyeData(meta).getDyeName()); if (this.meta == DyeColor.BROWN.getDyeData()) { this.block = Block.get(BlockID.COCOA_BLOCK); } }
Example 9
Source File: ItemItemFrame.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ItemItemFrame(Integer meta, int count) { super(ITEM_FRAME, meta, count, "Item Frame"); this.block = Block.get(BlockID.ITEM_FRAME_BLOCK); }
Example 10
Source File: ItemSeedsPumpkin.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ItemSeedsPumpkin(Integer meta, int count) { super(PUMPKIN_SEEDS, 0, count, "Pumpkin Seeds"); this.block = Block.get(BlockID.PUMPKIN_STEM); }
Example 11
Source File: ItemSign.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ItemSign(Integer meta, int count) { super(SIGN, 0, count, "Sign"); this.block = Block.get(BlockID.SIGN_POST); }
Example 12
Source File: ItemBrewingStand.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ItemBrewingStand(Integer meta, int count) { super(BREWING_STAND, 0, count, "Brewing Stand"); this.block = Block.get(BlockID.BREWING_STAND_BLOCK); }
Example 13
Source File: ItemNetherWart.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ItemNetherWart(Integer meta, int count) { super(NETHER_WART, meta, count, "Nether Wart"); this.block = Block.get(BlockID.NETHER_WART_BLOCK, meta); }
Example 14
Source File: ItemPotato.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ItemPotato(Integer meta, int count) { super(POTATO, meta, count, "Potato"); this.block = Block.get(BlockID.POTATO_BLOCK); }
Example 15
Source File: ItemDoorDarkOak.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ItemDoorDarkOak(Integer meta, int count) { super(DARK_OAK_DOOR, 0, count, "Dark Oak Door"); this.block = Block.get(BlockID.DARK_OAK_DOOR_BLOCK); }
Example 16
Source File: ItemSkull.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public ItemSkull(Integer meta, int count) { super(SKULL, meta, count, getItemSkullName(meta)); this.block = Block.get(Block.SKULL_BLOCK); }
Example 17
Source File: ItemRedstoneComparator.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ItemRedstoneComparator(Integer meta, int count) { super(COMPARATOR, meta, count, "Redstone Comparator"); this.block = Block.get(BlockID.UNPOWERED_COMPARATOR); }
Example 18
Source File: EntityMinecartTNT.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public EntityMinecartTNT(FullChunk chunk, CompoundTag nbt) { super(chunk, nbt); super.setDisplayBlock(Block.get(BlockID.TNT), false); }
Example 19
Source File: ItemFlowerPot.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public ItemFlowerPot(Integer meta, int count) { super(FLOWER_POT, meta, count, "Flower Pot"); this.block = Block.get(Block.FLOWER_POT_BLOCK); }
Example 20
Source File: ItemBanner.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public ItemBanner(Integer meta, int count) { super(BANNER, meta, count, "Banner"); this.block = Block.get(Block.STANDING_BANNER); }