org.bukkit.block.data.Orientable Java Examples

The following examples show how to use org.bukkit.block.data.Orientable. 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: BlockAdapterBlockData.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setAxis(Block block, boolean z) {
    if (!(block.getBlockData() instanceof Orientable)) {
        throw new IllegalArgumentException("Block is not Orientable");
    }
    Orientable data = (Orientable) block.getBlockData();
    data.setAxis(z ? Axis.Z : Axis.X);
    block.setBlockData(data, false);
}
 
Example #2
Source File: LumberAxe.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private void stripLog(Block b) {
    b.getWorld().playSound(b.getLocation(), Sound.ITEM_AXE_STRIP, 1, 1);
    Axis axis = ((Orientable) b.getBlockData()).getAxis();
    b.setType(Material.valueOf("STRIPPED_" + b.getType().name()));

    Orientable orientable = (Orientable) b.getBlockData();
    orientable.setAxis(axis);
    b.setBlockData(orientable);
}
 
Example #3
Source File: Draw3d.java    From GiantTrees with GNU General Public License v3.0 5 votes vote down vote up
private UnaryOperator<BlockData> orient(Orientation orientation) {
  return blockData -> {
    if (blockData instanceof Orientable) {
      Orientable orientable = (Orientable) blockData;
      switch (orientation) {
        case xMajor: orientable.setAxis(Axis.X);
        case yMajor: orientable.setAxis(Axis.Z);
        case zMajor: orientable.setAxis(Axis.Y);
      }
    }
    return blockData;
  };
}