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); }
GlowBlock aboveB = b.getRelative(BlockFace.UP); if (aboveB.isEmpty() && b.isFlammable()) { BlockIgniteEvent igniteEvent = new BlockIgniteEvent(aboveB, IgniteCause.LAVA, block); EventFactory.getInstance().callEvent(igniteEvent); if (b.isEmpty()) { if (hasNearFlammableBlock(b)) { BlockIgniteEvent igniteEvent = new BlockIgniteEvent(b, IgniteCause.LAVA, block); EventFactory.getInstance().callEvent(igniteEvent);
private void setBlockOnFire(GlowBlock block) { if (block.isEmpty() && block.getRelative(BlockFace.DOWN).isFlammable()) { BlockIgniteEvent igniteEvent = new BlockIgniteEvent(block, IgniteCause.LIGHTNING, this); EventFactory.getInstance().callEvent(igniteEvent); if (!igniteEvent.isCancelled()) { BlockState state = block.getState(); state.setType(Material.FIRE); state.update(true); } } }
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; } }
continue; BlockIgniteEvent igniteEvent = new BlockIgniteEvent( propagationBlock, IgniteCause.SPREAD, block); EventFactory.getInstance()
private void ignite(Block b, Player p) { if (!checkBlockRespect(p, b)) { Block above = b.getRelative(BlockFace.UP); if (b.getType().equals(Material.TNT)) { b.setBlockData(TARDISConstants.AIR); b.getWorld().spawnEntity(b.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.PRIMED_TNT); plugin.getPM().callEvent(new BlockIgniteEvent(b, IgniteCause.FLINT_AND_STEEL, p)); return; } if (above.getType().equals(Material.AIR)) { above.setBlockData(TARDISConstants.FIRE); // call a block ignite event plugin.getPM().callEvent(new BlockIgniteEvent(b, IgniteCause.FLINT_AND_STEEL, p)); } } }