/** * <p>Called when the BlockType should calculate the current physics.</p> * <p>Subclasses should override {@link #updatePhysicsAfterEvent(GlowBlock)} * if they need a custom handling of the physics calculation</p> * * @param block The block */ public final void updatePhysics(GlowBlock block) { if (!block.getWorld().isInitialized()) { return; } BlockPhysicsEvent event = EventFactory.getInstance() .callEvent(new BlockPhysicsEvent(block, block.getTypeId())); if (!event.isCancelled()) { updatePhysicsAfterEvent(block); } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockPhysics(final BlockPhysicsEvent event) { final Block block = event.getBlock(); if (!WaterManipulation.canPhysicsChange(block) || !EarthPassive.canPhysicsChange(block) || Illumination.isIlluminationTorch(block) || EarthAbility.getPreventPhysicsBlocks().contains(block)) { event.setCancelled(true); } // If there is a TempBlock of Air bellow FallingSand blocks, prevent it from updating. if (!event.isCancelled() && (block.getType() == Material.SAND || block.getType() == Material.GRAVEL || block.getType() == Material.ANVIL || block.getType() == Material.DRAGON_EGG) && TempBlock.isTempBlock(block.getRelative(BlockFace.DOWN)) && block.getRelative(BlockFace.DOWN).getType() == Material.AIR) { event.setCancelled(true); } }