Class ThreadUnsafeCharBlocks

java.lang.Object
com.fastasyncworldedit.core.queue.implementation.blocks.ThreadUnsafeCharBlocks
All Implemented Interfaces:
IBlocks, IChunkSet, Trimable, OutputExtent

public class ThreadUnsafeCharBlocks extends Object implements IChunkSet, IBlocks
Equivalent to CharSetBlocks without any attempt to make thread-safe for improved performance. This is currently only used as a "copy" of CharSetBlocks to provide to IBatchProcessor instances for processing without overlapping the continuing edit.
Since:
2.6.2
  • Method Details

    • hasSection

      public boolean hasSection(int layer)
      Description copied from interface: IBlocks
      Returns if the chunk has a BLOCKS section at the given layer. May not be indicative of presence of entities, tile entites, biomes, etc.
      Specified by:
      hasSection in interface IBlocks
      Parameters:
      layer - chunk section layer
      Returns:
      if blocks/a block section is present
    • load

      public char[] load(int layer)
      Description copied from interface: IBlocks
      Obtain the specified chunk section stored as an array of ordinals. Uses normal minecraft chunk-section position indices (length 4096). Operations synchronises on the section and will load the section into memory if not present. For chunk GET operations, this will load the data from the world. For chunk SET, this will create a new empty array.
      Specified by:
      load in interface IBlocks
      Parameters:
      layer - chunk section layer (may be negative)
      Returns:
      char array of ordinals of the chunk section
    • loadIfPresent

      @Nullable public @org.jetbrains.annotations.Nullable char[] loadIfPresent(int layer)
      Description copied from interface: IBlocks
      Obtain the specified chunk section stored as an array of ordinals if present or null. Uses normal minecraft chunk-section position indices (length 4096). Does not synchronise to the section layer as it will not attempt to load into memory.
      Specified by:
      loadIfPresent in interface IBlocks
      Parameters:
      layer - chunk section layer (may be negative)
      Returns:
      char array of ordinals of the chunk section if present
    • getTiles

      public Map<BlockVector3,CompoundTag> getTiles()
      Specified by:
      getTiles in interface IBlocks
    • getTile

      public CompoundTag getTile(int x, int y, int z)
      Specified by:
      getTile in interface IBlocks
    • getEntities

      public Set<CompoundTag> getEntities()
      Specified by:
      getEntities in interface IBlocks
    • getHeightMaps

      public Map<HeightMapType,int[]> getHeightMaps()
      Specified by:
      getHeightMaps in interface IChunkSet
    • removeSectionLighting

      public void removeSectionLighting(int layer, boolean sky)
      Specified by:
      removeSectionLighting in interface IBlocks
    • trim

      public boolean trim(boolean aggressive, int layer)
      Specified by:
      trim in interface IBlocks
    • getSectionCount

      public int getSectionCount()
      Description copied from interface: IBlocks
      Get the number of stored sections
      Specified by:
      getSectionCount in interface IBlocks
    • getMaxSectionPosition

      public int getMaxSectionPosition()
      Description copied from interface: IBlocks
      Get the highest layer position stored in the internal chunk. For 1.16 and below, always returns 15. For 1.17 and above, may not return a value correct to the world if this is a IChunkSet instance, which defaults to 15. For extended height worlds, this will only return over 15 if blocks are stored outside the default range.
      Specified by:
      getMaxSectionPosition in interface IBlocks
    • getMinSectionPosition

      public int getMinSectionPosition()
      Description copied from interface: IBlocks
      Get the lowest layer position stored in the internal chunk. For 1.16 and below, always returns 0. For 1.17 and above, may not return a value correct to the world if this is a IChunkSet instance, which defaults to 0. For extended height worlds, this will only return under 0 if blocks are stored outside the default range.
      Specified by:
      getMinSectionPosition in interface IBlocks
    • get

      public char get(int x, int y, int z)
    • getBiomeType

      public BiomeType getBiomeType(int x, int y, int z)
      Specified by:
      getBiomeType in interface IBlocks
    • getBlock

      public BlockState getBlock(int x, int y, int z)
      Specified by:
      getBlock in interface IBlocks
    • setBiome

      public boolean setBiome(int x, int y, int z, BiomeType biome)
      Specified by:
      setBiome in interface IChunkSet
      Specified by:
      setBiome in interface OutputExtent
    • 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.

      Specified by:
      setBiome in interface IChunkSet
      Specified by:
      setBiome in interface OutputExtent
      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)
    • set

      public void set(int x, int y, int z, char value)
    • setBlock

      public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T holder)
      Specified by:
      setBlock in interface IChunkSet
      Specified by:
      setBlock in interface OutputExtent
    • setBlocks

      public void setBlocks(int layer, char[] data)
      Specified by:
      setBlocks in interface IChunkSet
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface IChunkSet
    • setTile

      public boolean setTile(int x, int y, int z, CompoundTag tile)
      Specified by:
      setTile in interface IChunkSet
      Specified by:
      setTile in interface OutputExtent
    • setBlockLight

      public void setBlockLight(int x, int y, int z, int value)
      Specified by:
      setBlockLight in interface IChunkSet
      Specified by:
      setBlockLight in interface OutputExtent
    • setSkyLight

      public void setSkyLight(int x, int y, int z, int value)
      Specified by:
      setSkyLight in interface IChunkSet
      Specified by:
      setSkyLight in interface OutputExtent
    • setHeightMap

      public void setHeightMap(HeightMapType type, int[] heightMap)
      Specified by:
      setHeightMap in interface IChunkSet
      Specified by:
      setHeightMap in interface OutputExtent
    • setLightLayer

      public void setLightLayer(int layer, char[] toSet)
      Specified by:
      setLightLayer in interface IChunkSet
    • setSkyLightLayer

      public void setSkyLightLayer(int layer, char[] toSet)
      Specified by:
      setSkyLightLayer in interface IChunkSet
    • setFullBright

      public void setFullBright(int layer)
      Specified by:
      setFullBright in interface IChunkSet
    • setEntity

      public void setEntity(CompoundTag tag)
      Specified by:
      setEntity in interface IChunkSet
    • removeEntity

      public void removeEntity(UUID uuid)
      Specified by:
      removeEntity in interface IChunkSet
    • setFastMode

      public void setFastMode(boolean fastMode)
      Specified by:
      setFastMode in interface IChunkSet
    • isFastMode

      public boolean isFastMode()
      Specified by:
      isFastMode in interface IChunkSet
    • setBitMask

      public void setBitMask(int bitMask)
      Specified by:
      setBitMask in interface IChunkSet
    • getBitMask

      public int getBitMask()
      Specified by:
      getBitMask in interface IBlocks
      Specified by:
      getBitMask in interface IChunkSet
    • getEntityRemoves

      public Set<UUID> getEntityRemoves()
      Specified by:
      getEntityRemoves in interface IChunkSet
    • getBiomes

      public BiomeType[][] getBiomes()
      Description copied from interface: IChunkSet
      This will return only biomes SET to the EXTENT or QUEUE. This will NOT return the current biomes in the world. This is used for history purposes.
      Specified by:
      getBiomes in interface IChunkSet
      Returns:
      Array of biomes set
    • hasBiomes

      public boolean hasBiomes()
      Specified by:
      hasBiomes in interface IChunkSet
    • getLight

      public char[][] getLight()
      Specified by:
      getLight in interface IChunkSet
    • getSkyLight

      public char[][] getSkyLight()
      Specified by:
      getSkyLight in interface IChunkSet
    • hasLight

      public boolean hasLight()
      Specified by:
      hasLight in interface IChunkSet
    • reset

      public IChunkSet reset()
      Specified by:
      reset in interface IBlocks
      Specified by:
      reset in interface IChunkSet
    • hasBiomes

      public boolean hasBiomes(int layer)
      Description copied from interface: IChunkSet
      If the given layer has biomes stored to be set to the world. Can be negative
      Specified by:
      hasBiomes in interface IChunkSet
      Parameters:
      layer - layer to check
      Returns:
      if the layer has biomes stored to be set to the world
    • createCopy

      public IChunkSet createCopy()
      Description copied from interface: IChunkSet
      Create an entirely distinct copy of this SET instance. All mutable data must be copied to sufficiently prevent leakage between the copy and the original.
      Specified by:
      createCopy in interface IChunkSet
      Returns:
      distinct new instance
    • trim

      public boolean trim(boolean aggressive)
      Description copied from interface: Trimable
      Trims the object, reducing its memory footprint.
      Specified by:
      trim in interface Trimable
      Parameters:
      aggressive - if trimming should be aggressive e.g., Not returning early when the first element cannot be trimmed
      Returns:
      if this object is empty at the end of the trim, and can therefore be deleted