Interface World

All Superinterfaces:
Extent, InputExtent, Keyed, OutputExtent
All Known Implementing Classes:
AbstractWorld, NullWorld

public interface World extends Extent, Keyed
Represents a world (dimension).
  • Method Details

    • getName

      String getName()
      Get the name of the world.
      Returns:
      a name for the world
    • getStoragePath

      @Nullable Path getStoragePath()
      Get the folder in which this world is stored. May return null if unknown or if this world is not serialized to disk.
      Returns:
      world storage path
    • getMinY

      int getMinY()
      Get the minimum Y.
      Returns:
      the minimum Y
    • getMaxY

      int getMaxY()
      Get the maximum Y.
      Returns:
      the maximum Y
    • createLiquidMask

      Mask createLiquidMask()
      Create a mask that matches all liquids.

      Implementations should override this so that custom liquids are supported.

      Returns:
      a mask
    • useItem

      boolean useItem(BlockVector3 position, BaseItem item, Direction face)
      Use the given item on the block at the given location on the given side.
      Parameters:
      item - The item
      face - The face
      Returns:
      Whether it succeeded
    • setBlock

      @Deprecated default <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException
      Deprecated.
      Similar to OutputExtent.setBlock(BlockVector3, BlockStateHolder) but a notifyAndLight parameter indicates whether adjacent blocks should be notified that changes have been made and lighting operations should be executed.

      If it's not possible to skip lighting, or if it's not possible to avoid notifying adjacent blocks, then attempt to meet the specification as best as possible.

      On implementations where the world is not simulated, the notifyAndLight parameter has no effect either way.

      Parameters:
      position - position of the block
      block - block to set
      notifyAndLight - true to to notify and light
      Returns:
      true if the block was successfully set (return value may not be accurate)
      Throws:
      WorldEditException
    • setBlock

      <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException
      Similar to OutputExtent.setBlock(BlockVector3, BlockStateHolder) but a sideEffects parameter indicates which side effects should be applied to the block. This includes block updates, lighting, and others. See SideEffect for a full list.

      Not all implementations support all side effects. Use Platform.getSupportedSideEffects() for a list of supported side effects. Non-supported side effects will be ignored.

      Parameters:
      position - position of the block
      block - block to set
      sideEffects - which side effects to perform
      Returns:
      true if the block was successfully set (return value may not be accurate)
      Throws:
      WorldEditException
    • notifyAndLightBlock

      @Deprecated default boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException
      Deprecated.
      Notifies the simulation that the block at the given location has been changed and it must be re-lighted (and issue other events).
      Parameters:
      position - position of the block
      previousType - the type of the previous block that was there
      Returns:
      true if the block was successfully notified
      Throws:
      WorldEditException
    • applySideEffects

      Set<SideEffect> applySideEffects(BlockVector3 position, BlockState previousType, SideEffectSet sideEffectSet) throws WorldEditException
      Applies a set of side effects on the given block.
      Parameters:
      position - position of the block
      previousType - the type of the previous block that was there
      sideEffectSet - which side effects to perform
      Returns:
      a set of side effects that were applied
      Throws:
      WorldEditException
    • getBlockLightLevel

      int getBlockLightLevel(BlockVector3 position)
      Get the light level at the given block.
      Parameters:
      position - the position
      Returns:
      the light level (0-15)
    • clearContainerBlockContents

      boolean clearContainerBlockContents(BlockVector3 position)
      Clear a chest's contents.
      Parameters:
      position - the position
      Returns:
      true if the container was cleared
    • dropItem

      void dropItem(Vector3 position, BaseItemStack item, int count)
      Drop an item at the given position.
      Parameters:
      position - the position
      item - the item to drop
      count - the number of individual stacks to drop (number of item entities)
    • dropItem

      void dropItem(Vector3 position, BaseItemStack item)
      Drop one stack of the item at the given position.
      Parameters:
      position - the position
      item - the item to drop
      See Also:
    • simulateBlockMine

      void simulateBlockMine(BlockVector3 position)
      Simulate a block being mined at the given position.
      Parameters:
      position - the position
    • canPlaceAt

      default boolean canPlaceAt(BlockVector3 position, BlockState blockState)
      Gets whether the given BlockState can be placed here.
      Parameters:
      position - The position
      blockState - The blockstate
      Returns:
      If it can be placed
    • regenerate

      default boolean regenerate(Region region, EditSession editSession)
      Regenerate an area.
      Parameters:
      region - the region
      editSession - the EditSession
      Returns:
      true if re-generation was successful
    • regenerate

      default boolean regenerate(Region region, Extent extent)
      Regenerate an area.
      Parameters:
      region - the region
      extent - the Extent
      Returns:
      true if re-generation was successful
    • regenerate

      @NonAbstractForCompatibility(delegateName="regenerate", delegateParams={Region.class,EditSession.class}) default boolean regenerate(Region region, Extent extent, RegenOptions options)
      Regenerate an area.
      Parameters:
      region - the region
      extent - the Extent
      options - the regeneration options
      Returns:
      true if regeneration was successful
      API Note:
      This must be overridden by new subclasses. See NonAbstractForCompatibility for details
    • generateTree

      boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException
      Generate a tree at the given position.
      Parameters:
      type - the tree type
      editSession - the EditSession
      position - the position
      Returns:
      true if generation was successful
      Throws:
      MaxChangedBlocksException - thrown if too many blocks were changed
    • generateStructure

      default boolean generateStructure(StructureType type, EditSession editSession, BlockVector3 position)
    • generateFeature

      default boolean generateFeature(ConfiguredFeatureType type, EditSession editSession, BlockVector3 position)
      Generate a feature at the given position.
      Parameters:
      type - The feature type
      editSession - The EditSession
      position - The position
      Returns:
      True if the generation was successful
    • checkLoadedChunk

      void checkLoadedChunk(BlockVector3 position)
      Load the chunk at the given position if it isn't loaded.
      Parameters:
      position - the position
    • fixAfterFastMode

      void fixAfterFastMode(Iterable<BlockVector2> chunks)
      Fix the given chunks after fast mode was used.

      Fast mode makes calls to setBlock(BlockVector3, BlockStateHolder, boolean) with false for the notifyAndLight parameter, which may causes lighting errors to accumulate. Use of this method, if it is implemented by the underlying world, corrects those lighting errors and may trigger block change notifications.

      Parameters:
      chunks - a list of chunk coordinates to fix
    • sendBiomeUpdates

      void sendBiomeUpdates(Iterable<BlockVector2> chunks)
      Sends biome updates for the given chunks.

      This doesn't modify biomes at all, it just sends the current state of the biomes in the world to all of the nearby players, updating the visual representation of the biomes on their clients.

      Parameters:
      chunks - a list of chunk coordinates to send biome updates for
    • fixLighting

      void fixLighting(Iterable<BlockVector2> chunks)
      Relight the given chunks if possible.
      Parameters:
      chunks - a list of chunk coordinates to fix
    • playEffect

      boolean playEffect(Vector3 position, int type, int data)
      Play the given effect.
      Parameters:
      position - the position
      type - the effect type
      data - the effect data
      Returns:
      true if the effect was played
    • queueBlockBreakEffect

      boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority)
      Queue a block break effect.
      Parameters:
      server - the server
      position - the position
      blockType - the block type
      priority - the priority
      Returns:
      true if the effect was played
    • getWeather

      WeatherType getWeather()
      Gets the weather type of the world.
      Returns:
      The weather
    • getRemainingWeatherDuration

      long getRemainingWeatherDuration()
      Gets the remaining weather duration.
      Returns:
      The weather duration
    • setWeather

      void setWeather(WeatherType weatherType)
      Sets the weather type of the world.
      Parameters:
      weatherType - The weather type
    • setWeather

      void setWeather(WeatherType weatherType, long duration)
      Sets the weather type of the world.
      Parameters:
      weatherType - The weather type
      duration - The duration of the weather
    • getSpawnPosition

      BlockVector3 getSpawnPosition()
      Gets the spawn position of this world.
      Returns:
      The spawn position
    • equals

      boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      int hashCode()
      Overrides:
      hashCode in class Object