Interface World<W extends World<W,L>,L extends Location<W,L>>

All Superinterfaces:
ArchetypeVolumeCreator, Audience, BiomeVolume, BiomeVolume.Modifiable<W>, BiomeVolume.Streamable<W>, BlockEntityVolume, BlockEntityVolume.Modifiable<W>, BlockEntityVolume.Streamable<W>, BlockVolume, BlockVolume.Modifiable<W>, BlockVolume.Streamable<W>, ChunkVolume, ContextSource, EntityVolume, EntityVolume.Modifiable<W>, EntityVolume.Streamable<W>, EnvironmentalVolume, ForwardingAudience, GenerationVolume, GenerationVolume.Mutable, HeightAwareVolume, LocationBaseDataHolder, LocationBaseDataHolder.Mutable, LocationCreator<W,L>, MutableGameVolume, MutableVolume, PhysicsAwareMutableBlockVolume<W>, Pointered, PrimitiveGameVolume, RandomProvider, Region<W>, RegistryHolder, UpdatableVolume, Viewer, Volume, WeatherUniverse, WorldLike<W>
All Known Subinterfaces:
ClientWorld, ServerWorld

A loaded Minecraft world.
  • Method Details

    • properties

      WorldProperties properties()
      Gets the properties.
      Returns:
      The properties
    • world

      default W world()
      Specified by:
      world in interface LocationCreator<W extends World<W,L>,L extends Location<W,L>>
    • isLoaded

      boolean isLoaded()
      Gets if this world is currently loaded.

      An assumption can be made that if this returns false, this is considered a stale object.

      Returns:
      True if loaded, false if not
    • players

      Collection<? extends Player> players()
      Gets an unmodifiable collection of players currently in this world.
      Specified by:
      players in interface EntityVolume
      Returns:
      The players
    • audiences

      default Iterable<? extends Audience> audiences()
      Specified by:
      audiences in interface ForwardingAudience
    • closestPlayer

      default Optional<? extends Player> closestPlayer(Vector3i position, double distance)
    • closestPlayer

      default Optional<? extends Player> closestPlayer(Vector3i position, double distance, Predicate<? super Player> predicate)
    • closestPlayer

      default Optional<? extends Player> closestPlayer(Entity entity, double distance)
    • closestPlayer

      default Optional<? extends Player> closestPlayer(Entity entity, double distance, Predicate<? super Player> predicate)
    • closestPlayer

      default Optional<? extends Player> closestPlayer(int x, int y, int z, double distance)
    • closestPlayer

      Optional<? extends Player> closestPlayer(int x, int y, int z, double distance, Predicate<? super Player> predicate)
    • chunkAtBlock

      WorldChunk chunkAtBlock(Vector3i blockPosition)
      Gets the loaded chunk at the given block coordinate position. This gets a guaranteed WorldChunk at the desired block position; however, the WorldChunk instance may be empty, and likewise, may not be generated, valid, pre-existing. It is important to check for these cases prior to attempting to modify the chunk.

      Note that this is still different from chunk(Vector3i) due to it being a relative block position which can vary depending on implementation and other mods installed.

      Specified by:
      chunkAtBlock in interface ChunkVolume
      Parameters:
      blockPosition - The block position to be transformed for relative chunk position
      Returns:
      The available chunk at that position
    • chunkAtBlock

      WorldChunk chunkAtBlock(int bx, int by, int bz)
      Gets the loaded chunk at the given chunk coordinate position. The position is the block position relative to the Chunk.chunkPosition(), and therefor is going to return a different chunk from ChunkVolume.chunk(Vector3i). This is more usable from ServerLocations or a Locatable that returns a position in relation to a WorldLike. This gets a guaranteed WorldChunk at the desired block position; however, the WorldChunk instance may be empty, and likewise, may not be generated, valid, pre-existing. It is important to check for these cases prior to attempting to modify the chunk.

      Note that this is still different from chunk(Vector3i) due to the relative block position dictated by Server.chunkLayout(), which can vary depending on implementation and other mods installed.

      Specified by:
      chunkAtBlock in interface ChunkVolume
      Parameters:
      bx - The block x coordinate
      by - The block y coordinate
      bz - The block z coordinate
      Returns:
      The available chunk at that position
    • chunk

      default WorldChunk chunk(Vector3i chunkPos)
      Gets the loaded chunk at the given chunk coordinate position. The position is the same as Chunk.chunkPosition(). The difference between a block placed within a WorldLike is different from a Chunk's position, and therefore care should be taken when requesting a chunk. It is not guaranteed that the returned Chunk is empty or not, nor the state of the chunk. This gets a guaranteed WorldChunk at the desired chunk position; however, the WorldChunk instance may be empty, and likewise, may not be generated, valid, pre-existing. It is important to check for these cases prior to attempting to modify the chunk.
      Specified by:
      chunk in interface ChunkVolume
      Parameters:
      chunkPos - The chunk position relative to the chunk layout
      Returns:
      The available chunk at that position
    • chunk

      WorldChunk chunk(int cx, int cy, int cz)
      Gets the loaded chunk at the given chunk coordinate position. The position is the same as Chunk.chunkPosition(). The difference between a block placed within a WorldLike is different from a Chunk's position, and therefore care should be taken when requesting a chunk. It is not guaranteed that the returned Chunk is empty or not, nor the state of the chunk.

      In Vanilla, the y coordinate will always be 0.

      This gets a guaranteed WorldChunk at the desired chunk position; however, the WorldChunk instance may be empty, and likewise, may not be generated, valid, pre-existing. It is important to check for these cases prior to attempting to modify the chunk.
      Specified by:
      chunk in interface ChunkVolume
      Parameters:
      cx - The x chunk coordinate
      cy - The y coordinate
      cz - The z chunk coordinate
      Returns:
      The available chunk at the chunk position
    • loadChunk

      default Optional<WorldChunk> loadChunk(Vector3i chunkPosition, boolean shouldGenerate)
      Gets the chunk at the given chunk coordinate position if it exists or if shouldGenerate is true and the chunk is generated.
      Parameters:
      chunkPosition - The position
      shouldGenerate - True to generate a new chunk
      Returns:
      The loaded or generated chunk, if already generated
    • loadChunk

      Optional<WorldChunk> loadChunk(int cx, int cy, int cz, boolean shouldGenerate)
      Gets the chunk at the given chunk coordinate position if it exists or if shouldGenerate is true and the chunk is generated.

      In Vanilla, the y coordinate will always be 0.

      Parameters:
      cx - The x coordinate
      cy - The y coordinate
      cz - The z coordinate
      shouldGenerate - True to generate a new chunk
      Returns:
      The loaded or generated chunk, if already generated
    • loadedChunks

      Iterable<WorldChunk> loadedChunks()
      Returns a Collection of all actively loaded chunks in this world.

      The ordering of the returned chunks is undefined.

      Returns:
      The loaded chunks