Java Code Examples for cn.nukkit.math.BlockFace#DOWN
The following examples show how to use
cn.nukkit.math.BlockFace#DOWN .
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: BlockVine.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { BlockFace[] faces = { BlockFace.DOWN, BlockFace.SOUTH, BlockFace.WEST, BlockFace.DOWN, BlockFace.NORTH, BlockFace.DOWN, BlockFace.DOWN, BlockFace.DOWN, BlockFace.EAST }; if (!this.getSide(faces[this.meta]).isSolid()) { Block up = this.up(); if (up.getId() != this.getId() || up.meta != this.meta) { this.getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } } return 0; }
Example 2
Source File: BlockPistonBase.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public static boolean canPush(Block block, BlockFace face, boolean destroyBlocks) { if (!block.canBePushed()) { return false; } else if (block.getY() >= 0 && (face != BlockFace.DOWN || block.getY() != 0)) { if (block.getY() <= 255 && (face != BlockFace.UP || block.getY() != 255)) { if (!(block instanceof BlockPistonBase)) { if (block instanceof BlockFlowable) { return destroyBlocks; } } else if (((BlockPistonBase) block).isExtended()) { return false; } return true; } else { return false; } } else { return false; } }
Example 3
Source File: BlockCocoa.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (target.getId() == Block.WOOD && (target.getDamage() & 0x03) == BlockWood.JUNGLE) { if (face != BlockFace.DOWN && face != BlockFace.UP) { int[] faces = new int[]{ 0, 0, 0, 2, 3, 1, }; this.setDamage(faces[face.getIndex()]); this.level.setBlock(block, this, true, true); return true; } } return false; }
Example 4
Source File: BlockPistonBase.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public static boolean canPush(Block block, BlockFace face, boolean destroyBlocks) { if (!block.canBePushed()) { return false; } else if (block.getY() >= 0 && (face != BlockFace.DOWN || block.getY() != 0)) { if (block.getY() <= 255 && (face != BlockFace.UP || block.getY() != 255)) { if (!(block instanceof BlockPistonBase)) { if (block instanceof BlockFlowable) { return destroyBlocks; } } else if (((BlockPistonBase) block).isExtended()) { return false; } return true; } else { return false; } } else { return false; } }
Example 5
Source File: BlockTripWireHook.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (!this.getSide(face.getOpposite()).isNormalBlock() || face == BlockFace.DOWN || face == BlockFace.UP) { return false; } if (face.getAxis().isHorizontal()) { this.setFace(face); } this.level.setBlock(this, this); if (player != null) { this.calculateState(false, false, -1, null); } return true; }
Example 6
Source File: BlockTorch.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { Block below = this.down(); if (!target.isTransparent() && face != BlockFace.DOWN) { int[] faces = new int[]{ 0, //0, nerver used 5, //1 4, //2 3, //3 2, //4 1, //5 }; this.meta = faces[face.getIndex()]; this.getLevel().setBlock(block, this, true, true); return true; } else if (!below.isTransparent() || below instanceof BlockFence || below.getId() == COBBLE_WALL) { this.meta = 0; this.getLevel().setBlock(block, this, true, true); return true; } return false; }
Example 7
Source File: BlockTorch.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { Block below = this.down(); if (!target.isTransparent() && face != BlockFace.DOWN) { int[] faces = new int[]{ 0, //0, nerver used 5, //1 4, //2 3, //3 2, //4 1, //5 }; this.setDamage(faces[face.getIndex()]); this.getLevel().setBlock(block, this, true, true); return true; } else if (!below.isTransparent() || below instanceof BlockFence || below.getId() == COBBLE_WALL) { this.setDamage(0); this.getLevel().setBlock(block, this, true, true); return true; } return false; }
Example 8
Source File: BlockStairs.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) { int[] faces = new int[]{2, 1, 3, 0}; this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]); if ((fy > 0.5 && face != BlockFace.UP) || face == BlockFace.DOWN) { this.setDamage(this.getDamage() | 0x04); //Upside-down stairs } this.getLevel().setBlock(block, this, true, true); return true; }
Example 9
Source File: BlockSignPost.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) { CompoundTag nbt = new CompoundTag() .putString("id", BlockEntity.SIGN) .putInt("x", (int) block.x) .putInt("y", (int) block.y) .putInt("z", (int) block.z) .putString("Text1", "") .putString("Text2", "") .putString("Text3", "") .putString("Text4", ""); if (face == BlockFace.UP) { setDamage((int) Math.floor(((player.yaw + 180) * 16 / 360) + 0.5) & 0x0f); getLevel().setBlock(block, Block.get(BlockID.SIGN_POST, getDamage()), true); } else { setDamage(face.getIndex()); getLevel().setBlock(block, Block.get(BlockID.WALL_SIGN, getDamage()), true); } if (player != null) { nbt.putString("Creator", player.getUniqueId().toString()); } if (item.hasCustomBlockData()) { for (Tag aTag : item.getCustomBlockData().getAllTags()) { nbt.put(aTag.getName(), aTag); } } BlockEntitySign sign = (BlockEntitySign) BlockEntity.createBlockEntity(BlockEntity.SIGN, getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt); return sign != null; } return false; }
Example 10
Source File: BlockHopper.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) { BlockFace facing = face.getOpposite(); if (facing == BlockFace.UP) { facing = BlockFace.DOWN; } this.setDamage(facing.getIndex()); boolean powered = this.level.isBlockPowered(this.getLocation()); if (powered == this.isEnabled()) { this.setEnabled(!powered); } this.level.setBlock(this, this); CompoundTag nbt = new CompoundTag() .putList(new ListTag<>("Items")) .putString("id", BlockEntity.HOPPER) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); BlockEntityHopper hopper = (BlockEntityHopper) BlockEntity.createBlockEntity(BlockEntity.HOPPER, this.level.getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt); return hopper != null; }
Example 11
Source File: BlockPistonBase.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public static boolean canPush(Block block, BlockFace face, boolean destroyBlocks) { if (block.canBePushed() && block.getY() >= 0 && (face != BlockFace.DOWN || block.getY() != 0) && block.getY() <= 255 && (face != BlockFace.UP || block.getY() != 255)) { if (!(block instanceof BlockPistonBase)) { if (block instanceof BlockFlowable) { return destroyBlocks; } } else return !((BlockPistonBase) block).isExtended(); return true; } return false; }
Example 12
Source File: BlockSignPost.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) { CompoundTag nbt = new CompoundTag() .putString("id", BlockEntity.SIGN) .putInt("x", (int) block.x) .putInt("y", (int) block.y) .putInt("z", (int) block.z) .putString("Text1", "") .putString("Text2", "") .putString("Text3", "") .putString("Text4", ""); if (face == BlockFace.UP) { setDamage((int) Math.floor(((player.yaw + 180) * 16 / 360) + 0.5) & 0x0f); getLevel().setBlock(block, new BlockSignPost(getDamage()), true); } else { setDamage(face.getIndex()); getLevel().setBlock(block, new BlockWallSign(getDamage()), true); } if (player != null) { nbt.putString("Creator", player.getUniqueId().toString()); } if (item.hasCustomBlockData()) { for (Tag aTag : item.getCustomBlockData().getAllTags()) { nbt.put(aTag.getName(), aTag); } } new BlockEntitySign(getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt); return true; } return false; }
Example 13
Source File: BlockRedstoneTorchUnlit.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) { Block below = this.down(); if (!target.isTransparent() && face != BlockFace.DOWN) { int[] faces = new int[]{ 0, //0, nerver used 5, //1 4, //2 3, //3 2, //4 1, //5 }; this.setDamage(faces[face.getIndex()]); this.getLevel().setBlock(block, this, true, true); //Redstone.active(this); return true; } else if (!below.isTransparent() || below instanceof BlockFence || below.getId() == COBBLE_WALL) { this.setDamage(0); this.getLevel().setBlock(block, this, true, true); //Redstone.active(this); return true; } return false; }
Example 14
Source File: BlockBannerStanding.java From Jupiter 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) { 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; }
Example 15
Source File: BlockHopper.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) { BlockFace facing = face.getOpposite(); if (facing == BlockFace.UP) { facing = BlockFace.DOWN; } this.setDamage(facing.getIndex()); boolean powered = this.level.isBlockPowered(this); if (powered == this.isEnabled()) { this.setEnabled(!powered); } this.level.setBlock(this, this); CompoundTag nbt = new CompoundTag() .putList(new ListTag<>("Items")) .putString("id", BlockEntity.HOPPER) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); new BlockEntityHopper(this.level.getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt); return true; }
Example 16
Source File: BlockSlab.java From Jupiter with GNU General Public License v3.0 | 4 votes |
@Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { this.meta &= 0x07; if (face == BlockFace.DOWN) { if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0x08 && (target.getDamage() & 0x07) == (this.meta & 0x07)) { this.getLevel().setBlock(target, Block.get(doubleSlab, this.meta), true); return true; } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.meta & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.meta), true); return true; } else { this.meta |= 0x08; } } else if (face == BlockFace.UP) { if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0 && (target.getDamage() & 0x07) == (this.meta & 0x07)) { this.getLevel().setBlock(target, Block.get(doubleSlab, this.meta), true); return true; } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.meta & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.meta), true); return true; } //TODO: check for collision } else { if (block instanceof BlockSlab) { if ((block.getDamage() & 0x07) == (this.meta & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.meta), true); return true; } return false; } else { if (fy > 0.5) { this.meta |= 0x08; } } } if (block instanceof BlockSlab && (target.getDamage() & 0x07) != (this.meta & 0x07)) { return false; } this.getLevel().setBlock(block, this, true, true); return true; }
Example 17
Source File: BlockSlab.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { this.setDamage(this.getDamage() & 0x07); if (face == BlockFace.DOWN) { if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0x08 && (target.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(target, Block.get(doubleSlab, this.getDamage()), true); return true; } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true); return true; } else { this.setDamage(this.getDamage() | 0x08); } } else if (face == BlockFace.UP) { if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0 && (target.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(target, Block.get(doubleSlab, this.getDamage()), true); return true; } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true); return true; } //TODO: check for collision } else { if (block instanceof BlockSlab) { if ((block.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true); return true; } return false; } else { if (fy > 0.5) { this.setDamage(this.getDamage() | 0x08); } } } if (block instanceof BlockSlab && (target.getDamage() & 0x07) != (this.getDamage() & 0x07)) { return false; } this.getLevel().setBlock(block, this, true, true); return true; }
Example 18
Source File: BlockSlab.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { this.setDamage(this.getDamage() & 0x07); if (face == BlockFace.DOWN) { if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0x08 && (target.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(target, Block.get(doubleSlab, this.getDamage()), true); return true; } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true); return true; } else { this.setDamage(this.getDamage() | 0x08); } } else if (face == BlockFace.UP) { if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0 && (target.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(target, Block.get(doubleSlab, this.getDamage()), true); return true; } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true); return true; } //TODO: check for collision } else { if (block instanceof BlockSlab) { if ((block.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true); return true; } return false; } else { if (fy > 0.5) { this.setDamage(this.getDamage() | 0x08); } } } if (block instanceof BlockSlab && (target.getDamage() & 0x07) != (this.getDamage() & 0x07)) { return false; } this.getLevel().setBlock(block, this, true, true); return true; }
Example 19
Source File: BlockRedstoneTorch.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public int getStrongPower(BlockFace side) { return side == BlockFace.DOWN ? this.getWeakPower(side) : 0; }
Example 20
Source File: BlockRedstoneTorch.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public int getStrongPower(BlockFace side) { return side == BlockFace.DOWN ? this.getWeakPower(side) : 0; }