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.
  • Constructor Details

    • DiskOptimizedClipboard

      public DiskOptimizedClipboard(Region region, UUID uuid)
    • DiskOptimizedClipboard

      public DiskOptimizedClipboard(BlockVector3 dimensions)
    • DiskOptimizedClipboard

      public DiskOptimizedClipboard(BlockVector3 dimensions, File file)
    • DiskOptimizedClipboard

      public DiskOptimizedClipboard(File file)
  • Method Details

    • 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
    • createEntity

      @Nullable public Entity createEntity(Location location, BaseEntity entity)
      Description copied from interface: Extent
      Create an entity at the given location.
      Parameters:
      location - the location
      entity - the entity
      Returns:
      a reference to the created entity, or null if the entity could not be created
    • getEntities

      public List<? extends Entity> getEntities()
      Description copied from interface: Extent
      Get a list of all entities.

      If the extent is not wholly loaded (i.e. a world being simulated in the game will not have every chunk loaded), then this list may not be incomplete.

      Returns:
      a list of entities
    • getEntities

      public List<? extends Entity> getEntities(Region region)
      Description copied from interface: Extent
      Get a list of all entities within the given region.

      If the extent is not wholly loaded (i.e. a world being simulated in the game will not have every chunk loaded), then this list may not be incomplete.

      Parameters:
      region - the region in which entities must be contained
      Returns:
      a list of entities
    • removeEntity

      public void removeEntity(Entity entity)
      Description copied from interface: Clipboard
      Remove entity from clipboard.
    • removeEntity

      public void removeEntity(int x, int y, int z, UUID uuid)
      Description copied from interface: Extent
      Create an entity at the given location.
      Specified by:
      removeEntity in interface Extent
      Overrides:
      removeEntity in class LinearClipboard
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      uuid - the unique identifier of the entity