Java Code Examples for cn.nukkit.math.BlockFace#values()
The following examples show how to use
cn.nukkit.math.BlockFace#values() .
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: Level.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public int isBlockIndirectlyGettingPowered(Vector3 pos) { int power = 0; for (BlockFace face : BlockFace.values()) { int blockPower = this.getRedstonePower(pos.getSide(face), face); if (blockPower >= 15) { return 15; } if (blockPower > power) { power = blockPower; } } return power; }
Example 2
Source File: BlockRedstoneTorchUnlit.java From Nukkit with GNU General Public License v3.0 | 6 votes |
protected boolean checkState() { BlockFace face = getBlockFace().getOpposite(); Vector3 pos = getLocation(); if (!this.level.isSidePowered(pos.getSide(face), face)) { this.level.setBlock(pos, Block.get(BlockID.REDSTONE_TORCH, getDamage()), false, true); for (BlockFace side : BlockFace.values()) { if (side == face) { continue; } this.level.updateAroundRedstone(pos.getSide(side), null); } return true; } return false; }
Example 3
Source File: BlockSponge.java From Nukkit with GNU General Public License v3.0 | 6 votes |
private boolean performWaterAbsorb(Block block) { Queue<Entry> entries = new ArrayDeque<>(); entries.add(new Entry(block, 0)); Entry entry; int waterRemoved = 0; while (waterRemoved < 64 && (entry = entries.poll()) != null) { for (BlockFace face : BlockFace.values()) { Block faceBlock = entry.block.getSide(face); if (faceBlock.getId() == BlockID.WATER || faceBlock.getId() == BlockID.STILL_WATER) { this.level.setBlock(faceBlock, Block.get(BlockID.AIR)); ++waterRemoved; if (entry.distance < 6) { entries.add(new Entry(faceBlock, entry.distance + 1)); } } else if (faceBlock.getId() == BlockID.AIR) { if (entry.distance < 6) { entries.add(new Entry(faceBlock, entry.distance + 1)); } } } } return waterRemoved > 0; }
Example 4
Source File: BlockRedstoneWire.java From Nukkit with GNU General Public License v3.0 | 6 votes |
private int getIndirectPower() { int power = 0; Vector3 pos = getLocation(); for (BlockFace face : BlockFace.values()) { int blockPower = this.getIndirectPower(pos.getSide(face), face); if (blockPower >= 15) { return 15; } if (blockPower > power) { power = blockPower; } } return power; }
Example 5
Source File: BlockPistonBase.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private boolean addBranchingBlocks(Block block) { for (BlockFace face : BlockFace.values()) { if (face.getAxis() != this.moveDirection.getAxis() && !this.addBlockLine(block.getSide(face))) { return false; } } return true; }
Example 6
Source File: BlockRedstoneWire.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void updateAround(Vector3 pos, BlockFace face) { if (this.level.getBlock(pos).getId() == Block.REDSTONE_WIRE) { this.level.updateAroundRedstone(pos, face); for (BlockFace side : BlockFace.values()) { this.level.updateAroundRedstone(pos.getSide(side), side.getOpposite()); } } }
Example 7
Source File: BlockLiquid.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void checkForHarden() { if (this instanceof BlockLava) { boolean colliding = false; for (BlockFace face : BlockFace.values()) { if (colliding = this.getSide(face) instanceof BlockWater) { break; } } if (colliding) { Block to; if (this.getDamage() == 0) { to = new BlockObsidian(); } else if (this.getDamage() <= 4) { to = new BlockCobblestone(); } else { return; } to.setComponents(this.getX(), this.getY(), this.getZ()); to.setLevel(this.getLevel()); BlockFromToEvent ev = new BlockFromToEvent(this, to); this.getLevel().getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { this.getLevel().setBlock(this, ev.getTo(), true); this.triggerLavaMixEffects(this); } } } }
Example 8
Source File: BlockNetherPortal.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onBreak(Item item) { boolean result = super.onBreak(item); for (BlockFace face : BlockFace.values()) { Block b = this.getSide(face); if (b != null) { if (b instanceof BlockNetherPortal) { result &= b.onBreak(item); } } } return result; }
Example 9
Source File: BlockLava.java From Nukkit with GNU General Public License v3.0 | 5 votes |
protected boolean isSurroundingBlockFlammable(Block block) { for (BlockFace face : BlockFace.values()) { if (block.getSide(face).getBurnChance() > 0) { return true; } } return false; }
Example 10
Source File: BlockLava.java From Nukkit with GNU General Public License v3.0 | 5 votes |
protected boolean isSurroundingBlockFlammable(Block block) { for (BlockFace face : BlockFace.values()) { if (block.getSide(face).getBurnChance() > 0) { return true; } } return false; }
Example 11
Source File: BlockRedstoneWire.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void updateAround(Vector3 pos, BlockFace face) { if (this.level.getBlock(pos).getId() == Block.REDSTONE_WIRE) { this.level.updateAroundRedstone(pos, face); for (BlockFace side : BlockFace.values()) { this.level.updateAroundRedstone(pos.getSide(side), side.getOpposite()); } } }
Example 12
Source File: BlockRedstoneDiode.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onBreak(Item item) { Vector3 pos = getLocation(); this.level.setBlock(this, Block.get(BlockID.AIR), true, true); for (BlockFace face : BlockFace.values()) { this.level.updateAroundRedstone(pos.getSide(face), null); } return true; }
Example 13
Source File: BlockLiquid.java From Jupiter with GNU General Public License v3.0 | 5 votes |
private void checkForHarden() { if (this instanceof BlockLava) { boolean colliding = false; for (BlockFace face : BlockFace.values()) { if (colliding = this.getSide(face) instanceof BlockWater) { break; } } if (colliding) { Block to; if (this.getDamage() == 0) { to = new BlockObsidian(); } else if (this.getDamage() <= 4) { to = new BlockCobblestone(); } else { return; } to.setComponents(this.getX(), this.getY(), this.getZ()); to.setLevel(this.getLevel()); BlockFromToEvent ev = new BlockFromToEvent(this, to); this.getLevel().getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { this.getLevel().setBlock(this, ev.getTo(), true); this.triggerLavaMixEffects(this); } } } }
Example 14
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public void updateAroundRedstone(Vector3 pos, BlockFace face) { for (BlockFace side : BlockFace.values()) { /*if(face != null && side == face) { continue; }*/ this.getBlock(pos.getSide(side)).onUpdate(BLOCK_UPDATE_REDSTONE); } }
Example 15
Source File: BlockRedstoneTorch.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onBreak(Item item) { this.getLevel().setBlock(this, new BlockAir(), true, true); Vector3 pos = getLocation(); for (BlockFace side : BlockFace.values()) { this.level.updateAroundRedstone(pos.getSide(side), null); } return true; }
Example 16
Source File: BlockRedstoneDiode.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onBreak(Item item) { Vector3 pos = getLocation(); this.level.setBlock(this, new BlockAir(), true, true); for (BlockFace face : BlockFace.values()) { this.level.updateAroundRedstone(pos.getSide(face), null); } return true; }
Example 17
Source File: BlockFire.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public boolean canNeighborBurn() { for (BlockFace face : BlockFace.values()) { if (this.getSide(face).getBurnChance() > 0) { return true; } } return false; }
Example 18
Source File: BlockLava.java From Jupiter with GNU General Public License v3.0 | 5 votes |
protected boolean isSurroundingBlockFlammable(Block block) { for (BlockFace face : BlockFace.values()) { if (block.getSide(face).getBurnChance() > 0) { return true; } } return false; }
Example 19
Source File: BlockRedstoneWire.java From Jupiter with GNU General Public License v3.0 | 5 votes |
private void updateAround(Vector3 pos, BlockFace face) { if (this.level.getBlock(pos).getId() == Block.REDSTONE_WIRE) { this.level.updateAroundRedstone(pos, face); for (BlockFace side : BlockFace.values()) { this.level.updateAroundRedstone(pos.getSide(side), side.getOpposite()); } } }
Example 20
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public void updateAround(Vector3 pos) { BlockUpdateEvent ev; for (BlockFace face : BlockFace.values()) { this.server.getPluginManager().callEvent( ev = new BlockUpdateEvent(this.getBlock(pos.getSide(face)))); if (!ev.isCancelled()) { ev.getBlock().onUpdate(BLOCK_UPDATE_NORMAL); } } }