Interface Chunk<P extends Chunk<P>>

All Superinterfaces:
BiomeVolume, BiomeVolume.Modifiable<P>, BiomeVolume.Streamable<P>, BlockEntityVolume, BlockEntityVolume.Modifiable<P>, BlockEntityVolume.Streamable<P>, BlockVolume, BlockVolume.Modifiable<P>, BlockVolume.Streamable<P>, HeightAwareVolume, LocationBaseDataHolder, LocationBaseDataHolder.Mutable, MutableVolume, UpdatableVolume, Volume
All Known Subinterfaces:
GenerationChunk, WorldChunk

A chunk is a specific grid-aligned partition of a WorldLike.

Chunk is exposed as a superinterface due to the nature of needing chunk like structures for various purposes, whether it's for world generation, chunk loading from storage, or empty chunks on clients. Traditionally, a usable "live" proto chunk instance will be a WorldChunk with a valid World instance.

A chunk may not be attached to a World or GenerationRegion if it is in the process of being generated.

  • Method Details

    • addEntity

      void addEntity(Entity entity)
      Adds the Entity to this chunk. It is not guaranteed this will succeed in all cases, as state() does play a role in whether an entity can be directly added or not.

      This method should realistically be used only during world generation, and therefore will likely emit warnings if attempting to add entities to live WorldChunk instances.

      Parameters:
      entity - The entity to add
    • state

      ChunkState state()
      Gets this Chunk's current ChunkState. The ChunkState stipulates the potential validity of various operations that can be performed.

      A fully generated chunk will return ChunkStates.FULL - though care should be taken as the chunk may be an empty one.

      Returns:
      This chunk's state
    • isEmpty

      boolean isEmpty()
      Gets whether this chunk is empty.
      Returns:
      Whether this chunk is empty
    • chunkPosition

      Vector3i chunkPosition()
      Gets the position of the chunk.

      The returned position is 3-dimensional with the Y-coordinate set to be the base (lowest) Y-position of the chunk. As 3-dimensional chunks do not yet exist in Minecraft, the returned position will always have a y set to 0.

      Returns:
      The position
    • inhabitedTime

      Ticks inhabitedTime()
      Gets the number of ticks players have been present in this chunk, used for calculation of the regional difficulty factor. In vanilla, it is increased by the number of players in the chunk every tick, and is capped at 3,600,000 ticks (50 hours).
      Returns:
      The number of ticks
    • setInhabitedTime

      void setInhabitedTime(Ticks newInhabitedTime)
      Sets the number of ticks players have been present in this chunk.
      Parameters:
      newInhabitedTime - The Ticks to set this value to
      Throws:
      IllegalArgumentException - If the inhabited time is infinite
      See Also: