Klasse ChunkPart

java.lang.Object
net.risingworld.api.objects.world.ChunkPart

public class ChunkPart extends Object
Represents a chunk part. A chunk part contains the terrain voxel data. Each chunk contains multiple chunk parts along y.
  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    static final int
    Y size (vertically) of a chunk part (in blocks)
    static final int
    Raw terrain data (stored as short) contains the actual terrain id (last 8 bits) and an optional strength value between 0 and 100 (first 8 bits).
    static final int
    When extracting the strength (STRENGTH_BITS), shift the result by this value to the right to get a value between 0 and 100.
    static final int
    Raw terrain data (stored as short) contains the actual terrain id (last 8 bits) and an optional strength value between 0 and 100 (first 8 bits).
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    boolean
     
    int
    Gets the x offset of the chunk.
    int
    Gets the y offset (vertical) of the chunk part.
    int
    Gets the z offset of the chunk.
    byte[]
    Gets the raw compressed terrrain data of this chunk part.
    short[]
    Gets the raw terrain data of this chunk part.
    int
    getRawTerrainID(int x, int y, int z)
    Gets the raw terrain id at a particular index.
    static int
    getRawTerrainIndex(int x, int y, int z)
     
    byte[]
    Gets the 3d terrain voxel data as a flattened byte array.
    int
    getTerrainID(int x, int y, int z)
    Gets the terrain id at a particular index.
    static int
    getTerrainIndex(int x, int y, int z)
     
    int
     
    boolean
    Gets whether or not this chunk was loaded from database.
    boolean
     

    Von Klasse geerbte Methoden java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Felddetails

    • SIZE_Y

      public static final int SIZE_Y
      Y size (vertically) of a chunk part (in blocks)
    • TERRAIN_BITS

      public static final int TERRAIN_BITS
      Raw terrain data (stored as short) contains the actual terrain id (last 8 bits) and an optional strength value between 0 and 100 (first 8 bits). TERRAIN_BITS represents the bitmask to extract the terrain ID from raw data (id & TERRAIN_BITS)
      Siehe auch:
    • STRENGTH_BITS

      public static final int STRENGTH_BITS
      Raw terrain data (stored as short) contains the actual terrain id (last 8 bits) and an optional strength value between 0 and 100 (first 8 bits). STRENGTH_BITS represents the bitmask to extract the strength value from raw data, but also remember to shift it to the right ((id & STRENGTH_BITS) >> STRENGTH_BITSHIFT)
      Siehe auch:
    • STRENGTH_BITSHIFT

      public static final int STRENGTH_BITSHIFT
      When extracting the strength (STRENGTH_BITS), shift the result by this value to the right to get a value between 0 and 100.
      To get a float, multiply the value by 0.01f
      Siehe auch:
  • Methodendetails

    • isValid

      public boolean isValid()
    • getChunkPositionX

      public int getChunkPositionX()
      Gets the x offset of the chunk.
      Gibt zurück:
      the x chunk offset.
    • getChunkPositionY

      public int getChunkPositionY()
      Gets the y offset (vertical) of the chunk part.
      Gibt zurück:
      the y chunk part offset.
    • getChunkPositionZ

      public int getChunkPositionZ()
      Gets the z offset of the chunk.
      Gibt zurück:
      the z chunk offset.
    • isLoadedFromDB

      public boolean isLoadedFromDB()
      Gets whether or not this chunk was loaded from database. This means the chunk had been modified in the past
      Gibt zurück:
      true if this is a modified chunk which was loaded from database, false if this is a naturally generated chunk.
    • getTerrain

      public byte[] getTerrain()
      Gets the 3d terrain voxel data as a flattened byte array.

      The array has a size of 32x64x32 (see Chunk.SIZE_X, SIZE_Y and Chunk.SIZE_Z). To access the array from an x, y and z coordinate, use getTerrainIndex(int, int, int)
      Gibt zurück:
      a byte array (copy) with size Chunk.SIZE_X * ChunkPart.SIZE_Y * Chunk.SIZE_Z representing the terrain voxel data (terrain ids).
    • getRawTerrain

      public short[] getRawTerrain()
      Gets the raw terrain data of this chunk part. The terrain data is a flattened array with the size of 36x68x36: Each dimension includes 2 neighbour chunk cells in each direction. The terrain data is stored as short (16 bit value), where the first 8 bits contain the terrain "strength modifier" (a value between 0 and 100) and the last 8 bits contain the actual terrain id

      To access the array from an x, y and z coordinate, use getRawTerrainIndex(int, int, int)
      Gibt zurück:
      a short array (copy) representing the raw (uncompressed) terrain data.
      Siehe auch:
    • getRawCompressedTerrain

      public byte[] getRawCompressedTerrain()
      Gets the raw compressed terrrain data of this chunk part.
      Gibt zurück:
      the raw compressed terrain data as a byte array (copy).
    • getTerrainID

      public int getTerrainID(int x, int y, int z)
      Gets the terrain id at a particular index.
      Parameter:
      x - the x coordinate in the chunk (between 0 and Chunk.SIZE_X).
      y - the y coordinate (vertical) in the chunk (between 0 and ChunkPart.SIZE_Y).
      z - the z coordinate in the chunk (between 0 and Chunk.SIZE_Z).
      Gibt zurück:
      the terrain id, containing the terrain material at the given position in the chunk.
    • getRawTerrainID

      public int getRawTerrainID(int x, int y, int z)
      Gets the raw terrain id at a particular index. Unlike the regular terrain id (see getTerrainID(int, int, int)), it also contains an optional strength value (which modifies the smoothness of the terrain). The terrain data is stored as 16 bit value, where the first 8 bits contain the terrain "strength modifier" (a value between 0 and 100) and the last 8 bits contain the actual terrain id
      Parameter:
      x - the x coordinate in the chunk (between 0 and Chunk.SIZE_X).
      y - the y coordinate (vertical) in the chunk (between 0 and ChunkPart.SIZE_Y).
      z - the z coordinate in the chunk (between 0 and Chunk.SIZE_Z).
      Gibt zurück:
      the terrain id, containing the terrain material at the given position in the chunk.
    • getTerrainIndex

      public static int getTerrainIndex(int x, int y, int z)
    • getRawTerrainIndex

      public static int getRawTerrainIndex(int x, int y, int z)
    • equals

      public boolean equals(Object o)
      Setzt außer Kraft:
      equals in Klasse Object
    • hashCode

      public int hashCode()
      Setzt außer Kraft:
      hashCode in Klasse Object