Search in sources :

Example 1 with Ladder

use of org.bukkit.material.Ladder in project Glowstone by GlowstoneMC.

the class BlockLadder method placeBlock.

@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
    super.placeBlock(player, state, face, holding, clickedLoc);
    MaterialData data = state.getData();
    if (data instanceof Ladder) {
        if (face != BlockFace.DOWN && face != BlockFace.UP && isTargetOccluding(state, face.getOppositeFace())) {
            ((Ladder) data).setFacingDirection(face.getOppositeFace());
        } else {
            if (isTargetOccluding(state, BlockFace.SOUTH)) {
                ((Ladder) data).setFacingDirection(BlockFace.SOUTH);
            } else if (isTargetOccluding(state, BlockFace.WEST)) {
                ((Ladder) data).setFacingDirection(BlockFace.WEST);
            } else if (isTargetOccluding(state, BlockFace.NORTH)) {
                ((Ladder) data).setFacingDirection(BlockFace.NORTH);
            } else if (isTargetOccluding(state, BlockFace.EAST)) {
                ((Ladder) data).setFacingDirection(BlockFace.EAST);
            } else {
                return;
            }
        }
        state.setData(data);
    } else {
        warnMaterialData(Ladder.class, data);
    }
}
Also used : Ladder(org.bukkit.material.Ladder) MaterialData(org.bukkit.material.MaterialData)

Aggregations

Ladder (org.bukkit.material.Ladder)1 MaterialData (org.bukkit.material.MaterialData)1