Class Regenerator<IChunkAccess,ProtoChunk extends IChunkAccess,Chunk extends IChunkAccess,ChunkStatus extends Regenerator.ChunkStatusWrapper<IChunkAccess>>
java.lang.Object
com.fastasyncworldedit.bukkit.adapter.Regenerator<IChunkAccess,ProtoChunk,Chunk,ChunkStatus>
- Type Parameters:
IChunkAccess
- the type of theIChunkAccess
of the current Minecraft implementationProtoChunk
- the type of theProtoChunk
of the current Minecraft implementationChunk
- the type of theChunk
of the current Minecraft implementationChunkStatus
- the type of theChunkStatusWrapper
wrapping theChunkStatus
enum
public abstract class Regenerator<IChunkAccess,ProtoChunk extends IChunkAccess,Chunk extends IChunkAccess,ChunkStatus extends Regenerator.ChunkStatusWrapper<IChunkAccess>>
extends Object
Represents an abstract regeneration handler.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This class is used to wrap the ChunkStatus of the current Minecraft implementation and as the implementation to execute a chunk generation step.static enum
static class
static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Map<ChunkStatus,
Regenerator.Concurrency> protected boolean
protected final com.sk89q.worldedit.world.RegenOptions
protected final World
protected final com.sk89q.worldedit.regions.Region
protected long
protected final com.sk89q.worldedit.extent.Extent
-
Constructor Summary
ConstructorDescriptionRegenerator
(World originalBukkitWorld, com.sk89q.worldedit.regions.Region region, com.sk89q.worldedit.extent.Extent target, com.sk89q.worldedit.world.RegenOptions options) Initializes an abstract regeneration handler. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
cleanup()
Implement the cleanup of all the mess that is created during the regeneration process (initNewWorld() and generate()).This function must not throw any exceptions.protected abstract Chunk
createChunk
(ProtoChunk protoChunk) Implement the convertion of aProtoChunk
to aChunk
here.protected abstract ProtoChunk
createProtoChunk
(int x, int z) Implement the initialization of aProtoChunk
here.protected abstract List<BlockPopulator>
Return a list ofBlockPopulator
used to populate the original world here.protected Chunk
getChunkAt
(int x, int z) Returns theChunk
at the given chunk coordinates.protected abstract ChunkStatus
Return theChunkStatus.FULL
here.protected ProtoChunk
getProtoChunkAt
(int x, int z) Returns theProtoChunk
at the given chunk coordinates.protected abstract boolean
Implement the creation of the seperate world in here.protected abstract com.fastasyncworldedit.core.queue.IChunkCache<com.fastasyncworldedit.core.queue.IChunkGet>
Implement the initialization anIChunkCache<IChunkGet>
here.protected abstract void
populate
(Chunk chunk, Random random, BlockPopulator pop) Implement the population of theChunk
with the given chunk random andBlockPopulator
here.protected abstract boolean
prepare()
Implement the preparation process in here.boolean
Regenerates the selectedRegion
.
-
Field Details
-
originalBukkitWorld
-
region
protected final com.sk89q.worldedit.regions.Region region -
target
protected final com.sk89q.worldedit.extent.Extent target -
options
protected final com.sk89q.worldedit.world.RegenOptions options -
chunkStati
protected final Map<ChunkStatus extends Regenerator.ChunkStatusWrapper<IChunkAccess>,Regenerator.Concurrency> chunkStati -
generateConcurrent
protected boolean generateConcurrent -
seed
protected long seed
-
-
Constructor Details
-
Regenerator
public Regenerator(World originalBukkitWorld, com.sk89q.worldedit.regions.Region region, com.sk89q.worldedit.extent.Extent target, com.sk89q.worldedit.world.RegenOptions options) Initializes an abstract regeneration handler.- Parameters:
originalBukkitWorld
- the Bukkit world containing all the information on how to regenerate the {code Region}region
- the selection to regeneratetarget
- the targetExtent
to paste the regenerated blocks intooptions
- the options to used while regenerating and pasting into the targetExtent
-
-
Method Details
-
regenerate
Regenerates the selectedRegion
.- Returns:
- whether or not the regeneration process was successful
- Throws:
Exception
- when something goes terribly wrong
-
getProtoChunkAt
Returns theProtoChunk
at the given chunk coordinates.- Parameters:
x
- the chunk x coordinatez
- the chunk z coordinate- Returns:
- the
ProtoChunk
at the given chunk coordinates or null if it is not part of the regeneration process or has not been initialized yet.
-
getChunkAt
Returns theChunk
at the given chunk coordinates.- Parameters:
x
- the chunk x coordinatez
- the chunk z coordinate- Returns:
- the
Chunk
at the given chunk coordinates or null if it is not part of the regeneration process or has not been converted yet.
-
prepare
protected abstract boolean prepare()Implement the preparation process in here. DO NOT instanciate any variable here that require the cleanup function. This function is for gathering further information before initializing a new world.
Fields required to be initialized: chunkStati, seed
For chunkStati also see {code ChunkStatusWrapper}.
- Returns:
- whether or not the preparation process was successful
-
initNewWorld
Implement the creation of the seperate world in here.Fields required to be initialized: generateConcurrent
- Returns:
- true if everything went fine, otherwise false. When false is returned the Regenerator halts the regeneration process and calls the cleanup function.
- Throws:
Exception
- When the implementation of this method throws and exception the Regenerator halts the regeneration process and calls the cleanup function.
-
cleanup
protected abstract void cleanup()Implement the cleanup of all the mess that is created during the regeneration process (initNewWorld() and generate()).This function must not throw any exceptions. -
createProtoChunk
Implement the initialization of aProtoChunk
here.- Parameters:
x
- the x coorinate of theProtoChunk
to createz
- the z coorinate of theProtoChunk
to create- Returns:
- an initialized
ProtoChunk
-
createChunk
Implement the convertion of aProtoChunk
to aChunk
here.- Parameters:
protoChunk
- theProtoChunk
to be converted to aChunk
- Returns:
- the converted
Chunk
-
getFullChunkStatus
Return theChunkStatus.FULL
here. ChunkStatus.FULL is the last step of vanilla chunk generation.- Returns:
ChunkStatus.FULL
-
getBlockPopulators
Return a list ofBlockPopulator
used to populate the original world here.- Returns:
ChunkStatus.FULL
-
populate
Implement the population of theChunk
with the given chunk random andBlockPopulator
here.- Parameters:
chunk
- theChunk
to populaterandom
- the chunk random to use for populationpop
- theBlockPopulator
to use
-
initSourceQueueCache
protected abstract com.fastasyncworldedit.core.queue.IChunkCache<com.fastasyncworldedit.core.queue.IChunkGet> initSourceQueueCache()Implement the initialization anIChunkCache<IChunkGet>
here. Use will need thegetChunkAt
function- Returns:
- an initialized
IChunkCache<IChunkGet>
-