Interface TeleportHelper
ServerLocations for Entitys (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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default distance to check for a suitable floor below any candidate location.static final intThe default height radius to scan for safe locations.static final intThe default width radius to scan for safe locations. -
Method Summary
Modifier and TypeMethodDescriptiondefault Optional<ServerLocation> findSafeLocation(ServerLocation location) Gets the next safeServerLocationaround the given location.default Optional<ServerLocation> findSafeLocation(ServerLocation location, int height, int width) Gets the next safeServerLocationaround the given location with a given tolerance and search radius.default Optional<ServerLocation> findSafeLocation(ServerLocation location, int height, int width, int floorDistance) Gets the next safeServerLocationaround the given location with a given tolerance and search radius.findSafeLocation(ServerLocation location, int height, int width, int floorDistance, TeleportHelperFilter filter, TeleportHelperFilter... additionalFilters) Gets the next safeServerLocationaround the given location with a given tolerance and search radius.default Optional<ServerLocation> findSafeLocationWithBlacklist(ServerLocation location, int height, int width, int floorDistance, TeleportHelperFilter... filters) Gets the next safeServerLocationaround the given location with a given tolerance and search radius.
-
Field Details
-
DEFAULT_HEIGHT
static final int DEFAULT_HEIGHTThe default height radius to scan for safe locations.- See Also:
-
DEFAULT_WIDTH
static final int DEFAULT_WIDTHThe default width radius to scan for safe locations.- See Also:
-
DEFAULT_FLOOR_CHECK_DISTANCE
static final int DEFAULT_FLOOR_CHECK_DISTANCEThe default distance to check for a suitable floor below any candidate location.- See Also:
-
-
Method Details
-
findSafeLocation
Gets the next safeServerLocationaround 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.
- Parameters:
location- The location to search nearby.- Returns:
- A safe location near the original location or the original
location if it is deemed safe. If no safe location can be found,
Optional.empty()will be returned.
-
findSafeLocation
Gets the next safeServerLocationaround 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- Parameters:
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.- Returns:
- A safe location near the original location or the original
location if it is deemed safe. If no safe location can be found,
Optional.empty()will be returned
-
findSafeLocation
default Optional<ServerLocation> findSafeLocation(ServerLocation location, int height, int width, int floorDistance) Gets the next safeServerLocationaround 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
TeleportHelperFilterand will respect the blacklist.- Parameters:
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.- Returns:
- A safe location near the original location or the original
location if it is deemed safe. If no safe location can be found,
Optional.empty()will be returned
-
findSafeLocation
Optional<ServerLocation> findSafeLocation(ServerLocation location, int height, int width, int floorDistance, TeleportHelperFilter filter, TeleportHelperFilter... additionalFilters) Gets the next safeServerLocationaround 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.
- Parameters:
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- TheTeleportHelperFilterto use to determine if a location is safe.additionalFilters- AdditionalTeleportHelperFilters to check. All filters must match for a location to be marked as safe.- Returns:
- A safe location near the original location or the original
location if it is deemed safe. If no safe location can be found,
Optional.empty()will be returned
-
findSafeLocationWithBlacklist
default Optional<ServerLocation> findSafeLocationWithBlacklist(ServerLocation location, int height, int width, int floorDistance, TeleportHelperFilter... filters) Gets the next safeServerLocationaround 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.CONFIGto the filter set.- Parameters:
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- TheTeleportHelperFilters to check, in addition toTeleportHelperFilters.CONFIG. All filters must match for a location to be marked as safe.- Returns:
- A safe location near the original location or the original
location if it is deemed safe. If no safe location can be found,
Optional.empty()will be returned
-