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 the IChunkAccess of the current Minecraft implementation
ProtoChunk - the type of the ProtoChunk of the current Minecraft implementation
Chunk - the type of the Chunk of the current Minecraft implementation
ChunkStatus - the type of the ChunkStatusWrapper wrapping the ChunkStatus enum

public abstract class Regenerator<IChunkAccess,ProtoChunk extends IChunkAccess,Chunk extends IChunkAccess,ChunkStatus extends Regenerator.ChunkStatusWrapper<IChunkAccess>> extends Object
Represents an abstract regeneration handler.
  • Field Details

    • originalBukkitWorld

      protected final World 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

    • 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 regenerate
      target - the target Extent to paste the regenerated blocks into
      options - the options to used while regenerating and pasting into the target Extent
  • Method Details

    • regenerate

      public boolean regenerate() throws Exception
      Regenerates the selected Region.
      Returns:
      whether or not the regeneration process was successful
      Throws:
      Exception - when something goes terribly wrong
    • getProtoChunkAt

      protected ProtoChunk getProtoChunkAt(int x, int z)
      Returns the ProtoChunk at the given chunk coordinates.
      Parameters:
      x - the chunk x coordinate
      z - 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

      protected Chunk getChunkAt(int x, int z)
      Returns the Chunk at the given chunk coordinates.
      Parameters:
      x - the chunk x coordinate
      z - 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

      protected abstract boolean initNewWorld() throws Exception
      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

      protected abstract ProtoChunk createProtoChunk(int x, int z)
      Implement the initialization of a ProtoChunk here.
      Parameters:
      x - the x coorinate of the ProtoChunk to create
      z - the z coorinate of the ProtoChunk to create
      Returns:
      an initialized ProtoChunk
    • createChunk

      protected abstract Chunk createChunk(ProtoChunk protoChunk)
      Implement the convertion of a ProtoChunk to a Chunk here.
      Parameters:
      protoChunk - the ProtoChunk to be converted to a Chunk
      Returns:
      the converted Chunk
    • getFullChunkStatus

      protected abstract ChunkStatus getFullChunkStatus()
      Return the ChunkStatus.FULL here. ChunkStatus.FULL is the last step of vanilla chunk generation.
      Returns:
      ChunkStatus.FULL
    • getBlockPopulators

      protected abstract List<BlockPopulator> getBlockPopulators()
      Return a list of BlockPopulator used to populate the original world here.
      Returns:
      ChunkStatus.FULL
    • populate

      protected abstract void populate(Chunk chunk, Random random, BlockPopulator pop)
      Implement the population of the Chunk with the given chunk random and BlockPopulator here.
      Parameters:
      chunk - the Chunk to populate
      random - the chunk random to use for population
      pop - the BlockPopulator to use
    • initSourceQueueCache

      protected abstract com.fastasyncworldedit.core.queue.IChunkCache<com.fastasyncworldedit.core.queue.IChunkGet> initSourceQueueCache()
      Implement the initialization an IChunkCache<IChunkGet> here. Use will need the getChunkAt function
      Returns:
      an initialized IChunkCache<IChunkGet>