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 ClassesNested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.MutableNested 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 highestServerLocationat 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> Tmap(BiFunction<ServerWorld, Vector3d, T> mapper) Calls the mapper function on the world and position.<T> TmapBiome(BiFunction<ServerWorld, Vector3i, T> mapper) Calls the mapper function on the world and biome position.<T> TmapBlock(BiFunction<ServerWorld, Vector3i, T> mapper) Calls the mapper function on the world and block position.<T> TmapChunk(BiFunction<ServerWorld, Vector3i, T> mapper) Calls the mapper function on the world and chunk position.static ServerLocationof(ResourceKey worldKey, double x, double y, double z) static ServerLocationof(ResourceKey worldKey, int x, int y, int z) static ServerLocationof(ResourceKey worldKey, Vector3d position) static ServerLocationof(ResourceKey worldKey, Vector3i position) static ServerLocationof(ServerWorld world, double x, double y, double z) static ServerLocationof(ServerWorld world, int x, int y, int z) static ServerLocationof(ServerWorld world, Vector3d position) static ServerLocationof(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.booleanRemove the block at this position by replacing it withBlockTypes.AIR.booleanrestoreSnapshot(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 newScheduledUpdatefor the block at this location.scheduleBlockUpdate(int delay, TemporalUnit temporalUnit, TaskPriority priority) Adds a newScheduledUpdatefor the block at this location.scheduleBlockUpdate(Duration delay) Adds a newScheduledUpdatefor the block at this location.scheduleBlockUpdate(Duration delay, TaskPriority priority) Adds a newScheduledUpdatefor the block at this location.scheduleBlockUpdate(Ticks delay) Adds a newScheduledUpdatefor the block at this location.scheduleBlockUpdate(Ticks delay, TaskPriority priority) Adds a newScheduledUpdatefor the block at this location.Collection<? extends ScheduledUpdate<BlockType>> Gets a list ofScheduledUpdates for the block at this location.Collection<? extends ScheduledUpdate<FluidType>> Gets a list ofScheduledUpdates for the fluid at this location.scheduleFluidUpdate(int delay, TemporalUnit temporalUnit) Adds a newScheduledUpdatefor the fluid at this location.scheduleFluidUpdate(int delay, TemporalUnit temporalUnit, TaskPriority priority) Adds a newScheduledUpdatefor the fluid at this location.scheduleFluidUpdate(Duration delay) Adds a newScheduledUpdatefor the fluid at this location.scheduleFluidUpdate(Duration delay, TaskPriority priority) Adds a newScheduledUpdatefor the fluid at this location.scheduleFluidUpdate(Ticks ticks) Adds a newScheduledUpdatefor the fluid at this location.scheduleFluidUpdate(Ticks ticks, TaskPriority priority) Adds a newScheduledUpdatefor 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.booleanspawnEntity(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 theUUIDof 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, undoMethods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainerMethods inherited from interface org.spongepowered.api.data.DirectionRelativeDataHolder
get, getDouble, getInt, getLongMethods 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 theUUIDof 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 theBlockTypedoes 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 theEntityto 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 anEntityusing the already set properties (world, position, rotation) and applicableValues with the specifiedCausefor spawning the entity.Note that for the
Causeto be useful in the expectedSpawnEntityEvent, aSpawnTypeshould be provided in theEventContextfor 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 highestServerLocationat 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
Worldthat 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 ofScheduledUpdates for the block at this location.- Returns:
- A list of scheduled block updates on this location
-
scheduleBlockUpdate
Adds a newScheduledUpdatefor 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 newScheduledUpdatefor 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 newScheduledUpdatefor 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 newScheduledUpdatefor 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 newScheduledUpdatefor 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 newScheduledUpdatefor 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 ofScheduledUpdates for the fluid at this location.- Returns:
- A list of scheduled fluid updates on this location
-
scheduleFluidUpdate
Adds a newScheduledUpdatefor 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 newScheduledUpdatefor 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 newScheduledUpdatefor 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 newScheduledUpdatefor 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 newScheduledUpdatefor 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 newScheduledUpdatefor 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:LocationCreate a new instance with a new World.- Specified by:
withWorldin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
world- The new world- Returns:
- A new instance
-
withPosition
Description copied from interface:LocationCreate a new instance with a new position.- Specified by:
withPositionin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
position- The new position- Returns:
- A new instance
-
withBlockPosition
Description copied from interface:LocationCreate a new instance with a new block position.- Specified by:
withBlockPositionin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
position- The new position- Returns:
- A new instance
-
sub
Description copied from interface:LocationSubtract another Vector3d to the position on this instance, returning a new Location instance.- Specified by:
subin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
v- The vector to subtract- Returns:
- A new instance
-
sub
Description copied from interface:LocationSubtract another Vector3i to the position on this instance, returning a new Location instance.- Specified by:
subin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
v- The vector to subtract- Returns:
- A new instance
-
sub
Description copied from interface:LocationSubtract vector components to the position on this instance, returning a new Location instance.- Specified by:
subin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
x- The x componenty- The y componentz- The z component- Returns:
- A new instance
-
add
Description copied from interface:LocationAdd another Vector3d to the position on this instance, returning a new Location instance.- Specified by:
addin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
v- The vector to add- Returns:
- A new instance
-
add
Description copied from interface:LocationAdd another Vector3i to the position on this instance, returning a new Location instance.- Specified by:
addin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
v- The vector to add- Returns:
- A new instance
-
add
Description copied from interface:LocationAdd vector components to the position on this instance, returning a new Location instance.- Specified by:
addin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
x- The x componenty- The y componentz- The z component- Returns:
- A new instance
-
relativeTo
Description copied from interface:LocationGets the location next to this one in the given direction. Always moves by a unit amount, even diagonally.- Specified by:
relativeToin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
direction- The direction to move in- Returns:
- The location in that direction
-
relativeToBlock
Description copied from interface:LocationGets the location next to this one in the given direction. Always moves by a block amount, even diagonally.Direction.Division.SECONDARY_ORDINALdirections are not a valid argument. These will throw an exception.- Specified by:
relativeToBlockin interfaceLocation<ServerWorld,ServerLocation> - Parameters:
direction- The direction to move in- Returns:
- The location in that direction
-