Search in sources :

Example 1 with TrapDoor

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

the class BlockTrapDoor method placeBlock.

public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
    MaterialData materialData = state.getData();
    if (materialData instanceof TrapDoor) {
        TrapDoor trapDoor = (TrapDoor) materialData;
        trapDoor.setFacingDirection(face);
        if (clickedLoc.getY() >= 0.5) {
            trapDoor.setInverted(true);
        } else {
            trapDoor.setInverted(false);
        }
        state.update(true);
    } else {
        parent.warnMaterialData(TrapDoor.class, materialData);
    }
}
Also used : TrapDoor(org.bukkit.material.TrapDoor) MaterialData(org.bukkit.material.MaterialData)

Example 2 with TrapDoor

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

the class BlockTrapDoor method onRedstoneUpdate.

public void onRedstoneUpdate(GlowBlock block) {
    GlowBlockState state = block.getState();
    TrapDoor trapdoor = (TrapDoor) state.getData();
    boolean powered = block.isBlockIndirectlyPowered();
    if (powered != trapdoor.isOpen()) {
        trapdoor.setOpen(powered);
        state.update();
    }
}
Also used : TrapDoor(org.bukkit.material.TrapDoor) GlowBlockState(net.glowstone.block.GlowBlockState)

Aggregations

TrapDoor (org.bukkit.material.TrapDoor)2 GlowBlockState (net.glowstone.block.GlowBlockState)1 MaterialData (org.bukkit.material.MaterialData)1