Search in sources :

Example 1 with WoodenStep

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

the class BlockSlab method placeBlock.

@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
    super.placeBlock(player, state, face, holding, clickedLoc);
    Material blockType = state.getBlock().getType();
    if (blockType == Material.STEP) {
        state.setType(Material.DOUBLE_STEP);
        state.setData(holding.getData());
        return;
    } else if (blockType == Material.WOOD_STEP) {
        state.setType(Material.WOOD_DOUBLE_STEP);
        state.setData(holding.getData());
        return;
    } else if (blockType == Material.STONE_SLAB2) {
        state.setType(Material.DOUBLE_STONE_SLAB2);
        state.setData(holding.getData());
        return;
    } else if (blockType == Material.PURPUR_SLAB) {
        state.setType(Material.PURPUR_DOUBLE_SLAB);
        state.setData(holding.getData());
        return;
    }
    if (face == BlockFace.DOWN || face != BlockFace.UP && clickedLoc.getY() >= 0.5) {
        MaterialData data = state.getData();
        if (data instanceof Step) {
            ((Step) data).setInverted(true);
        } else if (data instanceof WoodenStep) {
            ((WoodenStep) data).setInverted(true);
        } else if (data.getItemType() == Material.STONE_SLAB2 || data.getItemType() == Material.PURPUR_SLAB) {
            Step slab = new Step(data.getItemType());
            slab.setInverted(true);
            data = slab;
        }
        state.setData(data);
    }
}
Also used : WoodenStep(org.bukkit.material.WoodenStep) Material(org.bukkit.Material) MaterialData(org.bukkit.material.MaterialData) WoodenStep(org.bukkit.material.WoodenStep) Step(org.bukkit.material.Step)

Aggregations

Material (org.bukkit.Material)1 MaterialData (org.bukkit.material.MaterialData)1 Step (org.bukkit.material.Step)1 WoodenStep (org.bukkit.material.WoodenStep)1