Search in sources :

Example 1 with Lightable

use of org.bukkit.block.data.Lightable in project Minigames by AddstarMC.

the class PulseRedstoneAction method executeNodeAction.

@Override
public void executeNodeAction(MinigamePlayer player, Node node) {
    debug(player, node);
    BlockData bdata = Material.REDSTONE_BLOCK.createBlockData();
    if (torch.getFlag()) {
        bdata = Material.REDSTONE_TORCH.createBlockData();
        if (bdata instanceof Lightable)
            ((Lightable) bdata).setLit(true);
    }
    final BlockState last = node.getLocation().getBlock().getState();
    node.getLocation().getBlock().setBlockData(bdata);
    Bukkit.getScheduler().scheduleSyncDelayedTask(Minigames.getPlugin(), () -> last.update(true), 20 * time.getFlag());
}
Also used : BlockState(org.bukkit.block.BlockState) Lightable(org.bukkit.block.data.Lightable) BlockData(org.bukkit.block.data.BlockData)

Example 2 with Lightable

use of org.bukkit.block.data.Lightable in project Denizen-For-Bukkit by DenizenScript.

the class MaterialSwitchable method describes.

public static boolean describes(ObjectTag material) {
    if (!(material instanceof MaterialTag)) {
        return false;
    }
    MaterialTag mat = (MaterialTag) material;
    if (!mat.hasModernData()) {
        return false;
    }
    BlockData data = mat.getModernData();
    return data instanceof Powerable || data instanceof Openable || data instanceof Dispenser || data instanceof DaylightDetector || data instanceof Piston || data instanceof Lightable || data instanceof EndPortalFrame || data instanceof Hopper;
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) Lightable(org.bukkit.block.data.Lightable) Powerable(org.bukkit.block.data.Powerable) BlockData(org.bukkit.block.data.BlockData) Openable(org.bukkit.block.data.Openable)

Example 3 with Lightable

use of org.bukkit.block.data.Lightable in project Glowstone by GlowstoneMC.

the class BlockRedstoneOre method blockInteract.

@Override
public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
    BlockData blockData = Bukkit.getServer().createBlockData(Material.REDSTONE_ORE);
    ((Lightable) blockData).setLit(true);
    EntityChangeBlockEvent changeBlockEvent = new EntityChangeBlockEvent(player, block, blockData);
    EventFactory.getInstance().callEvent(changeBlockEvent);
    if (!changeBlockEvent.isCancelled()) {
        GlowBlockState state = block.getState();
        state.setType(Material.REDSTONE_ORE);
        state.update(true);
    }
    return false;
}
Also used : Lightable(org.bukkit.block.data.Lightable) GlowBlockState(net.glowstone.block.GlowBlockState) BlockData(org.bukkit.block.data.BlockData) EntityChangeBlockEvent(org.bukkit.event.entity.EntityChangeBlockEvent)

Aggregations

BlockData (org.bukkit.block.data.BlockData)3 Lightable (org.bukkit.block.data.Lightable)3 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)1 GlowBlockState (net.glowstone.block.GlowBlockState)1 BlockState (org.bukkit.block.BlockState)1 Openable (org.bukkit.block.data.Openable)1 Powerable (org.bukkit.block.data.Powerable)1 EntityChangeBlockEvent (org.bukkit.event.entity.EntityChangeBlockEvent)1