public class LocalWorldAdapter extends LocalWorld
World
s into LocalWorld
.Modifier and Type | Method and Description |
---|---|
static LocalWorldAdapter |
adapt(World world) |
void |
checkLoadedChunk(Vector position)
Load the chunk at the given position if it isn't loaded.
|
boolean |
clearContainerBlockContents(Vector position)
Clear a chest's contents.
|
Operation |
commit()
Return an
Operation that should be called to tie up loose ends
(such as to commit changes in a buffer). |
Entity |
createEntity(Location location,
BaseEntity entity)
Create an entity at the given location.
|
Mask |
createLiquidMask()
Create a mask that matches all liquids.
|
void |
dropItem(Vector position,
BaseItemStack item)
Drop one stack of the item at the given position.
|
void |
dropItem(Vector position,
BaseItemStack item,
int count)
Drop an item at the given position.
|
boolean |
equals(java.lang.Object other) |
void |
fixAfterFastMode(java.lang.Iterable<BlockVector2D> chunks)
Fix the given chunks after fast mode was used.
|
void |
fixLighting(java.lang.Iterable<BlockVector2D> chunks)
Relight the given chunks if possible.
|
boolean |
generateBigTree(EditSession editSession,
Vector position)
Deprecated.
|
boolean |
generateBirchTree(EditSession editSession,
Vector position)
Deprecated.
|
boolean |
generateRedwoodTree(EditSession editSession,
Vector position)
Deprecated.
|
boolean |
generateTallRedwoodTree(EditSession editSession,
Vector position)
Deprecated.
|
boolean |
generateTree(EditSession editSession,
Vector position)
Deprecated.
|
boolean |
generateTree(TreeGenerator.TreeType type,
EditSession editSession,
Vector position)
Generate a tree at the given position.
|
BaseBiome |
getBiome(Vector2D position)
Get the biome at the given location.
|
BaseBlock |
getBlock(Vector position)
Get a snapshot of the block at the given location.
|
int |
getBlockData(Vector pt)
Deprecated.
|
int |
getBlockLightLevel(Vector position)
Get the light level at the given block.
|
int |
getBlockType(Vector pt)
Deprecated.
|
java.util.List<? extends Entity> |
getEntities()
Get a list of all entities.
|
java.util.List<? extends Entity> |
getEntities(Region region)
Get a list of all entities within the given region.
|
BaseBlock |
getLazyBlock(Vector position)
Get a lazy, immutable snapshot of the block at the given location that only
immediately contains information about the block's type (and metadata).
|
Vector |
getMaximumPoint()
Get the maximum point in the extent.
|
int |
getMaxY()
Get the maximum Y.
|
Vector |
getMinimumPoint()
Get the minimum point in the extent.
|
java.lang.String |
getName()
Get the name of the world.
|
WorldData |
getWorldData()
Get the data for blocks and so on for this world.
|
int |
hashCode() |
boolean |
isValidBlockType(int id)
Checks whether the given block ID is a valid block ID.
|
boolean |
playEffect(Vector position,
int type,
int data)
Play the given effect.
|
boolean |
queueBlockBreakEffect(Platform server,
Vector position,
int blockId,
double priority)
Queue a block break effect.
|
boolean |
regenerate(Region region,
EditSession editSession)
Regenerate an area.
|
boolean |
setBiome(Vector2D position,
BaseBiome biome)
Set the biome.
|
boolean |
setBlock(Vector position,
BaseBlock block,
boolean notifyAndLight)
Similar to
OutputExtent.setBlock(Vector, BaseBlock) but a
notifyAndLight parameter indicates whether adjacent blocks
should be notified that changes have been made and lighting operations
should be executed. |
void |
simulateBlockMine(Vector position)
Simulate a block being mined at the given position.
|
boolean |
usesBlockData(int id)
Checks whether the given block ID uses data values for differentiating
types of blocks.
|
setBlock, setBlockData, setBlockType, setTypeIdAndData, useItem
public java.lang.String getName()
World
public int getMaxY()
World
getMaxY
in interface World
getMaxY
in class AbstractWorld
public boolean isValidBlockType(int id)
World
isValidBlockType
in interface World
isValidBlockType
in class AbstractWorld
id
- the block IDpublic boolean usesBlockData(int id)
World
usesBlockData
in interface World
usesBlockData
in class AbstractWorld
id
- the block IDpublic Mask createLiquidMask()
World
Implementations should override this so that custom liquids are supported.
createLiquidMask
in interface World
createLiquidMask
in class AbstractWorld
@Deprecated public int getBlockType(Vector pt)
getBlockType
in interface World
getBlockType
in class AbstractWorld
@Deprecated public int getBlockData(Vector pt)
getBlockData
in interface World
getBlockData
in class AbstractWorld
public boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException
World
OutputExtent.setBlock(Vector, BaseBlock)
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.
position
- position of the blockblock
- block to setnotifyAndLight
- true to to notify and lightWorldEditException
public int getBlockLightLevel(Vector position)
World
position
- the positionpublic boolean clearContainerBlockContents(Vector position)
World
position
- the positionpublic BaseBiome getBiome(Vector2D position)
InputExtent
If there is no biome available, then the ocean biome should be returned.
position
- the (x, z) location to check the biome atpublic boolean setBiome(Vector2D position, BaseBiome biome)
OutputExtent
position
- the (x, z) location to set the biome atbiome
- the biome to set topublic void dropItem(Vector position, BaseItemStack item, int count)
World
dropItem
in interface World
dropItem
in class AbstractWorld
position
- the positionitem
- the item to dropcount
- the number of individual stacks to drop (number of item entities)public void dropItem(Vector position, BaseItemStack item)
World
position
- the positionitem
- the item to dropshortcut method to specify the number of stacks
public void simulateBlockMine(Vector position)
World
simulateBlockMine
in interface World
simulateBlockMine
in class AbstractWorld
position
- the positionpublic boolean regenerate(Region region, EditSession editSession)
World
region
- the regioneditSession
- the EditSession
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException
World
generateTree
in interface World
generateTree
in class LocalWorld
type
- the tree typeeditSession
- the EditSession
position
- the positionMaxChangedBlocksException
- thrown if too many blocks were changed@Deprecated public boolean generateTree(EditSession editSession, Vector position) throws MaxChangedBlocksException
generateTree
in interface World
generateTree
in class LocalWorld
MaxChangedBlocksException
@Deprecated public boolean generateBigTree(EditSession editSession, Vector position) throws MaxChangedBlocksException
generateBigTree
in interface World
generateBigTree
in class LocalWorld
MaxChangedBlocksException
@Deprecated public boolean generateBirchTree(EditSession editSession, Vector position) throws MaxChangedBlocksException
generateBirchTree
in interface World
generateBirchTree
in class LocalWorld
MaxChangedBlocksException
@Deprecated public boolean generateRedwoodTree(EditSession editSession, Vector position) throws MaxChangedBlocksException
generateRedwoodTree
in interface World
generateRedwoodTree
in class LocalWorld
MaxChangedBlocksException
@Deprecated public boolean generateTallRedwoodTree(EditSession editSession, Vector position) throws MaxChangedBlocksException
generateTallRedwoodTree
in interface World
generateTallRedwoodTree
in class LocalWorld
MaxChangedBlocksException
public void checkLoadedChunk(Vector position)
World
checkLoadedChunk
in interface World
checkLoadedChunk
in class AbstractWorld
position
- the positionpublic void fixAfterFastMode(java.lang.Iterable<BlockVector2D> chunks)
World
Fast mode makes calls to World.setBlock(Vector, BaseBlock, 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.
fixAfterFastMode
in interface World
fixAfterFastMode
in class AbstractWorld
chunks
- a list of chunk coordinates to fixpublic void fixLighting(java.lang.Iterable<BlockVector2D> chunks)
World
fixLighting
in interface World
fixLighting
in class AbstractWorld
chunks
- a list of chunk coordinates to fixpublic boolean playEffect(Vector position, int type, int data)
World
playEffect
in interface World
playEffect
in class AbstractWorld
position
- the positiontype
- the effect typedata
- the effect datapublic boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority)
World
queueBlockBreakEffect
in interface World
queueBlockBreakEffect
in class AbstractWorld
server
- the serverposition
- the positionblockId
- the block IDpriority
- the prioritypublic WorldData getWorldData()
World
public boolean equals(java.lang.Object other)
public int hashCode()
public Vector getMinimumPoint()
Extent
If the extent is unbounded, then a large (negative) value may be returned.
getMinimumPoint
in interface Extent
getMinimumPoint
in class AbstractWorld
public Vector getMaximumPoint()
Extent
If the extent is unbounded, then a large (positive) value may be returned.
getMaximumPoint
in interface Extent
getMaximumPoint
in class AbstractWorld
public java.util.List<? extends Entity> getEntities(Region region)
Extent
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.
region
- the region in which entities must be containedpublic BaseBlock getBlock(Vector position)
InputExtent
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 mutable 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
Pattern
s and so on.
Calls to this method can actually be quite expensive, so cache results
whenever it is possible, while being aware of the mutability aspect.
The cost, however, depends on the implementation and particular extent.
If only basic information about the block is required, then use of
InputExtent.getLazyBlock(Vector)
is recommended.
position
- position of the blockpublic BaseBlock getLazyBlock(Vector position)
InputExtent
Further information (such as NBT data) will be available by the time of access. Therefore, it is not recommended that this method is used if the world is being simulated at the time of call. If the block needs to be stored for future use, then this method should definitely not be used. Moreover, the block that is returned is immutable (or should be), and therefore modifications should not be attempted on it. If a modifiable copy is required, then the block should be cloned.
This method exists because it is sometimes important to inspect the block
at a given location, but InputExtent.getBlock(Vector)
may be too expensive in
the underlying implementation. It is also not possible to implement
caching if the returned object is mutable, so this methods allows caching
implementations to be used.
getLazyBlock
in interface InputExtent
getLazyBlock
in class LocalWorld
position
- position of the block@Nullable public Operation commit()
OutputExtent
Operation
that should be called to tie up loose ends
(such as to commit changes in a buffer).commit
in interface OutputExtent
commit
in class AbstractWorld
@Nullable public Entity createEntity(Location location, BaseEntity entity)
Extent
location
- the locationentity
- the entitypublic java.util.List<? extends Entity> getEntities()
Extent
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.
public static LocalWorldAdapter adapt(World world)