Interface ServerLocation

    • Method Detail

      • worldKey

        ResourceKey worldKey()
        Gets the UUID of the world.
        Returns:
        The world unique id
      • map

        <T> T map​(java.util.function.BiFunction<ServerWorld,​Vector3d,​T> mapper)
        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

        <T> T mapBlock​(java.util.function.BiFunction<ServerWorld,​Vector3i,​T> mapper)
        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

        <T> T mapChunk​(java.util.function.BiFunction<ServerWorld,​Vector3i,​T> mapper)
        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

        <T> T mapBiome​(java.util.function.BiFunction<ServerWorld,​Vector3i,​T> mapper)
        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

        boolean restoreSnapshot​(BlockSnapshot snapshot,
                                boolean force,
                                BlockChangeFlag flag)
        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 snapshot
        force - If true, forces block state to be set even if the BlockType 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 with BlockTypes.AIR.

        This will remove any extended block data at the given position.

        Returns:
        True if the block change was successful
      • createEntity

        <E extends Entity> E createEntity​(EntityType<E> type)
        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 the Entity 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:
        java.lang.IllegalArgumentException - If the position or entity type is not valid to create
        java.lang.IllegalStateException - If a constructor cannot be found
        See Also:
        EntityVolume.Modifiable.createEntity(EntityType, Vector3d)
      • spawnEntity

        boolean spawnEntity​(Entity entity)
        Spawns an Entity using the already set properties (world, position, rotation) and applicable Values with the specified Cause for spawning the entity.

        Note that for the Cause to be useful in the expected SpawnEntityEvent, a SpawnType should be provided in the EventContext 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:
        EntityVolume.Modifiable.spawnEntity(Entity)
      • spawnEntities

        java.util.Collection<Entity> spawnEntities​(java.lang.Iterable<? extends Entity> entities)
        Similar to spawnEntity(Entity) except where multiple entities can be attempted to be spawned with a customary Cause. 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:
        EntityVolume.Modifiable.spawnEntities(Iterable)
      • 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

        java.util.Collection<? extends ScheduledUpdate<BlockType>> scheduledBlockUpdates()
        Gets a list of ScheduledUpdates for the block at this location.
        Returns:
        A list of scheduled block updates on this location
      • scheduleBlockUpdate

        ScheduledUpdate<BlockType> scheduleBlockUpdate​(int delay,
                                                       java.time.temporal.TemporalUnit temporalUnit)
        Adds a new ScheduledUpdate for the block at this location.
        Parameters:
        delay - The delay before the scheduled update should be processed
        temporalUnit - The temporal unit of the delay
        Returns:
        The newly created scheduled update
      • scheduleBlockUpdate

        ScheduledUpdate<BlockType> scheduleBlockUpdate​(Ticks delay,
                                                       TaskPriority priority)
        Adds a new ScheduledUpdate for the block at this location.
        Parameters:
        delay - The delay, in Ticks, before the scheduled update should be processed
        priority - The priority of the scheduled update
        Returns:
        The newly created scheduled update
      • scheduleBlockUpdate

        ScheduledUpdate<BlockType> scheduleBlockUpdate​(int delay,
                                                       java.time.temporal.TemporalUnit temporalUnit,
                                                       TaskPriority priority)
        Adds a new ScheduledUpdate for the block at this location.
        Parameters:
        delay - The delay before the scheduled update should be processed
        temporalUnit - The temporal unit of the delay
        priority - The priority of the scheduled update
        Returns:
        The newly created scheduled update
      • scheduleBlockUpdate

        ScheduledUpdate<BlockType> scheduleBlockUpdate​(Ticks delay)
        Adds a new ScheduledUpdate for the block at this location.
        Parameters:
        delay - The delay, in Ticks, before the scheduled update should be processed
        Returns:
        The newly created scheduled update
      • scheduleBlockUpdate

        ScheduledUpdate<BlockType> scheduleBlockUpdate​(java.time.Duration delay)
        Adds a new ScheduledUpdate for the block at this location.
        Parameters:
        delay - The delay before the scheduled update should be processed
        Returns:
        The newly created scheduled update
      • scheduleBlockUpdate

        ScheduledUpdate<BlockType> scheduleBlockUpdate​(java.time.Duration delay,
                                                       TaskPriority priority)
        Adds a new ScheduledUpdate for the block at this location.
        Parameters:
        delay - The delay before the scheduled update should be processed
        priority - The priority of the scheduled update
        Returns:
        The newly created scheduled update
      • scheduledFluidUpdates

        java.util.Collection<? extends ScheduledUpdate<FluidType>> scheduledFluidUpdates()
        Gets a list of ScheduledUpdates for the fluid at this location.
        Returns:
        A list of scheduled fluid updates on this location
      • scheduleFluidUpdate

        ScheduledUpdate<FluidType> scheduleFluidUpdate​(int delay,
                                                       java.time.temporal.TemporalUnit temporalUnit)
        Adds a new ScheduledUpdate for the fluid at this location.
        Parameters:
        delay - The delay before the scheduled update should be processed
        temporalUnit - The temporal unit of the delay
        Returns:
        The newly created scheduled update
      • scheduleFluidUpdate

        ScheduledUpdate<FluidType> scheduleFluidUpdate​(int delay,
                                                       java.time.temporal.TemporalUnit temporalUnit,
                                                       TaskPriority priority)
        Adds a new ScheduledUpdate for the fluid at this location.
        Parameters:
        delay - The delay before the scheduled update should be processed
        temporalUnit - The temporal unit of the delay
        priority - The priority of the scheduled update
        Returns:
        The newly created scheduled update
      • scheduleFluidUpdate

        ScheduledUpdate<FluidType> scheduleFluidUpdate​(Ticks ticks)
        Adds a new ScheduledUpdate for the fluid at this location.
        Parameters:
        ticks - The delay, in Ticks, before the scheduled update should be processed
        Returns:
        The newly created scheduled update
      • scheduleFluidUpdate

        ScheduledUpdate<FluidType> scheduleFluidUpdate​(Ticks ticks,
                                                       TaskPriority priority)
        Adds a new ScheduledUpdate for the fluid at this location.
        Parameters:
        ticks - The delay, in Ticks, before the scheduled update should be processed
        priority - The priority of the scheduled update
        Returns:
        The newly created scheduled update
      • scheduleFluidUpdate

        ScheduledUpdate<FluidType> scheduleFluidUpdate​(java.time.Duration delay)
        Adds a new ScheduledUpdate for the fluid at this location.
        Parameters:
        delay - The delay before the scheduled update should be processed
        Returns:
        The newly created scheduled update
      • scheduleFluidUpdate

        ScheduledUpdate<FluidType> scheduleFluidUpdate​(java.time.Duration delay,
                                                       TaskPriority priority)
        Adds a new ScheduledUpdate for the fluid at this location.
        Parameters:
        delay - The delay before the scheduled update should be processed
        priority - The priority of the scheduled update
        Returns:
        The newly created scheduled update
      • sub

        ServerLocation sub​(double x,
                           double y,
                           double z)
        Description copied from interface: Location
        Subtract vector components to the position on this instance, returning a new Location instance.
        Specified by:
        sub in interface Location<ServerWorld,​ServerLocation>
        Parameters:
        x - The x component
        y - The y component
        z - The z component
        Returns:
        A new instance
      • add

        ServerLocation add​(double x,
                           double y,
                           double z)
        Description copied from interface: Location
        Add vector components to the position on this instance, returning a new Location instance.
        Specified by:
        add in interface Location<ServerWorld,​ServerLocation>
        Parameters:
        x - The x component
        y - The y component
        z - The z component
        Returns:
        A new instance
      • relativeTo

        ServerLocation relativeTo​(Direction direction)
        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 interface Location<ServerWorld,​ServerLocation>
        Parameters:
        direction - The direction to move in
        Returns:
        The location in that direction