本文整理汇总了Java中cn.nukkit.block.Block.canBeReplaced方法的典型用法代码示例。如果您正苦于以下问题:Java Block.canBeReplaced方法的具体用法?Java Block.canBeReplaced怎么用?Java Block.canBeReplaced使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.block.Block
的用法示例。
在下文中一共展示了Block.canBeReplaced方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdate
import cn.nukkit.block.Block; //导入方法依赖的package包/类
@Override
public boolean onUpdate(int currentTick) {
if (closed) {
return false;
}
this.timing.startTiming();
int tickDiff = currentTick - lastUpdate;
if (tickDiff <= 0 && !justCreated) {
return true;
}
lastUpdate = currentTick;
boolean hasUpdate = entityBaseTick(tickDiff);
if (isAlive()) {
motionY -= getGravity();
move(motionX, motionY, motionZ);
float friction = 1 - getDrag();
motionX *= friction;
motionY *= 1 - getDrag();
motionZ *= friction;
Vector3 pos = (new Vector3(x - 0.5, y, z - 0.5)).round();
if (onGround) {
kill();
Block block = level.getBlock(pos);
if (block.getId() > 0 && block.isTransparent() && !block.canBeReplaced()) {
if (this.level.getGameRules().getBoolean("doEntityDrops")) {
getLevel().dropItem(this, Item.get(this.getBlock(), this.getDamage(), 1));
}
} else {
EntityBlockChangeEvent event = new EntityBlockChangeEvent(this, block, Block.get(getBlock(), getDamage()));
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
getLevel().setBlock(pos, event.getTo(), true);
if (event.getTo().getId() == Item.ANVIL) {
getLevel().addSound(new AnvilFallSound(pos));
}
}
}
hasUpdate = true;
}
updateMovement();
}
this.timing.stopTiming();
return hasUpdate || !onGround || Math.abs(motionX) > 0.00001 || Math.abs(motionY) > 0.00001 || Math.abs(motionZ) > 0.00001;
}