public interface TeleportHelper
Location
s for Entity
s (typically ones that won't
hurt them).
Typically, the teleport helper will first determine whether the requested location is a safe one. If not, it will investigate locations close by, favouring spots closer, and favouring a location above or below over the x-z plane if two locations are equidistant.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_FLOOR_CHECK_DISTANCE
The default distance to check for a suitable floor below any candidate
location.
|
static int |
DEFAULT_HEIGHT
The default height radius to scan for safe locations.
|
static int |
DEFAULT_WIDTH
The default width radius to scan for safe locations.
|
Modifier and Type | Method and Description |
---|---|
default Optional<Location<World>> |
getSafeLocation(Location<World> location)
Gets the next safe
Location around the given location. |
default Optional<Location<World>> |
getSafeLocation(Location<World> location,
int height,
int width)
Gets the next safe
Location around the given location with a
given tolerance and search radius. |
default Optional<Location<World>> |
getSafeLocation(Location<World> location,
int height,
int width,
int floorDistance)
Gets the next safe
Location around the given location with a
given tolerance and search radius. |
Optional<Location<World>> |
getSafeLocation(Location<World> location,
int height,
int width,
int floorDistance,
TeleportHelperFilter filter,
TeleportHelperFilter... additionalFilters)
Gets the next safe
Location around the given location with a
given tolerance and search radius. |
default Optional<Location<World>> |
getSafeLocationWithBlacklist(Location<World> location,
int height,
int width,
int floorDistance,
TeleportHelperFilter... filters)
Gets the next safe
Location around the given location with a
given tolerance and search radius. |
static final int DEFAULT_HEIGHT
static final int DEFAULT_WIDTH
static final int DEFAULT_FLOOR_CHECK_DISTANCE
default Optional<Location<World>> getSafeLocation(Location<World> location)
Location
around the given location.
Safe entails that the returned location will not be somewhere that
would harm an Entity
. This method will use the default height and
width for a search area, and will check for a suitable floor up to two
blocks below any selected block.
It's possible the same location will be returned that was passed in. This means it was safe.
location
- The location to search nearby.Optional.empty()
will be returned.default Optional<Location<World>> getSafeLocation(Location<World> location, int height, int width)
Location
around the given location with a
given tolerance and search radius.
Safe entails that the returned location will not be somewhere that
would harm an Entity
.
It's possible the same location will be returned that was passed in. This means it was safe.
This method will check for a suitable floor up to two blocks below any selected block.
This method will use the default TeleportHelperFilter
location
- The location to search nearby.height
- The radius of blocks on the y-axis to search.width
- The radius of blocks on the x and z-axis to search.Optional.empty()
will be returneddefault Optional<Location<World>> getSafeLocation(Location<World> location, int height, int width, int floorDistance)
Location
around the given location with a
given tolerance and search radius.
Safe entails that the returned location will not be somewhere that
would harm an Entity
.
It's possible the same location will be returned that was passed in. This means it was safe.
This method will use the default TeleportHelperFilter
and will
respect the blacklist.
location
- The location to search nearby.height
- The radius of blocks on the y-axis to search.width
- The radius of blocks on the x and z-axis to search.floorDistance
- The number of blocks below a selected block to
search for a suitable floor, that is, the
maximum distance to a floor that the selected
point can be. If this is zero or negative, a floor
check will not be performed.Optional.empty()
will be returnedOptional<Location<World>> getSafeLocation(Location<World> location, int height, int width, int floorDistance, TeleportHelperFilter filter, TeleportHelperFilter... additionalFilters)
Location
around the given location with a
given tolerance and search radius.
Safe entails that the returned location will not be somewhere that
would harm an Entity
.
It's possible the same location will be returned that was passed in. This means it was safe.
location
- The location to search nearby.height
- The radius of blocks on the y-axis to search.width
- The radius of blocks on the x and z-axis to search.floorDistance
- The number of blocks below a selected block to
search for a suitable floor, that is, the
maximum distance to a floor that the selected
point can be. If this is zero or negative, a floor
check will not be performed.filter
- The TeleportHelperFilter
to use to determine if a
location is safe.additionalFilters
- Additional TeleportHelperFilter
s to
check. All filters must match for a location to
be marked as safe.Optional.empty()
will be returneddefault Optional<Location<World>> getSafeLocationWithBlacklist(Location<World> location, int height, int width, int floorDistance, TeleportHelperFilter... filters)
Location
around the given location with a
given tolerance and search radius.
Safe entails that the returned location will not be somewhere that
would harm an Entity
.
It's possible the same location will be returned that was passed in. This means it was safe.
This method will use the defined blacklist, effectively an equivalent
to adding TeleportHelperFilters.CONFIG
to the filter set.
location
- The location to search nearby.height
- The radius of blocks on the y-axis to search.width
- The radius of blocks on the x and z-axis to search.floorDistance
- The number of blocks below a selected block to
search for a suitable floor, that is, the
maximum distance to a floor that the selected
point can be. If this is zero or negative, a floor
check will not be performed.filters
- The TeleportHelperFilter
s to check, in addition
to TeleportHelperFilters.CONFIG
. All filters must
match for a location to be marked as safe.Optional.empty()
will be returned