public abstract class AbstractWorldExporter extends java.lang.Object implements WorldExporter
WorldExporter
for block based platforms.
Created by Pepijn on 11-12-2016.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractWorldExporter.ExportResults |
Modifier and Type | Field and Description |
---|---|
static java.text.DateFormat |
DATE_FORMAT |
protected java.util.concurrent.Semaphore |
performingFixups |
protected Platform |
platform |
protected BlockBasedPlatformProvider |
platformProvider |
protected boolean |
populateSupported |
protected World2 |
world |
protected WorldExportSettings |
worldExportSettings |
Modifier | Constructor and Description |
---|---|
protected |
AbstractWorldExporter(World2 world,
WorldExportSettings worldExportSettings,
Platform platform) |
Modifier and Type | Method and Description |
---|---|
protected void |
applyWorldExportSettings(java.util.Collection<? extends Layer> layers) |
protected void |
blockPropertiesPass(MinecraftWorld minecraftWorld,
java.awt.Point regionCoords,
BlockBasedExportSettings exportSettings,
org.pepsoft.util.ProgressReceiver progressReceiver) |
protected ChunkFactory.ChunkCreationResult |
createChunk(Dimension dimension,
ChunkFactory chunkFactory,
java.util.Map<java.awt.Point,Tile> tiles,
int chunkX,
int chunkY,
boolean tileSelection,
java.util.Map<Layer,LayerExporter> exporters,
boolean ceiling) |
protected java.util.concurrent.ExecutorService |
createExecutorService(java.lang.String operation,
int jobCount) |
protected AbstractWorldExporter.ExportResults |
exportRegion(MinecraftWorld minecraftWorld,
Dimension dimension,
Dimension ceiling,
java.awt.Point regionCoords,
boolean tileSelection,
java.util.Map<Layer,LayerExporter> exporters,
java.util.Map<Layer,LayerExporter> ceilingExporters,
ChunkFactory chunkFactory,
ChunkFactory ceilingChunkFactory,
org.pepsoft.util.ProgressReceiver progressReceiver) |
protected AbstractWorldExporter.ExportResults |
firstPass(MinecraftWorld minecraftWorld,
Dimension dimension,
java.awt.Point regionCoords,
java.util.Map<java.awt.Point,Tile> tiles,
boolean tileSelection,
java.util.Map<Layer,LayerExporter> exporters,
ChunkFactory chunkFactory,
boolean ceiling,
org.pepsoft.util.ProgressReceiver progressReceiver) |
protected java.util.Map<Layer,LayerExporter> |
getExportersForRegion(Dimension dimension,
java.awt.Point regionCoords) |
protected int |
getIntHeightAt(int dim,
int x,
int y) |
protected int |
getWaterLevelAt(int dim,
int x,
int y) |
World2 |
getWorld()
Get the world that is being or has been exported.
|
protected boolean |
isReadyForFixups(java.util.Set<java.awt.Point> regionsToExport,
java.util.Set<java.awt.Point> exportedRegions,
java.awt.Point coords) |
protected void |
logLayers(Dimension dimension,
org.pepsoft.worldpainter.vo.EventVO event,
java.lang.String prefix) |
protected void |
moveEntityTileData(Chunk toChunk,
Chunk fromChunk,
int x,
int y,
int z,
int dy)
Move tile entity data from a source chunk to a potentially different height in a destination chunk.
|
protected ChunkFactory.Stats |
parallelExportRegions(Dimension dimension,
java.io.File worldDir,
org.pepsoft.util.ProgressReceiver progressReceiver)
Export a dimension by exporting each region (512 block by 512 block area)
separately and in parallel as much as possible, taking into account the
number of CPU cores and available memory.
|
protected void |
performFixups(java.io.File worldDir,
Dimension dimension,
ChunkFactory.Stats stats,
org.pepsoft.util.ProgressReceiver progressReceiver,
java.util.Map<java.awt.Point,java.util.List<Fixup>> fixups) |
protected void |
performFixupsIfNecessary(java.io.File worldDir,
Dimension dimension,
java.util.Set<java.awt.Point> regionsToExport,
java.util.Map<java.awt.Point,java.util.List<Fixup>> fixups,
java.util.Set<java.awt.Point> exportedRegions,
ChunkFactory.Stats stats,
org.pepsoft.util.ProgressReceiver progressReceiver)
Apply all fixups which can be applied because all surrounding regions
have been exported (or are not going to be), but only if another thread
is not already doing it
|
protected void |
restoreDimensionAfterExport(Dimension dimension,
java.lang.Object savedSettings)
Restores changes that were performed by
setupDimensionForExport(Dimension, Set) . |
protected java.util.List<Fixup> |
secondPass(java.util.List<Layer> secondaryPassLayers,
Dimension dimension,
MinecraftWorld minecraftWorld,
java.util.Map<Layer,LayerExporter> exporters,
java.util.Collection<Tile> tiles,
java.awt.Point regionCoords,
AbstractWorldExporter.ExportResults exportResults,
org.pepsoft.util.ProgressReceiver progressReceiver) |
java.io.File |
selectBackupDir(java.io.File worldDir)
Indicate into which directory the existing map, if any, will be backed up that is going to be exported into
worldDir . |
protected java.lang.Object |
setupDimensionForExport(Dimension dimension,
java.util.Set<java.awt.Point> selectedTiles) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
export, selectBackupDir
protected final World2 world
protected final BlockBasedPlatformProvider platformProvider
protected final java.util.concurrent.Semaphore performingFixups
protected final Platform platform
protected final WorldExportSettings worldExportSettings
protected final boolean populateSupported
public static final java.text.DateFormat DATE_FORMAT
protected AbstractWorldExporter(World2 world, WorldExportSettings worldExportSettings, Platform platform)
public World2 getWorld()
WorldExporter
getWorld
in interface WorldExporter
public java.io.File selectBackupDir(java.io.File worldDir) throws java.io.IOException
WorldExporter
worldDir
.selectBackupDir
in interface WorldExporter
worldDir
- The map directory into which the world would be exported.java.io.IOException
- If an I/O error occurs while determining the backup directory.protected ChunkFactory.Stats parallelExportRegions(Dimension dimension, java.io.File worldDir, org.pepsoft.util.ProgressReceiver progressReceiver) throws org.pepsoft.util.ProgressReceiver.OperationCancelled
If an exception occurs and a progress receiver has been specified, the exception is reported to the progress receiver and the export continues. If there is no progress receiver, the export is aborted and the first exception rethrown.
org.pepsoft.util.ProgressReceiver.OperationCancelled
- If the progress receiver threw an
OperationCancelled
exception.java.lang.RuntimeException
- If an exception occurs during the export and no
progress receiver has been specified.protected final void logLayers(Dimension dimension, org.pepsoft.worldpainter.vo.EventVO event, java.lang.String prefix)
protected java.lang.Object setupDimensionForExport(Dimension dimension, java.util.Set<java.awt.Point> selectedTiles)
protected void restoreDimensionAfterExport(Dimension dimension, java.lang.Object savedSettings)
setupDimensionForExport(Dimension, Set)
.dimension
- The dimension to restore.savedSettings
- The object that was returned from setupDimensionForExport(Dimension, Set)
.protected java.util.Map<Layer,LayerExporter> getExportersForRegion(Dimension dimension, java.awt.Point regionCoords)
protected AbstractWorldExporter.ExportResults firstPass(MinecraftWorld minecraftWorld, Dimension dimension, java.awt.Point regionCoords, java.util.Map<java.awt.Point,Tile> tiles, boolean tileSelection, java.util.Map<Layer,LayerExporter> exporters, ChunkFactory chunkFactory, boolean ceiling, org.pepsoft.util.ProgressReceiver progressReceiver) throws org.pepsoft.util.ProgressReceiver.OperationCancelled
org.pepsoft.util.ProgressReceiver.OperationCancelled
protected java.util.List<Fixup> secondPass(java.util.List<Layer> secondaryPassLayers, Dimension dimension, MinecraftWorld minecraftWorld, java.util.Map<Layer,LayerExporter> exporters, java.util.Collection<Tile> tiles, java.awt.Point regionCoords, AbstractWorldExporter.ExportResults exportResults, org.pepsoft.util.ProgressReceiver progressReceiver) throws org.pepsoft.util.ProgressReceiver.OperationCancelled
org.pepsoft.util.ProgressReceiver.OperationCancelled
protected void blockPropertiesPass(MinecraftWorld minecraftWorld, java.awt.Point regionCoords, BlockBasedExportSettings exportSettings, org.pepsoft.util.ProgressReceiver progressReceiver) throws org.pepsoft.util.ProgressReceiver.OperationCancelled
org.pepsoft.util.ProgressReceiver.OperationCancelled
protected AbstractWorldExporter.ExportResults exportRegion(MinecraftWorld minecraftWorld, Dimension dimension, Dimension ceiling, java.awt.Point regionCoords, boolean tileSelection, java.util.Map<Layer,LayerExporter> exporters, java.util.Map<Layer,LayerExporter> ceilingExporters, ChunkFactory chunkFactory, ChunkFactory ceilingChunkFactory, org.pepsoft.util.ProgressReceiver progressReceiver)
protected ChunkFactory.ChunkCreationResult createChunk(Dimension dimension, ChunkFactory chunkFactory, java.util.Map<java.awt.Point,Tile> tiles, int chunkX, int chunkY, boolean tileSelection, java.util.Map<Layer,LayerExporter> exporters, boolean ceiling)
protected boolean isReadyForFixups(java.util.Set<java.awt.Point> regionsToExport, java.util.Set<java.awt.Point> exportedRegions, java.awt.Point coords)
protected void performFixupsIfNecessary(java.io.File worldDir, Dimension dimension, java.util.Set<java.awt.Point> regionsToExport, java.util.Map<java.awt.Point,java.util.List<Fixup>> fixups, java.util.Set<java.awt.Point> exportedRegions, ChunkFactory.Stats stats, org.pepsoft.util.ProgressReceiver progressReceiver) throws org.pepsoft.util.ProgressReceiver.OperationCancelled
org.pepsoft.util.ProgressReceiver.OperationCancelled
protected void performFixups(java.io.File worldDir, Dimension dimension, ChunkFactory.Stats stats, org.pepsoft.util.ProgressReceiver progressReceiver, java.util.Map<java.awt.Point,java.util.List<Fixup>> fixups) throws org.pepsoft.util.ProgressReceiver.OperationCancelled
org.pepsoft.util.ProgressReceiver.OperationCancelled
protected void moveEntityTileData(Chunk toChunk, Chunk fromChunk, int x, int y, int z, int dy)
toChunk
- The destination chunk.fromChunk
- The source chunk.x
- The X coordinate.y
- The Y coordinate in the destination chunk.z
- The Z coordinate.dy
- The delta to subtract from y
to obtain the Y coordinate in the source chunk. In other
words: how many blocks to move the tile entity data up.protected final java.util.concurrent.ExecutorService createExecutorService(java.lang.String operation, int jobCount)
protected final void applyWorldExportSettings(java.util.Collection<? extends Layer> layers)
protected final int getIntHeightAt(int dim, int x, int y)
protected final int getWaterLevelAt(int dim, int x, int y)