# Class TerrainChunk

java.lang.Object
com.codename1.gaming.level.TerrainChunk

public class TerrainChunk extends Object
A `#SIZE`x`#SIZE` square block of terrain -- the unit of streaming. Identified by its chunk coordinates (`#getChunkX()`, `#getChunkZ()`), it is self-describing: a height per cell, a material per cell (stored compactly as an index into the chunk's own material palette), and the `TerrainFeature`s anchored within it. `StreamingTerrain` loads/saves chunks on demand so a world can be arbitrarily large without holding it all in memory.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `SIZE`
  Cells per side of a chunk.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TerrainChunk(int cx, int cz)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clearDirty()`
  `List<TerrainFeature>`
  `features()`
  Features anchored in this chunk (mutate directly; mark dirty via `#touch()`).
  `int`
  `getChunkX()`
  `int`
  `getChunkZ()`
  `float`
  `getHeight(int localX, int localZ)`
  `String`
  `getMaterial(int localX, int localZ)`
  `boolean`
  `hasGround(int localX, int localZ)`
  `boolean`
  `isDirty()`
  Whether the chunk has unsaved edits (used by providers to decide what to persist).
  `void`
  `setHeight(int localX, int localZ, float h)`
  `void`
  `setMaterial(int localX, int localZ, String materialId)`
  `void`
  `touch()`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### SIZE

    public static final int SIZE
    Cells per side of a chunk.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### TerrainChunk

    public TerrainChunk(int cx, int cz)

- ## Method Details

  - ### getChunkX

    public int getChunkX()

  - ### getChunkZ

    public int getChunkZ()

  - ### isDirty

    public boolean isDirty()
    Whether the chunk has unsaved edits (used by providers to decide what to persist).

  - ### clearDirty

    public void clearDirty()

  - ### getHeight

    public float getHeight(int localX, int localZ)

  - ### setHeight

    public void setHeight(int localX, int localZ, float h)

  - ### hasGround

    public boolean hasGround(int localX, int localZ)

  - ### getMaterial

    public String getMaterial(int localX, int localZ)

  - ### setMaterial

    public void setMaterial(int localX, int localZ, String materialId)

  - ### features

    public List<TerrainFeature> features()
    Features anchored in this chunk (mutate directly; mark dirty via `#touch()`).

  - ### touch

    public void touch()