cn.nukkit.event.player.PlayerInteractEvent.Action Java Examples
The following examples show how to use
cn.nukkit.event.player.PlayerInteractEvent.Action.
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: Player.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public void stopSleep() { if (this.sleeping != null) { this.server.getPluginManager().callEvent(new PlayerBedLeaveEvent(this, this.level.getBlock(this.sleeping))); this.sleeping = null; this.setDataProperty(new IntPositionEntityData(DATA_PLAYER_BED_POSITION, 0, 0, 0)); this.setDataFlag(DATA_PLAYER_FLAGS, DATA_PLAYER_FLAG_SLEEP, false); this.level.sleepTicks = 0; AnimatePacket pk = new AnimatePacket(); pk.eid = this.id; pk.action = AnimatePacket.Action.WAKE_UP; this.dataPacket(pk); } }