use of org.lanternpowered.server.block.LanternScheduledBlockUpdate in project LanternServer by LanternPowered.
the class LanternChunk method pulse.
public void pulse() {
// The update entry
LanternScheduledBlockUpdate update;
while ((update = this.scheduledBlockUpdateQueue.peek()) != null && update.getTicks() <= 0) {
// Remove the entry from the queue
this.scheduledBlockUpdateQueue.poll();
// TODO: Update
}
final CauseStack causeStack = CauseStack.current();
// Add the chunk that is being pulsed
causeStack.pushCause(this);
getTileEntities().forEach(tileEntity -> {
// Add the tile entity to the cause
causeStack.pushCause(tileEntity);
try {
((LanternTileEntity) tileEntity).pulse();
} catch (Throwable t) {
final Vector3i pos = tileEntity.getLocation().getBlockPosition();
Lantern.getLogger().error("Failed to pulse TileEntity at ({};{};{})", pos.getX(), pos.getY(), pos.getZ(), t);
} finally {
// Pop the tile entity
causeStack.popCause();
}
});
// Pop the chunk
causeStack.popCause();
}
use of org.lanternpowered.server.block.LanternScheduledBlockUpdate in project LanternServer by LanternPowered.
the class LanternChunk method addScheduledUpdate.
@Override
public ScheduledBlockUpdate addScheduledUpdate(int x, int y, int z, int priority, int ticks) {
checkVolumeBounds(x, y, z);
final int entryId = this.scheduledBlockUpdateCounter.getAndIncrement();
final Location<World> location = new Location<>(this.world, new Vector3i(x, y, z));
final LanternScheduledBlockUpdate update = new LanternScheduledBlockUpdate(entryId, location, ticks, priority);
this.scheduledBlockUpdateQueue.add(update);
return update;
}
Aggregations