net.minecraft.world.chunk

## Class Chunk

- java.lang.Object
- - net.minecraft.world.chunk.Chunk

- Direct Known Subclasses:
    EmptyChunk

      public class Chunk
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `Map` | `chunkTileEntityMap` A Map of ChunkPositions to TileEntities in this chunk
    `boolean` | `deferRender`
    `List[]` | `entityLists` Array of Lists containing the entities in this Chunk.
    `int` | `field_82912_p`
    `boolean` | `hasEntities` Whether this Chunk has any Entities and thus requires saving on every tick
    `int[]` | `heightMap`
    `boolean` | `isChunkLoaded` Whether or not this Chunk is currently loaded into the World
    `static boolean` | `isLit` Determines if the chunk is lit or not at a light value greater than 0.
    `boolean` | `isModified` Set to true if the chunk has been modified and needs to be updated internally.
    `boolean` | `isTerrainPopulated` Boolean value indicating if the terrain is populated.
    `long` | `lastSaveTime` The time according to World.worldTime when this chunk was last saved
    `int[]` | `precipitationHeightMap` A map, similar to heightMap, that tracks how far down precipitation can fall.
    `boolean[]` | `updateSkylightColumns` Which columns need their skylightMaps updated.
    `World` | `worldObj` Reference to the World object.
    `int` | `xPosition` The x coordinate of the chunk.
    `int` | `zPosition` The z coordinate of the chunk.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Chunk(World world, byte[] ids, byte[] metadata, int chunkX, int chunkZ)` Metadata sensitive Chunk constructor for use in new ChunkProviders that use metadata sensitive blocks during generation.
    `Chunk(World par1World, byte[] par2ArrayOfByte, int par3, int par4)`
    `Chunk(World par1World, int par2, int par3)`
    `Chunk(World world, short[] ids, byte[] metadata, int chunkX, int chunkZ)` A Chunk Constructor which handles shorts to allow block ids > 256 (full 4096 range) Meta data sensitive NOTE: The x,y,z order of the array is different from the native Chunk constructor to allow for generation > y127 NOTE: This is possibly more efficient than the standard constructor due to less memory skipping

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addEntity(Entity par1Entity)` Adds an entity to the chunk.
    `void` | `addTileEntity(TileEntity par1TileEntity)` Adds a TileEntity to a chunk
    `boolean` | `canBlockSeeTheSky(int par1, int par2, int par3)` Returns whether is not a block above this one blocking sight to the sky (done via checking against the heightmap)
    `void` | `cleanChunkBlockTileEntity(int x, int y, int z)` FORGE: Used to remove only invalid TileEntities
    `void` | `enqueueRelightChecks()` Called once-per-chunk-per-tick, and advances the round-robin relight check index per-storage-block by up to 8 blocks at a time.
    `void` | `fillChunk(byte[] par1ArrayOfByte, int par2, int par3, boolean par4)`
    `void` | `generateHeightMap()`
    `void` | `generateSkylightMap()` Generates the initial skylight map for the chunk upon generation or load.
    `boolean` | `getAreLevelsEmpty(int par1, int par2)` Returns whether the ExtendedBlockStorages containing levels (in blocks) from arg 1 to arg 2 are fully empty (true) or not (false).
    `byte[]` | `getBiomeArray()` Returns an array containing a 16x16 mapping on the X/Z of block positions in this Chunk to biome IDs.
    `BiomeGenBase` | `getBiomeGenForWorldCoords(int par1, int par2, WorldChunkManager par3WorldChunkManager)` This method retrieves the biome at a set of coordinates
    `int` | `getBlockID(int par1, int par2, int par3)` Return the ID of a block in the chunk.
    `int` | `getBlockLightOpacity(int par1, int par2, int par3)`
    `int` | `getBlockLightValue(int par1, int par2, int par3, int par4)` Gets the amount of light on a block taking into account sunlight
    `int` | `getBlockMetadata(int par1, int par2, int par3)` Return the metadata corresponding to the given coordinates inside a chunk.
    `ExtendedBlockStorage[]` | `getBlockStorageArray()` Returns the ExtendedBlockStorage array for this Chunk.
    `TileEntity` | `getChunkBlockTileEntity(int par1, int par2, int par3)` Gets the TileEntity for a given block in this chunk
    `ChunkCoordIntPair` | `getChunkCoordIntPair()` Gets a ChunkCoordIntPair representing the Chunk's position.
    `void` | `getEntitiesOfTypeWithinAAAB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector)` Gets all entities that can be assigned to the specified class.
    `void` | `getEntitiesWithinAABBForEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, List par3List)` Fills the given list of all entities that intersect within the given bounding box that aren't the passed entity Args: entity, aabb, listToFill
    `int` | `getHeightValue(int par1, int par2)` Returns the value in the height map at this x, z coordinate in the chunk
    `int` | `getPrecipitationHeight(int par1, int par2)` Gets the height to which rain/snow will fall.
    `Random` | `getRandomWithSeed(long par1)`
    `int` | `getSavedLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4)` Gets the amount of light saved in this block (doesn't adjust for daylight)
    `int` | `getTopFilledSegment()` Returns the topmost ExtendedBlockStorage instance for this Chunk that actually contains a block.
    `boolean` | `isAtLocation(int par1, int par2)` Checks whether the chunk is at the X/Z location specified
    `boolean` | `isEmpty()`
    `boolean` | `needsSaving(boolean par1)` Returns true if this Chunk needs to be saved
    `void` | `onChunkLoad()` Called when this Chunk is loaded by the ChunkProvider
    `void` | `onChunkUnload()` Called when this Chunk is unloaded by the ChunkProvider
    `void` | `populateChunk(IChunkProvider par1IChunkProvider, IChunkProvider par2IChunkProvider, int par3, int par4)`
    `void` | `removeChunkBlockTileEntity(int par1, int par2, int par3)` Removes the TileEntity for a given block in this chunk
    `void` | `removeEntity(Entity par1Entity)` removes entity using its y chunk coordinate as its index
    `void` | `removeEntityAtIndex(Entity par1Entity, int par2)` Removes entity at the specified index from the entity array.
    `void` | `resetRelightChecks()` Resets the relight check index to 0 for this Chunk.
    `void` | `setBiomeArray(byte[] par1ArrayOfByte)` Accepts a 256-entry array that contains a 16x16 mapping on the X/Z plane of block positions in this Chunk to biome IDs.
    `boolean` | `setBlockID(int par1, int par2, int par3, int par4)` Sets a blockID for a position in the chunk.
    `boolean` | `setBlockIDWithMetadata(int par1, int par2, int par3, int par4, int par5)` Sets a blockID of a position within a chunk with metadata.
    `boolean` | `setBlockMetadata(int par1, int par2, int par3, int par4)` Set the metadata of a block in the chunk
    `void` | `setChunkBlockTileEntity(int par1, int par2, int par3, TileEntity par4TileEntity)` Sets the TileEntity for a given block in this chunk
    `void` | `setChunkModified()` Sets the isModified flag for this Chunk
    `void` | `setLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4, int par5)` Sets the light value at the coordinate.
    `void` | `setStorageArrays(ExtendedBlockStorage[] par1ArrayOfExtendedBlockStorage)`
    `void` | `updateSkylight()` Checks whether skylight needs updated; if it does, calls updateSkylight_do

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### isLit

          public static boolean isLit

      Determines if the chunk is lit or not at a light value greater than 0.

    - #### precipitationHeightMap

          public int[] precipitationHeightMap

      A map, similar to heightMap, that tracks how far down precipitation can fall.

    - #### updateSkylightColumns

          public boolean[] updateSkylightColumns

      Which columns need their skylightMaps updated.

    - #### isChunkLoaded

          public boolean isChunkLoaded

      Whether or not this Chunk is currently loaded into the World

    - #### worldObj

          public World worldObj

      Reference to the World object.

    - #### heightMap

          public int[] heightMap

    - #### xPosition

          public final int xPosition

      The x coordinate of the chunk.

    - #### zPosition

          public final int zPosition

      The z coordinate of the chunk.

    - #### chunkTileEntityMap

          public Map chunkTileEntityMap

      A Map of ChunkPositions to TileEntities in this chunk

    - #### entityLists

          public List[] entityLists

      Array of Lists containing the entities in this Chunk. Each List represents a 16 block subchunk.

    - #### isTerrainPopulated

          public boolean isTerrainPopulated

      Boolean value indicating if the terrain is populated.

    - #### isModified

          public boolean isModified

      Set to true if the chunk has been modified and needs to be updated internally.

    - #### hasEntities

          public boolean hasEntities

      Whether this Chunk has any Entities and thus requires saving on every tick

    - #### lastSaveTime

          public long lastSaveTime

      The time according to World.worldTime when this chunk was last saved

    - #### deferRender

          public boolean deferRender

    - #### field_82912_p

          public int field_82912_p

  - ### Constructor Detail

    - #### Chunk

          public Chunk(World par1World,
               int par2,
               int par3)

    - #### Chunk

          public Chunk(World par1World,
               byte[] par2ArrayOfByte,
               int par3,
               int par4)

    - #### Chunk

          public Chunk(World world,
               byte[] ids,
               byte[] metadata,
               int chunkX,
               int chunkZ)

      Metadata sensitive Chunk constructor for use in new ChunkProviders that use metadata sensitive blocks during generation.
      Parameters:
        `world` - The world this chunk belongs to
        `ids` - A ByteArray containing all the BlockID's to set this chunk to
        `metadata` - A ByteArray containing all the metadata to set this chunk to
        `chunkX` - The chunk's X position
        `chunkZ` - The Chunk's Z position

    - #### Chunk

          public Chunk(World world,
               short[] ids,
               byte[] metadata,
               int chunkX,
               int chunkZ)

      A Chunk Constructor which handles shorts to allow block ids > 256 (full 4096 range) Meta data sensitive NOTE: The x,y,z order of the array is different from the native Chunk constructor to allow for generation > y127 NOTE: This is possibly more efficient than the standard constructor due to less memory skipping
      Parameters:
        `world` - The world this chunk belongs to
        `ids` - A ShortArray containing all the BlockID's to set this chunk to (x is low order, z is mid, y is high)
        `metadata` - A ByteArray containing all the metadata to set this chunk to
        `chunkX` - The chunk's X position
        `chunkZ` - The Chunk's Z position

  - ### Method Detail

    - #### isAtLocation

          public boolean isAtLocation(int par1,
                             int par2)

      Checks whether the chunk is at the X/Z location specified

    - #### getHeightValue

          public int getHeightValue(int par1,
                           int par2)

      Returns the value in the height map at this x, z coordinate in the chunk

    - #### getTopFilledSegment

          public int getTopFilledSegment()

      Returns the topmost ExtendedBlockStorage instance for this Chunk that actually contains a block.

    - #### getBlockStorageArray

          public ExtendedBlockStorage[] getBlockStorageArray()

      Returns the ExtendedBlockStorage array for this Chunk.

    - #### generateHeightMap

          public void generateHeightMap()

    - #### generateSkylightMap

          public void generateSkylightMap()

      Generates the initial skylight map for the chunk upon generation or load.

    - #### getBlockLightOpacity

          public int getBlockLightOpacity(int par1,
                                 int par2,
                                 int par3)

    - #### getBlockID

          public int getBlockID(int par1,
                       int par2,
                       int par3)

      Return the ID of a block in the chunk.

    - #### getBlockMetadata

          public int getBlockMetadata(int par1,
                             int par2,
                             int par3)

      Return the metadata corresponding to the given coordinates inside a chunk.

    - #### setBlockID

          public boolean setBlockID(int par1,
                           int par2,
                           int par3,
                           int par4)

      Sets a blockID for a position in the chunk. Args: x, y, z, blockID

    - #### setBlockIDWithMetadata

          public boolean setBlockIDWithMetadata(int par1,
                                       int par2,
                                       int par3,
                                       int par4,
                                       int par5)

      Sets a blockID of a position within a chunk with metadata. Args: x, y, z, blockID, metadata

    - #### setBlockMetadata

          public boolean setBlockMetadata(int par1,
                                 int par2,
                                 int par3,
                                 int par4)

      Set the metadata of a block in the chunk

    - #### getSavedLightValue

          public int getSavedLightValue(EnumSkyBlock par1EnumSkyBlock,
                               int par2,
                               int par3,
                               int par4)

      Gets the amount of light saved in this block (doesn't adjust for daylight)

    - #### setLightValue

          public void setLightValue(EnumSkyBlock par1EnumSkyBlock,
                           int par2,
                           int par3,
                           int par4,
                           int par5)

      Sets the light value at the coordinate. If enumskyblock is set to sky it sets it in the skylightmap and if its a block then into the blocklightmap. Args enumSkyBlock, x, y, z, lightValue

    - #### getBlockLightValue

          public int getBlockLightValue(int par1,
                               int par2,
                               int par3,
                               int par4)

      Gets the amount of light on a block taking into account sunlight

    - #### addEntity

          public void addEntity(Entity par1Entity)

      Adds an entity to the chunk. Args: entity

    - #### removeEntity

          public void removeEntity(Entity par1Entity)

      removes entity using its y chunk coordinate as its index

    - #### removeEntityAtIndex

          public void removeEntityAtIndex(Entity par1Entity,
                                 int par2)

      Removes entity at the specified index from the entity array.

    - #### canBlockSeeTheSky

          public boolean canBlockSeeTheSky(int par1,
                                  int par2,
                                  int par3)

      Returns whether is not a block above this one blocking sight to the sky (done via checking against the heightmap)

    - #### getChunkBlockTileEntity

          public TileEntity getChunkBlockTileEntity(int par1,
                                           int par2,
                                           int par3)

      Gets the TileEntity for a given block in this chunk

    - #### addTileEntity

          public void addTileEntity(TileEntity par1TileEntity)

      Adds a TileEntity to a chunk

    - #### setChunkBlockTileEntity

          public void setChunkBlockTileEntity(int par1,
                                     int par2,
                                     int par3,
                                     TileEntity par4TileEntity)

      Sets the TileEntity for a given block in this chunk

    - #### removeChunkBlockTileEntity

          public void removeChunkBlockTileEntity(int par1,
                                        int par2,
                                        int par3)

      Removes the TileEntity for a given block in this chunk

    - #### onChunkLoad

          public void onChunkLoad()

      Called when this Chunk is loaded by the ChunkProvider

    - #### onChunkUnload

          public void onChunkUnload()

      Called when this Chunk is unloaded by the ChunkProvider

    - #### setChunkModified

          public void setChunkModified()

      Sets the isModified flag for this Chunk

    - #### getEntitiesWithinAABBForEntity

          public void getEntitiesWithinAABBForEntity(Entity par1Entity,
                                            AxisAlignedBB par2AxisAlignedBB,
                                            List par3List)

      Fills the given list of all entities that intersect within the given bounding box that aren't the passed entity Args: entity, aabb, listToFill

    - #### getEntitiesOfTypeWithinAAAB

          public void getEntitiesOfTypeWithinAAAB(Class par1Class,
                                         AxisAlignedBB par2AxisAlignedBB,
                                         List par3List,
                                         IEntitySelector par4IEntitySelector)

      Gets all entities that can be assigned to the specified class. Args: entityClass, aabb, listToFill

    - #### needsSaving

          public boolean needsSaving(boolean par1)

      Returns true if this Chunk needs to be saved

    - #### getRandomWithSeed

          public Random getRandomWithSeed(long par1)

    - #### isEmpty

          public boolean isEmpty()

    - #### populateChunk

          public void populateChunk(IChunkProvider par1IChunkProvider,
                           IChunkProvider par2IChunkProvider,
                           int par3,
                           int par4)

    - #### getPrecipitationHeight

          public int getPrecipitationHeight(int par1,
                                   int par2)

      Gets the height to which rain/snow will fall. Calculates it if not already stored.

    - #### updateSkylight

          public void updateSkylight()

      Checks whether skylight needs updated; if it does, calls updateSkylight_do

    - #### getChunkCoordIntPair

          public ChunkCoordIntPair getChunkCoordIntPair()

      Gets a ChunkCoordIntPair representing the Chunk's position.

    - #### getAreLevelsEmpty

          public boolean getAreLevelsEmpty(int par1,
                                  int par2)

      Returns whether the ExtendedBlockStorages containing levels (in blocks) from arg 1 to arg 2 are fully empty (true) or not (false).

    - #### setStorageArrays

          public void setStorageArrays(ExtendedBlockStorage[] par1ArrayOfExtendedBlockStorage)

    - #### fillChunk

          public void fillChunk(byte[] par1ArrayOfByte,
                       int par2,
                       int par3,
                       boolean par4)

    - #### getBiomeGenForWorldCoords

          public BiomeGenBase getBiomeGenForWorldCoords(int par1,
                                               int par2,
                                               WorldChunkManager par3WorldChunkManager)

      This method retrieves the biome at a set of coordinates

    - #### getBiomeArray

          public byte[] getBiomeArray()

      Returns an array containing a 16x16 mapping on the X/Z of block positions in this Chunk to biome IDs.

    - #### setBiomeArray

          public void setBiomeArray(byte[] par1ArrayOfByte)

      Accepts a 256-entry array that contains a 16x16 mapping on the X/Z plane of block positions in this Chunk to biome IDs.

    - #### resetRelightChecks

          public void resetRelightChecks()

      Resets the relight check index to 0 for this Chunk.

    - #### enqueueRelightChecks

          public void enqueueRelightChecks()

      Called once-per-chunk-per-tick, and advances the round-robin relight check index per-storage-block by up to 8 blocks at a time. In a worst-case scenario, can potentially take up to 1.6 seconds, calculated via (4096/(8*16))/20, to re-check all blocks in a chunk, which could explain both lagging light updates in certain cases as well as Nether relight

    - #### cleanChunkBlockTileEntity

          public void cleanChunkBlockTileEntity(int x,
                                       int y,
                                       int z)

      FORGE: Used to remove only invalid TileEntities