use of io.xol.chunkstories.api.util.IterableIterator in project chunkstories by Hugobros3.
the class WorldServer method getPlayers.
public IterableIterator<Player> getPlayers() {
return new IterableIterator<Player>() {
Iterator<Player> players = server.getConnectedPlayers();
Player next = null;
@Override
public boolean hasNext() {
while (next == null && players.hasNext()) {
next = players.next();
if (// Require the player to be spawned within this world.
next.getWorld() != null && next.getWorld().equals(WorldServer.this))
break;
else
next = null;
}
return next != null;
}
@Override
public Player next() {
Player player = next;
next = null;
return player;
}
};
}
use of io.xol.chunkstories.api.util.IterableIterator in project chunkstories by Hugobros3.
the class ChunkRenderDataHolder method renderExtras.
public void renderExtras(RenderingInterface renderingInterface) {
noDrawDeleteConflicts.acquireUninterruptibly();
if (this.currentData != null) {
// For each type of voxel that requires dynamic rendering...
for (DynamicallyRenderedVoxelType drvt : this.currentData.dynamicVoxelTypes) {
VoxelDynamicRenderer voxelDynamicRenderer = drvt.renderer;
// Build an iterator for the list of indexes that use that renderer
IterableIterator<ChunkCell> relevantCellsIterator = new IterableIterator<ChunkCell>() {
Iterator<Integer> iindex = drvt.indexes.iterator();
ChunkCell cvc = null;
@Override
public boolean hasNext() {
while (iindex.hasNext()) {
if (cvc != null)
return true;
int index = iindex.next();
cvc = chunk.peek(index / 1024, (index / 32) % 32, index % 32);
}
if (cvc != null)
return true;
return false;
}
@Override
public ChunkCell next() {
ChunkCell cvr = cvc;
cvc = null;
return cvr;
}
};
// And we call the renderer
voxelDynamicRenderer.renderVoxels(renderingInterface, relevantCellsIterator);
}
}
noDrawDeleteConflicts.release();
}
Aggregations