Package valorless.rarespawns.world
Interface SpawnUtils
public interface SpawnUtils
Utility class providing world-level spawn validation and location helpers for RareSpawns.
Methods fall into three categories:
- Spawn validity —
isValidNaturalSpawnLocation(Location)uses NMSSpawnPlacementsvia reflection to replicate vanilla spawn checks, with a pure-Bukkitfallbackfor unsupported versions. - Location selection —
getRandomSpawnLocation(Location, Integer, Integer)picks a random candidate position in the vanilla natural-spawn radius (24–128 blocks), walking downward from the highest block to find solid, non-tree, non-structure ground. - World queries —
isBlockNearby(Location, Material, int),isTreeOrStructure(Material), andisWithinVerticalSpawnRange(Location, Location)provide lightweight spatial checks used by the spawn pipeline.
All methods are static; this class is not intended to be instantiated.
-
Field Summary
Fields -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic org.bukkit.LocationgetRandomSpawnLocation(org.bukkit.Location origin, Integer min, Integer max) Picks a random candidate spawn location near an origin point, within Minecraft's natural spawn range (24–128 blocks away).static booleanisBlockNearby(org.bukkit.Location loc, org.bukkit.Material material, int radius) Checks for the presence of a specific block type within a certain radius of a location.static booleanisTreeOrStructure(org.bukkit.Material material) Returns true if the given material is considered part of a tree or player-built structure, and should be skipped as a spawn surface.static booleanisValidNaturalSpawnLocation(org.bukkit.Location loc) Checks whether the given location is valid for a natural mob spawn, using NMS NaturalSpawner logic via reflection.static booleanisWithinVerticalSpawnRange(org.bukkit.Location location, org.bukkit.Location location1) Checks if two locations are within a certain vertical distance of each other.
-
Field Details
-
random
Shared Random instance for location generation.
-
-
Method Details
-
isValidNaturalSpawnLocation
static boolean isValidNaturalSpawnLocation(org.bukkit.Location loc) Checks whether the given location is valid for a natural mob spawn, using NMS NaturalSpawner logic via reflection. Falls back to a basic Bukkit check if NMS fails.- Parameters:
loc- The location to check.- Returns:
- true if the location passes spawn validity checks.
-
getRandomSpawnLocation
static org.bukkit.Location getRandomSpawnLocation(org.bukkit.Location origin, Integer min, Integer max) Picks a random candidate spawn location near an origin point, within Minecraft's natural spawn range (24–128 blocks away). Finds the highest natural ground block, skipping trees and structures.- Parameters:
origin- The origin point (e.g. a player's location).- Returns:
- A candidate spawn Location at ground level, or null if no valid ground found.
-
isTreeOrStructure
static boolean isTreeOrStructure(org.bukkit.Material material) Returns true if the given material is considered part of a tree or player-built structure, and should be skipped as a spawn surface.- Parameters:
material- The material to check.- Returns:
- true if the material should be skipped.
-
isBlockNearby
static boolean isBlockNearby(org.bukkit.Location loc, org.bukkit.Material material, int radius) Checks for the presence of a specific block type within a certain radius of a location.- Parameters:
loc- The center location to check around.material- The block material to look for.radius- The radius (in blocks) to search within.- Returns:
- true if at least one block of the specified material is found within the radius; false otherwise.
-
isWithinVerticalSpawnRange
static boolean isWithinVerticalSpawnRange(org.bukkit.Location location, org.bukkit.Location location1) Checks if two locations are within a certain vertical distance of each other.- Parameters:
location- The first location.location1- The second location.- Returns:
- true if the vertical distance between the two locations is within the specified range; false otherwise.
-