Search in sources :

Example 1 with Gate

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

the class BlockFenceGate method onRedstoneUpdate.

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

Example 2 with Gate

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

the class BlockFenceGate method onOpened.

@Override
protected void onOpened(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc, GlowBlockState state, MaterialData materialData) {
    if (materialData instanceof Gate) {
        Gate gate = (Gate) materialData;
        gate.setFacingDirection(getOpenDirection(player.getLocation().getYaw(), gate.getFacing()));
    } else {
        warnMaterialData(Gate.class, materialData);
    }
}
Also used : Gate(org.bukkit.material.Gate)

Example 3 with Gate

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

the class BlockFenceGate method placeBlock.

@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
    super.placeBlock(player, state, face, holding, clickedLoc);
    MaterialData materialData = state.getData();
    if (materialData instanceof Gate) {
        Gate gate = (Gate) materialData;
        float yaw = player.getLocation().getYaw();
        gate.setFacingDirection(blockFaceFromYaw(yaw));
        state.update(true);
    } else {
        warnMaterialData(Gate.class, materialData);
    }
}
Also used : Gate(org.bukkit.material.Gate) MaterialData(org.bukkit.material.MaterialData)

Aggregations

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