本文整理汇总了Java中cn.nukkit.item.Item.FARMLAND属性的典型用法代码示例。如果您正苦于以下问题:Java Item.FARMLAND属性的具体用法?Java Item.FARMLAND怎么用?Java Item.FARMLAND使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cn.nukkit.item.Item
的用法示例。
在下文中一共展示了Item.FARMLAND属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fall
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);
}
}
}
示例2: fall
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, PlayerInteractEvent.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);
}
}
}
示例3: fall
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) {
Block down = this.level.getBlock(this.floor().down());
if (down.getId() == Item.FARMLAND) {
if (this instanceof Player) {
Player p = (Player) this;
PlayerInteractEvent ev = new PlayerInteractEvent(p, p.getInventory().getItemInHand(), down, null, Action.PHYSICAL);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
return;
}
}
this.level.setBlock(down, new BlockDirt(), true, true);
}
}
}