use of cn.nukkit.entity.item.EntityMinecartAbstract in project Nukkit by Nukkit.
the class BlockRailDetector method updateState.
protected void updateState() {
boolean wasPowered = isActive();
boolean isPowered = false;
for (Entity entity : level.getNearbyEntities(new SimpleAxisAlignedBB(getFloorX() + 0.125D, getFloorY(), getFloorZ() + 0.125D, getFloorX() + 0.875D, getFloorY() + 0.525D, getFloorZ() + 0.875D))) {
if (entity instanceof EntityMinecartAbstract) {
isPowered = true;
}
}
if (isPowered && !wasPowered) {
setActive(true);
level.scheduleUpdate(this, this, 0);
level.scheduleUpdate(this, this.down(), 0);
}
if (!isPowered && wasPowered) {
setActive(false);
level.scheduleUpdate(this, this, 0);
level.scheduleUpdate(this, this.down(), 0);
}
level.updateComparatorOutputLevel(this);
}
Aggregations