Interface SpawnUtils


public interface SpawnUtils
Utility class providing world-level spawn validation and location helpers for RareSpawns.

Methods fall into three categories:

All methods are static; this class is not intended to be instantiated.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Random
    Shared Random instance for location generation.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    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).
    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.
    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.
    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.
    static boolean
    isWithinVerticalSpawnRange(org.bukkit.Location location, org.bukkit.Location location1)
    Checks if two locations are within a certain vertical distance of each other.
  • Field Details

    • random

      static final Random 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.