org.bukkit.material.Attachable Java Examples
The following examples show how to use
org.bukkit.material.Attachable.
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: CraftBlockState.java From Kettle with GNU General Public License v3.0 | 5 votes |
public boolean update(boolean force, boolean applyPhysics) { if (!isPlaced()) { return true; } Block block = getBlock(); if (block.getType() != getType()) { if (!force) { return false; } } BlockPos pos = new BlockPos(x, y, z); IBlockState newBlock = CraftMagicNumbers.getBlock(getType()).getStateFromMeta(this.getRawData()); block.setTypeIdAndData(getTypeId(), getRawData(), applyPhysics); world.getHandle().notifyBlockUpdate( pos, CraftMagicNumbers.getBlock(block).getStateFromMeta(block.getData()), newBlock, 3 ); // Update levers etc if (applyPhysics && getData() instanceof Attachable) { world.getHandle().notifyNeighborsOfStateChange(pos.offset(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock(), false); } if (nbt != null) { TileEntity te = world.getHandle().getTileEntity(new BlockPos(this.x, this.y, this.z)); if (te != null) { te.readFromNBT(nbt); } } return true; }
Example #2
Source File: SignShop.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
private BlockFace getSignFacingFromWorld() { // try getting the current sign facing from the sign in the world: Sign sign = this.getSign(); if (sign != null) { return ((Attachable) sign.getData()).getFacing(); } return null; }
Example #3
Source File: SignShop.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
@Override public boolean spawn() { Location signLocation = this.getActualLocation(); if (signLocation == null) return false; Block signBlock = signLocation.getBlock(); if (signBlock.getType() != Material.AIR) { return false; } // place sign: // TODO maybe also allow non-wall signs? // cancel block physics for this placed sign if needed: ShopkeepersPlugin.getInstance().cancelNextBlockPhysics(signLocation); signBlock.setType(Material.WALL_SIGN); // cleanup state if no block physics were triggered: ShopkeepersPlugin.getInstance().cancelNextBlockPhysics(null); // in case sign placement has failed for some reason: if (!Utils.isSign(signBlock.getType())) { return false; } // set sign facing: if (signFacing != null) { Sign signState = (Sign) signBlock.getState(); ((Attachable) signState.getData()).setFacingDirection(signFacing); // apply facing: signState.update(); } // init sign content: updateSign = false; this.updateSign(); return true; }
Example #4
Source File: ExtensionLobbyWall.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
private static Block getAttached(Sign sign) { Attachable data = (Attachable) sign.getData(); BlockFace attachingBlockFace = data.getFacing().getOppositeFace(); return sign.getBlock().getRelative(attachingBlockFace); }