Search in sources :

Example 6 with BlockIgniteEvent

use of org.bukkit.event.block.BlockIgniteEvent in project Arcade2 by ShootGame.

the class BlockTransformListeners method onBlockIgnite.

@EventHandler(ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event) {
    BlockIgniteEvent.IgniteCause cause = BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL;
    if (event.getCause().equals(cause)) {
        return;
    }
    BlockState newState = this.applyState(event.getBlock(), Material.FIRE);
    this.post(event, event.getBlock().getState(), newState, event.getPlayer());
}
Also used : BlockState(org.bukkit.block.BlockState) BlockIgniteEvent(org.bukkit.event.block.BlockIgniteEvent) EventHandler(org.bukkit.event.EventHandler)

Example 7 with BlockIgniteEvent

use of org.bukkit.event.block.BlockIgniteEvent in project Glowstone by GlowstoneMC.

the class Explosion method setBlockOnFire.

private void setBlockOnFire(GlowBlock block) {
    if (ThreadLocalRandom.current().nextInt(3) != 0) {
        return;
    }
    Block below = block.getRelative(BlockFace.DOWN);
    Material belowType = below.getType();
    if (belowType == Material.AIR || belowType == Material.FIRE || !belowType.isFlammable()) {
        return;
    }
    BlockIgniteEvent event = EventFactory.getInstance().callEvent(new BlockIgniteEvent(block, IgniteCause.EXPLOSION, source));
    if (event.isCancelled()) {
        return;
    }
    block.setType(Material.FIRE);
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) Block(org.bukkit.block.Block) Material(org.bukkit.Material) BlockIgniteEvent(org.bukkit.event.block.BlockIgniteEvent)

Example 8 with BlockIgniteEvent

use of org.bukkit.event.block.BlockIgniteEvent in project Glowstone by GlowstoneMC.

the class ItemFlintAndSteel method setBlockOnFire.

private boolean setBlockOnFire(GlowPlayer player, GlowBlock clicked, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) {
    GlowBlock fireBlock = clicked.getRelative(face);
    if (fireBlock.getType() != Material.AIR) {
        return true;
    }
    if (!clicked.isFlammable() && clicked.getRelative(BlockFace.DOWN).getType() == Material.AIR) {
        return true;
    }
    BlockIgniteEvent event = EventFactory.getInstance().callEvent(new BlockIgniteEvent(fireBlock, IgniteCause.FLINT_AND_STEEL, player, null));
    if (event.isCancelled()) {
        player.setItemInHand(holding);
        return false;
    }
    // clone holding to avoid decreasing of the item's amount
    ItemTable.instance().getBlock(Material.FIRE).rightClickBlock(player, clicked, face, holding.clone(), clickedLoc, hand);
    return true;
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) BlockIgniteEvent(org.bukkit.event.block.BlockIgniteEvent)

Aggregations

BlockIgniteEvent (org.bukkit.event.block.BlockIgniteEvent)8 GlowBlock (net.glowstone.block.GlowBlock)5 GlowBlockState (net.glowstone.block.GlowBlockState)2 Material (org.bukkit.Material)2 Block (org.bukkit.block.Block)2 BlockState (org.bukkit.block.BlockState)2 EventHandler (org.bukkit.event.EventHandler)2 UndoList (com.elmakers.mine.bukkit.api.block.UndoList)1 GlowWorld (net.glowstone.GlowWorld)1 Difficulty (org.bukkit.Difficulty)1 BlockFace (org.bukkit.block.BlockFace)1 Entity (org.bukkit.entity.Entity)1 FallingBlock (org.bukkit.entity.FallingBlock)1