Search in sources :

Example 1 with BlockUpdateEntry

use of cn.nukkit.utils.BlockUpdateEntry in project Nukkit by Nukkit.

the class BlockUpdateScheduler method perform.

private void perform(long tick) {
    try {
        lastTick = tick;
        Set<BlockUpdateEntry> updates = pendingUpdates = queuedUpdates.remove(tick);
        if (updates != null) {
            for (BlockUpdateEntry entry : updates) {
                Vector3 pos = entry.pos;
                if (level.isChunkLoaded(NukkitMath.floorDouble(pos.x) >> 4, NukkitMath.floorDouble(pos.z) >> 4)) {
                    Block block = level.getBlock(entry.pos);
                    if (Block.equals(block, entry.block, false)) {
                        block.onUpdate(level.BLOCK_UPDATE_SCHEDULED);
                    }
                } else {
                    level.scheduleUpdate(entry.block, entry.pos, 0);
                }
            }
        }
    } finally {
        pendingUpdates = null;
    }
}
Also used : BlockUpdateEntry(cn.nukkit.utils.BlockUpdateEntry) Block(cn.nukkit.block.Block) Vector3(cn.nukkit.math.Vector3)

Aggregations

Block (cn.nukkit.block.Block)1 Vector3 (cn.nukkit.math.Vector3)1 BlockUpdateEntry (cn.nukkit.utils.BlockUpdateEntry)1