cn.nukkit.event.player.PlayerInteractEvent Java Examples
The following examples show how to use
cn.nukkit.event.player.PlayerInteractEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Entity.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public void fall(float fallDistance) { float damage = (float) Math.floor(fallDistance - 3 - (this.hasEffect(Effect.JUMP) ? this.getEffect(Effect.JUMP).getAmplifier() + 1 : 0)); if (damage > 0) { this.attack(new EntityDamageEvent(this, DamageCause.FALL, damage)); } if (fallDistance > 0.75) { BlockVector3 v = new BlockVector3(getFloorX(), getFloorY() - 1, getFloorZ()); int down = this.level.getBlockIdAt(v.x, v.y, v.z); if (down == Item.FARMLAND) { if (this instanceof Player) { Player p = (Player) this; PlayerInteractEvent ev = new PlayerInteractEvent(p, p.getInventory().getItemInHand(), this.temporalVector.setComponents(v.x, v.y, v.z), null, Action.PHYSICAL); this.server.getPluginManager().callEvent(ev); if (ev.isCancelled()) { return; } } this.level.setBlock(this.temporalVector.setComponents(v.x, v.y, v.z), new BlockDirt(), true, true); } } }
Example #2
Source File: BrushListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerInteract(final PlayerInteractEvent event) { Player nukkitPlayer = event.getPlayer(); if (nukkitPlayer.isSneaking()) { if (event.getAction() == PlayerInteractEvent.Action.PHYSICAL) { return; } FawePlayer<Object> fp = FawePlayer.wrap(nukkitPlayer); com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = fp.getSession(); Tool tool = session.getTool(player); if (tool instanceof ResettableTool) { if (((ResettableTool) tool).reset()) { event.setCancelled(true); } } } }