Class DiskOptimizedClipboard

All Implemented Interfaces:
Clipboard, Extent, InputExtent, OutputExtent, Closeable, Flushable, AutoCloseable, Iterable<BlockVector3>

public class DiskOptimizedClipboard extends LinearClipboard
A clipboard with disk backed storage. (lower memory + loads on crash) - Uses an auto closable RandomAccessFile for getting / setting id / data - I don't know how to reduce nbt / entities to O(2) complexity, so it is stored in memory.
  • Field Details

  • Constructor Details

    • DiskOptimizedClipboard

      public DiskOptimizedClipboard(Region region, UUID uuid)
      Creates a new DiskOptimizedClipboard for the given region. Creates or overwrites a file using the given UUID as a name.
    • DiskOptimizedClipboard

      @Deprecated(forRemoval=true, since="2.3.0") public DiskOptimizedClipboard(BlockVector3 dimensions)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use DiskOptimizedClipboard(Region, UUID) or DiskOptimizedClipboard(BlockVector3, File) to avoid creating a large number of clipboard files that won't be cleaned until `clipboard.delete-after-days` and a server restart.
      Creates a new DiskOptimizedClipboard with the given dimensions. Creates a new file with a random UUID name.
    • DiskOptimizedClipboard

      public DiskOptimizedClipboard(BlockVector3 dimensions, File file)
      New DiskOptimizedClipboard. If the file specified exists, then it will be completely overwritten. To load an existing clipboard, use DiskOptimizedClipboard(File).
    • DiskOptimizedClipboard

      @Deprecated(forRemoval=true, since="2.6.2") public DiskOptimizedClipboard(File file)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Will be made private, use loadFromFile(File)
      Load an existing file as a DiskOptimizedClipboard. The file MUST exist and MUST be created as a DiskOptimizedClipboard with data written to it.
    • DiskOptimizedClipboard

      @Deprecated(forRemoval=true, since="2.6.2") public DiskOptimizedClipboard(File file, int versionOverride)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Will be made private, use loadFromFile(File)
      Load an existing file as a DiskOptimizedClipboard. The file MUST exist and MUST be created as a DiskOptimizedClipboard with data written to it.
      Parameters:
      file - File to read from
      versionOverride - An override version to allow loading of older clipboards if required
  • Method Details

    • loadFromFile

      public static DiskOptimizedClipboard loadFromFile(File file)
      Attempt to load a file into a new DiskOptimizedClipboard instance. Will attempt to recover on version mismatch failure.
      Parameters:
      file - File to load
      Returns:
      new DiskOptimizedClipboard instance.
    • getURI

      public URI getURI()
    • getFile

      public File getFile()
    • hasBiomes

      public boolean hasBiomes()
      Description copied from interface: Clipboard
      Returns true if the clipboard has biome data. This can be checked since InputExtent.getBiome(BlockVector2) strongly suggests returning BiomeTypes.OCEAN instead of null if biomes aren't present. However, it might not be desired to set areas to ocean if the clipboard is defaulting to ocean, instead of having biomes explicitly set.
      Returns:
      true if the clipboard has biome data set
    • setBiome

      public boolean setBiome(BlockVector3 position, BiomeType biome)
      Description copied from interface: OutputExtent
      Set the biome.

      As implementation varies per Minecraft version, this may set more than this position's biome. On versions prior to 1.15, this will set the entire column. On later versions it will set the 4x4x4 cube.

      Parameters:
      position - the (x, y, z) location to set the biome at
      biome - the biome to set to
      Returns:
      true if the biome was successfully set (return value may not be accurate)
    • setBiome

      public boolean setBiome(int x, int y, int z, BiomeType biome)
    • setBiome

      public void setBiome(int index, BiomeType biome)
      Specified by:
      setBiome in class LinearClipboard
    • getBiome

      public BiomeType getBiome(int index)
      Specified by:
      getBiome in class LinearClipboard
    • streamBiomes

      public void streamBiomes(IntValueReader task)
      Description copied from class: LinearClipboard
      The locations provided are relative to the clipboard min
      Specified by:
      streamBiomes in class LinearClipboard
    • getBiomeType

      public BiomeType getBiomeType(int x, int y, int z)
    • getBiome

      public BiomeType getBiome(BlockVector3 position)
      Description copied from interface: InputExtent
      Get the biome at the given location.

      If there is no biome available, then the ocean biome should be returned.

      As implementation varies per Minecraft version, this may not exactly get this positions biome. On versions prior to 1.15, this will get the entire column. On later versions it will get the 4x4x4 cube's biome.

      Parameters:
      position - the (x, y, z) location to check the biome at
      Returns:
      the biome at the location
      See Also:
    • toClipboard

      public BlockArrayClipboard toClipboard()
    • setOrigin

      public void setOrigin(BlockVector3 origin)
      Description copied from interface: Clipboard
      Set the origin point from which the copy was made from.
      Specified by:
      setOrigin in interface Clipboard
      Overrides:
      setOrigin in class SimpleClipboard
      Parameters:
      origin - the origin
    • setOffset

      protected void setOffset(BlockVector3 offset)
      Overrides:
      setOffset in class SimpleClipboard
    • flush

      public void flush()
      Description copied from interface: Clipboard
      Flush the clipboard if appropriate. Only does something if using clipboard-on-disk. Blocking method and ensures all data is saved to disk for any further operation with the clipboard.
    • close

      public void close()
      Description copied from interface: Clipboard
      Close the clipboard. May not allow further reading of the clipboard if saved on disk.
    • getTileEntities

      public Collection<CompoundTag> getTileEntities()
      Specified by:
      getTileEntities in class LinearClipboard
    • getIndex

      public int getIndex(int x, int y, int z)
    • getBiomeIndex

      public int getBiomeIndex(int x, int y, int z)
    • getFullBlock

      public BaseBlock getFullBlock(int x, int y, int z)
    • getFullBlock

      public BaseBlock getFullBlock(int i)
      Specified by:
      getFullBlock in class LinearClipboard
    • getBlock

      public BlockState getBlock(int index)
      Specified by:
      getBlock in class LinearClipboard
    • getBlock

      public BlockState getBlock(int x, int y, int z)
    • setTile

      public boolean setTile(int x, int y, int z, CompoundTag tag)
    • setBlock

      public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block)
    • setBlock

      public <B extends BlockStateHolder<B>> boolean setBlock(int i, B block)
      Specified by:
      setBlock in class LinearClipboard