Interface ServerLocation
- All Superinterfaces:
DataHolder
,DataHolder.Mutable
,DataSerializable
,DirectionRelativeDataHolder
,DirectionRelativeDataHolder.Mutable
,Location<ServerWorld,
,ServerLocation> ValueContainer
ServerWorld
.
Locations are immutable. Methods that change the properties of the location create a new instance.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.Mutable
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DirectionRelativeDataHolder
DirectionRelativeDataHolder.Immutable<I extends DirectionRelativeDataHolder.Immutable<I>>, DirectionRelativeDataHolder.Mutable
-
Method Summary
Modifier and TypeMethodDescriptionadd
(double x, double y, double z) Add vector components to the position on this instance, returning a new Location instance.Add another Vector3d to the position on this instance, returning a new Location instance.Add another Vector3i to the position on this instance, returning a new Location instance.Gets the highestServerLocation
at this location.Gets aLocatableBlock
.<E extends Entity>
EcreateEntity
(EntityType<E> type) Create an entity instance at the given position.Gets a snapshot of this block at the current point in time.<T> T
map
(BiFunction<ServerWorld, Vector3d, T> mapper) Calls the mapper function on the world and position.<T> T
mapBiome
(BiFunction<ServerWorld, Vector3i, T> mapper) Calls the mapper function on the world and biome position.<T> T
mapBlock
(BiFunction<ServerWorld, Vector3i, T> mapper) Calls the mapper function on the world and block position.<T> T
mapChunk
(BiFunction<ServerWorld, Vector3i, T> mapper) Calls the mapper function on the world and chunk position.static ServerLocation
of
(ResourceKey worldKey, double x, double y, double z) static ServerLocation
of
(ResourceKey worldKey, int x, int y, int z) static ServerLocation
of
(ResourceKey worldKey, Vector3d position) static ServerLocation
of
(ResourceKey worldKey, Vector3i position) static ServerLocation
of
(ServerWorld world, double x, double y, double z) static ServerLocation
of
(ServerWorld world, int x, int y, int z) static ServerLocation
of
(ServerWorld world, Vector3d position) static ServerLocation
of
(ServerWorld world, Vector3i position) relativeTo
(Direction direction) Gets the location next to this one in the given direction.relativeToBlock
(Direction direction) Gets the location next to this one in the given direction.boolean
Remove the block at this position by replacing it withBlockTypes.AIR
.boolean
restoreSnapshot
(BlockSnapshot snapshot, boolean force, BlockChangeFlag flag) Replace the block at this position with a copy of the given snapshot.scheduleBlockUpdate
(int delay, TemporalUnit temporalUnit) Adds a newScheduledUpdate
for the block at this location.scheduleBlockUpdate
(int delay, TemporalUnit temporalUnit, TaskPriority priority) Adds a newScheduledUpdate
for the block at this location.scheduleBlockUpdate
(Duration delay) Adds a newScheduledUpdate
for the block at this location.scheduleBlockUpdate
(Duration delay, TaskPriority priority) Adds a newScheduledUpdate
for the block at this location.scheduleBlockUpdate
(Ticks delay) Adds a newScheduledUpdate
for the block at this location.scheduleBlockUpdate
(Ticks delay, TaskPriority priority) Adds a newScheduledUpdate
for the block at this location.Collection
<? extends ScheduledUpdate<BlockType>> Gets a list ofScheduledUpdate
s for the block at this location.Collection
<? extends ScheduledUpdate<FluidType>> Gets a list ofScheduledUpdate
s for the fluid at this location.scheduleFluidUpdate
(int delay, TemporalUnit temporalUnit) Adds a newScheduledUpdate
for the fluid at this location.scheduleFluidUpdate
(int delay, TemporalUnit temporalUnit, TaskPriority priority) Adds a newScheduledUpdate
for the fluid at this location.scheduleFluidUpdate
(Duration delay) Adds a newScheduledUpdate
for the fluid at this location.scheduleFluidUpdate
(Duration delay, TaskPriority priority) Adds a newScheduledUpdate
for the fluid at this location.scheduleFluidUpdate
(Ticks ticks) Adds a newScheduledUpdate
for the fluid at this location.scheduleFluidUpdate
(Ticks ticks, TaskPriority priority) Adds a newScheduledUpdate
for the fluid at this location.spawnEntities
(Iterable<? extends Entity> entities) Similar tospawnEntity(Entity)
except where multiple entities can be attempted to be spawned with a customaryCause
.boolean
spawnEntity
(Entity entity) sub
(double x, double y, double z) Subtract vector components to the position on this instance, returning a new Location instance.Subtract another Vector3d to the position on this instance, returning a new Location instance.Subtract another Vector3i to the position on this instance, returning a new Location instance.withBlockPosition
(Vector3i position) Create a new instance with a new block position.withPosition
(Vector3d position) Create a new instance with a new position.withWorld
(ServerWorld world) Create a new instance with a new World.worldKey()
Gets theUUID
of the world.Methods inherited from interface org.spongepowered.api.data.DataHolder.Mutable
copyFrom, copyFrom, offer, offer, offer, offer, offerAll, offerAll, offerAll, offerAll, offerAll, offerAll, offerSingle, offerSingle, offerSingle, offerSingle, remove, remove, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeAll, removeKey, removeKey, removeSingle, removeSingle, transform, transform, tryOffer, tryOffer, tryOffer, undo
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
Methods inherited from interface org.spongepowered.api.data.DirectionRelativeDataHolder
get, getDouble, getInt, getLong
Methods inherited from interface org.spongepowered.api.world.Location
biome, biomePosition, block, blockEntity, blockPosition, blockType, blockX, blockY, blockZ, chunkPosition, fluid, hasBlock, hasBlockEntity, inWorld, isAvailable, isValid, onServer, position, setBlock, setBlock, setBlockType, setBlockType, world, worldIfAvailable, x, y, z
-
Method Details
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
worldKey
ResourceKey worldKey()Gets theUUID
of the world.- Returns:
- The world unique id
-
asLocatableBlock
LocatableBlock asLocatableBlock()Gets aLocatableBlock
.- Returns:
- The locatable block of this location.
-
map
Calls the mapper function on the world and position.- Type Parameters:
T
- The return type of the mapper- Parameters:
mapper
- The mapper- Returns:
- The results of the mapping
-
mapBlock
Calls the mapper function on the world and block position.- Type Parameters:
T
- The return type of the mapper- Parameters:
mapper
- The mapper- Returns:
- The results of the mapping
-
mapChunk
Calls the mapper function on the world and chunk position.- Type Parameters:
T
- The return type of the mapper- Parameters:
mapper
- The mapper- Returns:
- The results of the mapping
-
mapBiome
Calls the mapper function on the world and biome position.- Type Parameters:
T
- The return type of the mapper- Parameters:
mapper
- The mapper- Returns:
- The results of the mapping
-
restoreSnapshot
Replace the block at this position with a copy of the given snapshot.Changing the snapshot afterwards will not affect the block that has been placed at this location.
- Parameters:
snapshot
- The snapshotforce
- If true, forces block state to be set even if theBlockType
does not match the snapshot one.flag
- The various change flags controlling some interactions- Returns:
- True if the snapshot restore was successful
-
removeBlock
boolean removeBlock()Remove the block at this position by replacing it withBlockTypes.AIR
.This will remove any extended block data at the given position.
- Returns:
- True if the block change was successful
-
createEntity
Create an entity instance at the given position.Creating an entity does not spawn the entity into the world. An entity created means the entity can be spawned at the given location. If
Optional.empty()
was returned, the entity is not able to spawn at the given location. Furthermore, this allows for theEntity
to be customized further prior to traditional "ticking" and processing by core systems.- Parameters:
type
- The type- Returns:
- An entity, if one was created
- Throws:
IllegalArgumentException
- If the position or entity type is not valid to createIllegalStateException
- If a constructor cannot be found- See Also:
-
spawnEntity
Spawns anEntity
using the already set properties (world, position, rotation) and applicableValue
s with the specifiedCause
for spawning the entity.Note that for the
Cause
to be useful in the expectedSpawnEntityEvent
, aSpawnType
should be provided in theEventContext
for other plugins to understand and have finer control over the event.The requirements involve that all necessary setup of states and data is already preformed on the entity retrieved from the various
EntityVolume.Modifiable.createEntity(EntityType,Vector3d)
methods. Calling this will make the now-spawned entity able to be processed by various systems.If the entity was unable to spawn, the entity is not removed, but it should be taken note that there can be many reasons for a failure.
- Parameters:
entity
- The entity to spawn- Returns:
- True if successful, false if not
- See Also:
-
spawnEntities
Similar tospawnEntity(Entity)
except where multiple entities can be attempted to be spawned with a customaryCause
. The recommended use is to easily process the entity spawns without interference with the cause tracking system.- Parameters:
entities
- The entities which spawned correctly, or empty if none- Returns:
- True if any of the entities were successfully spawned
- See Also:
-
asHighestLocation
ServerLocation asHighestLocation()Gets the highestServerLocation
at this location.- Returns:
- The highest location at this location
- See Also:
-
createSnapshot
BlockSnapshot createSnapshot()Gets a snapshot of this block at the current point in time.A snapshot is disconnected from the
World
that it was taken from so changes to the original block do not affect the snapshot.- Returns:
- A snapshot
-
scheduledBlockUpdates
Collection<? extends ScheduledUpdate<BlockType>> scheduledBlockUpdates()Gets a list ofScheduledUpdate
s for the block at this location.- Returns:
- A list of scheduled block updates on this location
-
scheduleBlockUpdate
Adds a newScheduledUpdate
for the block at this location.- Parameters:
delay
- The delay before the scheduled update should be processedtemporalUnit
- The temporal unit of the delay- Returns:
- The newly created scheduled update
-
scheduleBlockUpdate
Adds a newScheduledUpdate
for the block at this location.- Parameters:
delay
- The delay, inTicks
, before the scheduled update should be processedpriority
- The priority of the scheduled update- Returns:
- The newly created scheduled update
- Throws:
IllegalArgumentException
- if the delay is infinite
-
scheduleBlockUpdate
ScheduledUpdate<BlockType> scheduleBlockUpdate(int delay, TemporalUnit temporalUnit, TaskPriority priority) Adds a newScheduledUpdate
for the block at this location.- Parameters:
delay
- The delay before the scheduled update should be processedtemporalUnit
- The temporal unit of the delaypriority
- The priority of the scheduled update- Returns:
- The newly created scheduled update
-
scheduleBlockUpdate
Adds a newScheduledUpdate
for the block at this location.- Parameters:
delay
- The delay, inTicks
, before the scheduled update should be processed- Returns:
- The newly created scheduled update
- Throws:
IllegalArgumentException
- if the delay is infinite
-
scheduleBlockUpdate
Adds a newScheduledUpdate
for the block at this location.- Parameters:
delay
- The delay before the scheduled update should be processed- Returns:
- The newly created scheduled update
-
scheduleBlockUpdate
Adds a newScheduledUpdate
for the block at this location.- Parameters:
delay
- The delay before the scheduled update should be processedpriority
- The priority of the scheduled update- Returns:
- The newly created scheduled update
-
scheduledFluidUpdates
Collection<? extends ScheduledUpdate<FluidType>> scheduledFluidUpdates()Gets a list ofScheduledUpdate
s for the fluid at this location.- Returns:
- A list of scheduled fluid updates on this location
-
scheduleFluidUpdate
Adds a newScheduledUpdate
for the fluid at this location.- Parameters:
delay
- The delay before the scheduled update should be processedtemporalUnit
- The temporal unit of the delay- Returns:
- The newly created scheduled update
-
scheduleFluidUpdate
ScheduledUpdate<FluidType> scheduleFluidUpdate(int delay, TemporalUnit temporalUnit, TaskPriority priority) Adds a newScheduledUpdate
for the fluid at this location.- Parameters:
delay
- The delay before the scheduled update should be processedtemporalUnit
- The temporal unit of the delaypriority
- The priority of the scheduled update- Returns:
- The newly created scheduled update
-
scheduleFluidUpdate
Adds a newScheduledUpdate
for the fluid at this location.- Parameters:
ticks
- The delay, inTicks
, before the scheduled update should be processed- Returns:
- The newly created scheduled update
- Throws:
IllegalArgumentException
- if the delay is infinite
-
scheduleFluidUpdate
Adds a newScheduledUpdate
for the fluid at this location.- Parameters:
ticks
- The delay, inTicks
, before the scheduled update should be processedpriority
- The priority of the scheduled update- Returns:
- The newly created scheduled update
- Throws:
IllegalArgumentException
- if the delay is infinite
-
scheduleFluidUpdate
Adds a newScheduledUpdate
for the fluid at this location.- Parameters:
delay
- The delay before the scheduled update should be processed- Returns:
- The newly created scheduled update
-
scheduleFluidUpdate
Adds a newScheduledUpdate
for the fluid at this location.- Parameters:
delay
- The delay before the scheduled update should be processedpriority
- The priority of the scheduled update- Returns:
- The newly created scheduled update
-
withWorld
Description copied from interface:Location
Create a new instance with a new World.- Specified by:
withWorld
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
world
- The new world- Returns:
- A new instance
-
withPosition
Description copied from interface:Location
Create a new instance with a new position.- Specified by:
withPosition
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
position
- The new position- Returns:
- A new instance
-
withBlockPosition
Description copied from interface:Location
Create a new instance with a new block position.- Specified by:
withBlockPosition
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
position
- The new position- Returns:
- A new instance
-
sub
Description copied from interface:Location
Subtract another Vector3d to the position on this instance, returning a new Location instance.- Specified by:
sub
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
v
- The vector to subtract- Returns:
- A new instance
-
sub
Description copied from interface:Location
Subtract another Vector3i to the position on this instance, returning a new Location instance.- Specified by:
sub
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
v
- The vector to subtract- Returns:
- A new instance
-
sub
Description copied from interface:Location
Subtract vector components to the position on this instance, returning a new Location instance.- Specified by:
sub
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
x
- The x componenty
- The y componentz
- The z component- Returns:
- A new instance
-
add
Description copied from interface:Location
Add another Vector3d to the position on this instance, returning a new Location instance.- Specified by:
add
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
v
- The vector to add- Returns:
- A new instance
-
add
Description copied from interface:Location
Add another Vector3i to the position on this instance, returning a new Location instance.- Specified by:
add
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
v
- The vector to add- Returns:
- A new instance
-
add
Description copied from interface:Location
Add vector components to the position on this instance, returning a new Location instance.- Specified by:
add
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
x
- The x componenty
- The y componentz
- The z component- Returns:
- A new instance
-
relativeTo
Description copied from interface:Location
Gets the location next to this one in the given direction. Always moves by a unit amount, even diagonally.- Specified by:
relativeTo
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
direction
- The direction to move in- Returns:
- The location in that direction
-
relativeToBlock
Description copied from interface:Location
Gets the location next to this one in the given direction. Always moves by a block amount, even diagonally.Direction.Division.SECONDARY_ORDINAL
directions are not a valid argument. These will throw an exception.- Specified by:
relativeToBlock
in interfaceLocation<ServerWorld,
ServerLocation> - Parameters:
direction
- The direction to move in- Returns:
- The location in that direction
-