use of org.pepsoft.worldpainter.gardenofeden.GardenExporter in project WorldPainter by Captain-Chaos.
the class AbstractWorldExporter method secondPass.
protected List<Fixup> secondPass(List<Layer> secondaryPassLayers, Dimension dimension, MinecraftWorld minecraftWorld, Map<Layer, LayerExporter> exporters, Collection<Tile> tiles, Point regionCoords, ProgressReceiver progressReceiver) throws OperationCancelled {
// Apply other secondary pass layers
if (logger.isDebugEnabled()) {
logger.debug("Start of second pass for region {},{}", regionCoords.x, regionCoords.y);
}
int layerCount = secondaryPassLayers.size(), counter = 0;
Rectangle area = new Rectangle((regionCoords.x << 9) - 16, (regionCoords.y << 9) - 16, 544, 544);
Rectangle exportedArea = new Rectangle((regionCoords.x << 9), (regionCoords.y << 9), 512, 512);
List<Fixup> fixups = new ArrayList<>();
// boolean frost = false;
for (Layer layer : secondaryPassLayers) {
// if (layer instanceof Frost) {
// frost = true;
// continue;
// }
@SuppressWarnings("unchecked") SecondPassLayerExporter exporter = (SecondPassLayerExporter) exporters.get(layer);
if (logger.isDebugEnabled()) {
logger.debug("Exporting layer {} for region {},{}", layer, regionCoords.x, regionCoords.y);
}
if (progressReceiver != null) {
if (minecraftWorld instanceof InvertedWorld) {
progressReceiver.setMessage("Exporting layer " + layer + " for ceiling");
} else {
progressReceiver.setMessage("Exporting layer " + layer);
}
}
List<Fixup> layerFixups = exporter.render(dimension, area, exportedArea, minecraftWorld);
if (layerFixups != null) {
fixups.addAll(layerFixups);
}
if (progressReceiver != null) {
counter++;
progressReceiver.setProgress((float) counter / layerCount);
}
}
// Garden / seeds first and second pass
GardenExporter gardenExporter = new GardenExporter();
Set<Seed> firstPassProcessedSeeds = new HashSet<>();
Set<Seed> secondPassProcessedSeeds = new HashSet<>();
tiles.stream().filter(tile -> tile.getLayers().contains(GardenCategory.INSTANCE)).forEach(tile -> {
gardenExporter.firstPass(dimension, tile, minecraftWorld, firstPassProcessedSeeds);
gardenExporter.secondPass(dimension, tile, minecraftWorld, secondPassProcessedSeeds);
});
// elegant
if ((dimension.getDim() == 0) && world.isCreateGoodiesChest()) {
Point goodiesPoint = (Point) world.getSpawnPoint().clone();
goodiesPoint.translate(3, 3);
int height = Math.min(dimension.getIntHeightAt(goodiesPoint) + 1, dimension.getMaxHeight() - 1);
minecraftWorld.setMaterialAt(goodiesPoint.x, goodiesPoint.y, height, Material.CHEST_NORTH);
Chunk chunk = minecraftWorld.getChunk(goodiesPoint.x >> 4, goodiesPoint.y >> 4);
if ((chunk != null) && (chunk.getTileEntities() != null)) {
Chest goodiesChest = createGoodiesChest();
goodiesChest.setX(goodiesPoint.x);
goodiesChest.setY(height);
goodiesChest.setZ(goodiesPoint.y);
chunk.getTileEntities().add(goodiesChest);
}
}
if (logger.isDebugEnabled()) {
logger.debug("End of second pass for region {},{}", regionCoords.x, regionCoords.y);
}
return fixups;
}
Aggregations