use of cn.nukkit.event.block.BlockPistonChangeEvent in project Nukkit by Nukkit.
the class BlockPistonBase method onUpdate.
@Override
public int onUpdate(int type) {
if (type != 6 && type != 1) {
return 0;
} else {
BlockEntity blockEntity = this.level.getBlockEntity(this);
if (blockEntity instanceof BlockEntityPistonArm) {
BlockEntityPistonArm arm = (BlockEntityPistonArm) blockEntity;
boolean powered = this.isPowered();
if (arm.powered != powered) {
this.level.getServer().getPluginManager().callEvent(new BlockPistonChangeEvent(this, powered ? 0 : 15, powered ? 15 : 0));
arm.powered = !arm.powered;
if (arm.chunk != null) {
arm.chunk.setChanged();
}
}
}
return type;
}
}
Aggregations