Class WorldWrapper

java.lang.Object
com.sk89q.worldedit.world.AbstractWorld
com.fastasyncworldedit.core.wrappers.WorldWrapper
All Implemented Interfaces:
IChunkCache<IChunkGet>, Trimable, Extent, InputExtent, OutputExtent, Keyed, World

public class WorldWrapper extends AbstractWorld
  • Method Details

    • wrap

      public static WorldWrapper wrap(World world)
    • unwrap

      public static World unwrap(World world)
    • unwrap

      public static World unwrap(Extent extent)
    • getParent

      public World getParent()
    • useItem

      public boolean useItem(BlockVector3 position, BaseItem item, Direction face)
      Description copied from interface: World
      Use the given item on the block at the given location on the given side.
      Specified by:
      useItem in interface World
      Overrides:
      useItem in class AbstractWorld
      item - The item
      face - The face
      Returns:
      Whether it succeeded
    • getMaxY

      public int getMaxY()
      Description copied from interface: World
      Get the maximum Y.
      Specified by:
      getMaxY in interface Extent
      Specified by:
      getMaxY in interface World
      Overrides:
      getMaxY in class AbstractWorld
      Returns:
      the maximum Y
    • getMinY

      public int getMinY()
      Description copied from interface: World
      Get the minimum Y.
      Specified by:
      getMinY in interface Extent
      Specified by:
      getMinY in interface World
      Overrides:
      getMinY in class AbstractWorld
      Returns:
      the minimum Y
    • createLiquidMask

      public Mask createLiquidMask()
      Description copied from interface: World
      Create a mask that matches all liquids.

      Implementations should override this so that custom liquids are supported.

      Specified by:
      createLiquidMask in interface World
      Overrides:
      createLiquidMask in class AbstractWorld
      Returns:
      a mask
    • dropItem

      public void dropItem(Vector3 pt, BaseItemStack item, int times)
      Description copied from interface: World
      Drop an item at the given position.
      Specified by:
      dropItem in interface World
      Overrides:
      dropItem in class AbstractWorld
      Parameters:
      pt - the position
      item - the item to drop
      times - the number of individual stacks to drop (number of item entities)
    • checkLoadedChunk

      public void checkLoadedChunk(BlockVector3 pt)
      Description copied from interface: World
      Load the chunk at the given position if it isn't loaded.
      Specified by:
      checkLoadedChunk in interface World
      Overrides:
      checkLoadedChunk in class AbstractWorld
      Parameters:
      pt - the position
    • fixAfterFastMode

      public void fixAfterFastMode(Iterable<BlockVector2> chunks)
      Description copied from interface: World
      Fix the given chunks after fast mode was used.

      Fast mode makes calls to World.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.

      Specified by:
      fixAfterFastMode in interface World
      Overrides:
      fixAfterFastMode in class AbstractWorld
      Parameters:
      chunks - a list of chunk coordinates to fix
    • fixLighting

      public void fixLighting(Iterable<BlockVector2> chunks)
      Description copied from interface: World
      Relight the given chunks if possible.
      Specified by:
      fixLighting in interface World
      Overrides:
      fixLighting in class AbstractWorld
      Parameters:
      chunks - a list of chunk coordinates to fix
    • playEffect

      public boolean playEffect(Vector3 position, int type, int data)
      Description copied from interface: World
      Play the given effect.
      Specified by:
      playEffect in interface World
      Overrides:
      playEffect in class AbstractWorld
      Parameters:
      position - the position
      type - the effect type
      data - the effect data
      Returns:
      true if the effect was played
    • queueBlockBreakEffect

      public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority)
      Description copied from interface: World
      Queue a block break effect.
      Specified by:
      queueBlockBreakEffect in interface World
      Overrides:
      queueBlockBreakEffect in class AbstractWorld
      Parameters:
      server - the server
      position - the position
      blockType - the block type
      priority - the priority
      Returns:
      true if the effect was played
    • getMinimumPoint

      public BlockVector3 getMinimumPoint()
      Description copied from interface: Extent
      Get the minimum point in the extent.

      If the extent is unbounded, then a large (negative) value may be returned.

      Specified by:
      getMinimumPoint in interface Extent
      Overrides:
      getMinimumPoint in class AbstractWorld
      Returns:
      the minimum point
    • getMaximumPoint

      public BlockVector3 getMaximumPoint()
      Description copied from interface: Extent
      Get the maximum point in the extent.

      If the extent is unbounded, then a large (positive) value may be returned.

      Specified by:
      getMaximumPoint in interface Extent
      Overrides:
      getMaximumPoint in class AbstractWorld
      Returns:
      the maximum point
    • commit

      @Nullable public Operation commit()
      Description copied from interface: OutputExtent
      Return an Operation that should be called to tie up loose ends (such as to commit changes in a buffer).
      Specified by:
      commit in interface Extent
      Specified by:
      commit in interface OutputExtent
      Overrides:
      commit in class AbstractWorld
      Returns:
      an operation or null if there is none to execute
    • getWeather

      public WeatherType getWeather()
      Description copied from interface: World
      Gets the weather type of the world.
      Specified by:
      getWeather in interface World
      Overrides:
      getWeather in class AbstractWorld
      Returns:
      The weather
    • getRemainingWeatherDuration

      public long getRemainingWeatherDuration()
      Description copied from interface: World
      Gets the remaining weather duration.
      Specified by:
      getRemainingWeatherDuration in interface World
      Overrides:
      getRemainingWeatherDuration in class AbstractWorld
      Returns:
      The weather duration
    • setWeather

      public void setWeather(WeatherType weatherType)
      Description copied from interface: World
      Sets the weather type of the world.
      Specified by:
      setWeather in interface World
      Overrides:
      setWeather in class AbstractWorld
      Parameters:
      weatherType - The weather type
    • setWeather

      public void setWeather(WeatherType weatherType, long duration)
      Description copied from interface: World
      Sets the weather type of the world.
      Specified by:
      setWeather in interface World
      Overrides:
      setWeather in class AbstractWorld
      Parameters:
      weatherType - The weather type
      duration - The duration of the weather
    • setBlock

      public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException
      Throws:
      WorldEditException
    • setTile

      public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException
      Throws:
      WorldEditException
    • setBiome

      public boolean setBiome(int x, int y, int z, BiomeType biome)
    • setBiome

      public boolean setBiome(BlockVector3 position, BiomeType biome)
      Description copied from interface: OutputExtent
      Set the biome.

      As implementation varies per Minecraft version, this may set more than this position's biome. On versions prior to 1.15, this will set the entire column. On later versions it will set the 4x4x4 cube.

      Parameters:
      position - the (x, y, z) location to set the biome at
      biome - the biome to set to
      Returns:
      true if the biome was successfully set (return value may not be accurate)
    • getName

      public String getName()
      Description copied from interface: World
      Get the name of the world.
      Returns:
      a name for the world
    • setBlock

      public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException
      Description copied from interface: World
      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

      public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException
      Description copied from interface: World
      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

      public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException
      Description copied from interface: World
      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

      public Set<SideEffect> applySideEffects(BlockVector3 position, BlockState previousType, SideEffectSet sideEffectSet) throws WorldEditException
      Description copied from interface: World
      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

      public int getBlockLightLevel(BlockVector3 position)
      Description copied from interface: World
      Get the light level at the given block.
      Parameters:
      position - the position
      Returns:
      the light level (0-15)
    • clearContainerBlockContents

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

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

      public void simulateBlockMine(BlockVector3 pt)
      Description copied from interface: World
      Simulate a block being mined at the given position.
      Parameters:
      pt - the position
    • getBlockDrops

      public Collection<BaseItemStack> getBlockDrops(BlockVector3 position)
      Description copied from interface: World
      Return items that may drop by destroying this block.
      Parameters:
      position - the position
      Returns:
      Block drops
    • regenerate

      public boolean regenerate(Region region, EditSession session)
      Description copied from interface: World
      Regenerate an area.
      Parameters:
      region - the region
      session - the EditSession
      Returns:
      true if re-generation was successful
    • regenerate

      public boolean regenerate(Region region, Extent extent, RegenOptions options)
      Description copied from interface: World
      Regenerate an area.
      Parameters:
      region - the region
      extent - the Extent
      options - the regeneration options
      Returns:
      true if regeneration was successful
    • generateTree

      public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException
      Description copied from interface: World
      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
    • getSpawnPosition

      public BlockVector3 getSpawnPosition()
      Description copied from interface: World
      Gets the spawn position of this world.
      Returns:
      The spawn position
    • refreshChunk

      public void refreshChunk(int chunkX, int chunkZ)
      Description copied from interface: World
      Refresh a specific chunk. Note: only 0 is guaranteed to send all tiles / entities Note: Only 65535 is guaranteed to send all blocks
    • get

      public IChunkGet get(int x, int z)
    • sendFakeChunk

      public void sendFakeChunk(@Nullable Player player, ChunkPacket packet)
      Description copied from interface: World
      Send a fake chunk to a player.
      Parameters:
      player - may be null to send to everyone
      packet - the chunk packet
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface World
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Specified by:
      equals in interface World
      Overrides:
      equals in class Object
    • getEntities

      public List<? extends Entity> getEntities(Region region)
      Description copied from interface: Extent
      Get a list of all entities within the given region.

      If the extent is not wholly loaded (i.e. a world being simulated in the game will not have every chunk loaded), then this list may not be incomplete.

      Parameters:
      region - the region in which entities must be contained
      Returns:
      a list of entities
    • getEntities

      public List<? extends Entity> getEntities()
      Description copied from interface: Extent
      Get a list of all entities.

      If the extent is not wholly loaded (i.e. a world being simulated in the game will not have every chunk loaded), then this list may not be incomplete.

      Returns:
      a list of entities
    • createEntity

      @Nullable public Entity createEntity(Location location, BaseEntity entity)
      Description copied from interface: Extent
      Create an entity at the given location.
      Parameters:
      location - the location
      entity - the entity
      Returns:
      a reference to the created entity, or null if the entity could not be created
    • getBlock

      public BlockState getBlock(BlockVector3 position)
      Description copied from interface: InputExtent
      Get a snapshot of the block at the given location.

      If the given position is out of the bounds of the extent, then the behavior is undefined (an air block could be returned). However, null should not be returned.

      The returned block is immutable and is a snapshot of the block at the time of call. It has no position attached to it, so it could be reused in Patterns and so on.

      Parameters:
      position - position of the block
      Returns:
      the block
    • getFullBlock

      public BaseBlock getFullBlock(BlockVector3 position)
      Description copied from interface: InputExtent
      Get an immutable snapshot of the block at the given location.
      Parameters:
      position - position of the block
      Returns:
      the block
    • getBiome

      public BiomeType getBiome(BlockVector3 position)
      Description copied from interface: InputExtent
      Get the biome at the given location.

      If there is no biome available, then the ocean biome should be returned.

      As implementation varies per Minecraft version, this may not exactly get this positions biome. On versions prior to 1.15, this will get the entire column. On later versions it will get the 4x4x4 cube's biome.

      Parameters:
      position - the (x, y, z) location to check the biome at
      Returns:
      the biome at the location
      See Also:
    • flush

      public void flush()