Search in sources :

Example 1 with Openable

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

the class BlockOpenable method blockInteract.

@Override
public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
    GlowBlockState blockState = block.getState();
    MaterialData materialData = blockState.getData();
    if (materialData instanceof Openable) {
        Openable toOpen = (Openable) materialData;
        boolean wasOpen = toOpen.isOpen();
        toOpen.setOpen(!wasOpen);
        if (wasOpen) {
            onClosed(player, block, face, clickedLoc, blockState, materialData);
        } else {
            onOpened(player, block, face, clickedLoc, blockState, materialData);
        }
        blockState.update(true);
        return true;
    } else {
        warnMaterialData(Openable.class, materialData);
        return false;
    }
}
Also used : GlowBlockState(net.glowstone.block.GlowBlockState) MaterialData(org.bukkit.material.MaterialData) Openable(org.bukkit.material.Openable)

Aggregations

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