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;
}
}
Aggregations