use of io.xol.chunkstories.world.WorldImplementation in project chunkstories by Hugobros3.
the class DebugWorldDataCommands method handleCommand.
@Override
public boolean handleCommand(CommandEmitter emitter, Command command, String[] arguments) {
if (command.getName().equals("chunk") && emitter.hasPermission("server.debug")) {
Player player = (Player) emitter;
emitter.sendMessage("#00FFD0" + player.getControlledEntity().getChunk());
return true;
} else if (command.getName().equals("region") && emitter.hasPermission("server.debug")) {
Player player = (Player) emitter;
Chunk chunk = player.getControlledEntity().getChunk();
if (chunk != null)
emitter.sendMessage("#00FFD0" + chunk.getRegion());
else
emitter.sendMessage("#00FFD0" + "not within a loaded chunk, so no parent region could be found.");
return true;
} else if (command.getName().equals("heightmap") && emitter.hasPermission("server.debug")) {
Heightmap sum;
if (arguments.length == 2) {
int x = Integer.parseInt(arguments[0]);
int z = Integer.parseInt(arguments[1]);
sum = server.getWorld().getRegionsSummariesHolder().getHeightmap(x, z);
} else {
Player player = (Player) emitter;
sum = player.getWorld().getRegionsSummariesHolder().getHeightmapLocation(player.getLocation());
}
emitter.sendMessage("#00FFD0" + sum);
return true;
} else if (command.getName().equals("heightmaps") && emitter.hasPermission("server.debug")) {
dumpLoadedHeightmap((WorldImplementation) server.getWorld(), emitter);
}
return false;
}
use of io.xol.chunkstories.world.WorldImplementation in project chunkstories by Hugobros3.
the class CulledEntitiesRenderer method renderEntities.
public int renderEntities(RenderingInterface renderer) {
((WorldImplementation) world).entitiesLock.readLock().lock();
// Sort them by type
Map<EntityDefinition, List<EntityRenderable>> renderableEntitiesTypes = new HashMap<EntityDefinition, List<EntityRenderable>>();
for (Entity entity : world.getAllLoadedEntities()) {
if (entity instanceof EntityRenderable) {
EntityRenderable entityRenderable = (EntityRenderable) entity;
List<EntityRenderable> entitiesOfThisType = renderableEntitiesTypes.get(entityRenderable.getDefinition());
if (entitiesOfThisType == null) {
renderableEntitiesTypes.put(entityRenderable.getDefinition(), new ArrayList<EntityRenderable>());
entitiesOfThisType = renderableEntitiesTypes.get(entityRenderable.getDefinition());
}
entitiesOfThisType.add(entityRenderable);
}
}
int entitiesRendered = 0;
for (Entry<EntityDefinition, List<EntityRenderable>> entry : renderableEntitiesTypes.entrySet()) {
List<EntityRenderable> entities = entry.getValue();
// Caches entity renderers until we f12
if (!entityRenderers.containsKey(entry.getKey()))
entityRenderers.put(entry.getKey(), entities.get(0).getEntityRenderer());
EntityRenderer<? extends EntityRenderable> entityRenderer = entityRenderers.get(entry.getKey());
if (entityRenderer == null)
continue;
try {
int e = entityRenderer.renderEntities(renderer, new EntitiesRendererIterator<>(renderer, entities));
entitiesRendered += e;
} catch (Throwable e) {
System.out.println("Exception rendering entities " + entities.get(0).getClass().getSimpleName() + " using " + entityRenderer.getClass().getSimpleName());
e.printStackTrace();
}
}
((WorldImplementation) world).entitiesLock.readLock().unlock();
return entitiesRendered;
}
Aggregations