Class WildernessTracker

java.lang.Object
com.hypixel.hytale.builtin.adventure.wilderness.resource.WildernessTracker
All Implemented Interfaces:
Resource<ChunkStore>, Cloneable

public class WildernessTracker extends Object implements Resource<ChunkStore>
Tracks wilderness and home chunk regions within a world.

Provides functionality to determine whether a position or chunk is in a "wilderness" region or a "home" region, as well as tools for managing and querying these regions. Gameplay systems can use this information to specify certain game events occur specifically in parts of the world that match either of these categories.

The current implementation defines a "home" chunk as one being within a given elliptic radius of a player bed, and "wilderness" chunks being those outside that radius. This may be expanded upon in the future to consider more factors when determining a home chunk vs wilderness chunk.

  • Field Summary

    Fields inherited from interface Resource

    EMPTY_ARRAY
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new WildernessTracker with default radius settings.
    Copy constructor for WildernessTracker.
    Constructs a new WildernessTracker with settings from the provided configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addHomeChunk(int chunkX, int chunkY, int chunkZ, boolean owned)
    Marks a chunk (and its surrounding radius) as being near a "home".
    Creates a clone of this tracker.
    void
    collectHomeChunks(int x, int y, int z, int radiusX, int radiusY, int radiusZ, Collection<org.joml.Vector3i> collector)
    Collects all chunks within the specified radius from world coordinates that are considered home.
    void
    collectHomeChunks(org.joml.Vector3d position, int radiusX, int radiusY, int radiusZ, Collection<org.joml.Vector3i> collector)
    Collects all chunks within the specified radius from a world position that are considered home chunks.
    void
    collectHomeChunks(org.joml.Vector3i position, int radiusX, int radiusY, int radiusZ, Collection<org.joml.Vector3i> collector)
    Collects all chunks within the specified radius from a position that are considered home chunks.
    void
    collectWildernessChunks(int x, int y, int z, int radiusX, int radiusY, int radiusZ, Collection<org.joml.Vector3i> collector)
    Collects all chunks within the specified radius from world coordinates that are considered wilderness.
    void
    collectWildernessChunks(org.joml.Vector3d position, int radiusX, int radiusY, int radiusZ, Collection<org.joml.Vector3i> collector)
    Collects all chunks within the specified radius from a world position that are considered wilderness.
    void
    collectWildernessChunks(org.joml.Vector3i position, int radiusX, int radiusY, int radiusZ, Collection<org.joml.Vector3i> collector)
    Collects all chunks within the specified radius from a position that are considered wilderness.
    long
    Get the generation count of the WildernessTracker.
    Gets the resource type for the wilderness tracker.
    Retrieves the WildernessTracker associated with the given World.
    boolean
    Checks if the wilderness tracking is disabled.
    boolean
    Checks if the wilderness tracking is enabled.
    boolean
    isHome(int x, int y, int z)
    Checks if the specified world coordinates are in a home chunk.
    boolean
    isHome(org.joml.Vector3d position)
    Checks if the specified world position is in a home chunk.
    boolean
    isHome(org.joml.Vector3i position)
    Checks if the specified chunk position is considered a home chunk.
    boolean
    isWilderness(int x, int y, int z)
    Checks if the specified world coordinates are in wilderness.
    boolean
    isWilderness(org.joml.Vector3d position)
    Checks if the specified world position is in wilderness.
    boolean
    isWilderness(org.joml.Vector3i position)
    Checks if the specified chunk position is considered wilderness.
    boolean
    isWildernessChunk(int chunkX, int chunkY, int chunkZ)
     
    boolean
    isWildernessChunk(org.joml.Vector3i coords)
     
    void
    removeHomeChunk(int chunkX, int chunkY, int chunkZ, boolean owned)
    Unmarks a chunk (and its surrounding radius) from being near a "home".

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WildernessTracker

      public WildernessTracker()
      Constructs a new WildernessTracker with default radius settings.
    • WildernessTracker

      public WildernessTracker(@Nonnull WildernessConfig config)
      Constructs a new WildernessTracker with settings from the provided configuration.
      Parameters:
      config - the wilderness configuration.
    • WildernessTracker

      public WildernessTracker(@Nonnull WildernessTracker tracker)
      Copy constructor for WildernessTracker.
      Parameters:
      tracker - the tracker to copy from.
  • Method Details

    • clone

      @Nonnull public WildernessTracker clone()
      Creates a clone of this tracker.
      Specified by:
      clone in interface Resource<ChunkStore>
      Returns:
      a new instance of WildernessTracker with the same state.
    • generation

      public long generation()
      Get the generation count of the WildernessTracker. The generation count is incremented whenever the WildernessTracker is updated, so can be used by third-party systems to determine whether they to refresh their own state.
      Returns:
      The current generation count of the WildernessTracker.
    • isEnabled

      public boolean isEnabled()
      Checks if the wilderness tracking is enabled.
      Returns:
      true if enabled, false otherwise.
    • isDisabled

      public boolean isDisabled()
      Checks if the wilderness tracking is disabled.
      Returns:
      true if disabled, false otherwise.
    • isHome

      public boolean isHome(@Nonnull org.joml.Vector3i position)
      Checks if the specified chunk position is considered a home chunk.
      Parameters:
      position - the chunk position to check.
      Returns:
      true if it is a home chunk, false if it is wilderness.
    • isHome

      public boolean isHome(@Nonnull org.joml.Vector3d position)
      Checks if the specified world position is in a home chunk.
      Parameters:
      position - the world position to check.
      Returns:
      true if it is in a home chunk, false if it is in wilderness.
    • isHome

      public boolean isHome(int x, int y, int z)
      Checks if the specified world coordinates are in a home chunk.
      Parameters:
      x - world x-coordinate.
      y - world y-coordinate.
      z - world z-coordinate.
      Returns:
      true if it is in a home chunk, false if it is in wilderness.
    • isWilderness

      public boolean isWilderness(@Nonnull org.joml.Vector3i position)
      Checks if the specified chunk position is considered wilderness.
      Parameters:
      position - the chunk position to check.
      Returns:
      true if it is wilderness, false if it is a home chunk.
    • isWilderness

      public boolean isWilderness(@Nonnull org.joml.Vector3d position)
      Checks if the specified world position is in wilderness.
      Parameters:
      position - the world position to check.
      Returns:
      true if it is wilderness, false if it is in a home chunk.
    • isWilderness

      public boolean isWilderness(int x, int y, int z)
      Checks if the specified world coordinates are in wilderness.
      Parameters:
      x - world x-coordinate.
      y - world y-coordinate.
      z - world z-coordinate.
      Returns:
      true if it is wilderness, false if it is in a home chunk.
    • isWildernessChunk

      public boolean isWildernessChunk(int chunkX, int chunkY, int chunkZ)
    • isWildernessChunk

      public boolean isWildernessChunk(@Nonnull org.joml.Vector3i coords)
    • collectHomeChunks

      public void collectHomeChunks(@Nonnull org.joml.Vector3i position, int radiusX, int radiusY, int radiusZ, @Nonnull Collection<org.joml.Vector3i> collector)
      Collects all chunks within the specified radius from a position that are considered home chunks.
      Parameters:
      position - the center chunk position.
      radiusX - x-radius in blocks.
      radiusY - y-radius in blocks.
      radiusZ - z-radius in blocks.
      collector - the collection to add the home chunks to.
    • collectHomeChunks

      public void collectHomeChunks(@Nonnull org.joml.Vector3d position, int radiusX, int radiusY, int radiusZ, @Nonnull Collection<org.joml.Vector3i> collector)
      Collects all chunks within the specified radius from a world position that are considered home chunks.
      Parameters:
      position - the center world position.
      radiusX - x-radius in blocks.
      radiusY - y-radius in blocks.
      radiusZ - z-radius in blocks.
      collector - the collection to add the home chunks to.
    • collectWildernessChunks

      public void collectWildernessChunks(@Nonnull org.joml.Vector3i position, int radiusX, int radiusY, int radiusZ, @Nonnull Collection<org.joml.Vector3i> collector)
      Collects all chunks within the specified radius from a position that are considered wilderness.
      Parameters:
      position - the center chunk position.
      radiusX - x-radius in blocks.
      radiusY - y-radius in blocks.
      radiusZ - z-radius in blocks.
      collector - the collection to add the wilderness chunks to.
    • collectWildernessChunks

      public void collectWildernessChunks(@Nonnull org.joml.Vector3d position, int radiusX, int radiusY, int radiusZ, @Nonnull Collection<org.joml.Vector3i> collector)
      Collects all chunks within the specified radius from a world position that are considered wilderness.
      Parameters:
      position - the center world position.
      radiusX - x-radius in blocks.
      radiusY - y-radius in blocks.
      radiusZ - z-radius in blocks.
      collector - the collection to add the wilderness chunks to.
    • collectHomeChunks

      public void collectHomeChunks(int x, int y, int z, int radiusX, int radiusY, int radiusZ, @Nonnull Collection<org.joml.Vector3i> collector)
      Collects all chunks within the specified radius from world coordinates that are considered home.
      Parameters:
      x - world x-coordinate.
      y - world y-coordinate.
      z - world z-coordinate.
      radiusX - x-radius in blocks.
      radiusY - y-radius in blocks.
      radiusZ - z-radius in blocks.
      collector - the collection to add the home chunks to.
    • collectWildernessChunks

      public void collectWildernessChunks(int x, int y, int z, int radiusX, int radiusY, int radiusZ, @Nonnull Collection<org.joml.Vector3i> collector)
      Collects all chunks within the specified radius from world coordinates that are considered wilderness.
      Parameters:
      x - world x-coordinate.
      y - world y-coordinate.
      z - world z-coordinate.
      radiusX - x-radius in blocks.
      radiusY - y-radius in blocks.
      radiusZ - z-radius in blocks.
      collector - the collection to add the wilderness chunks to.
    • addHomeChunk

      public void addHomeChunk(int chunkX, int chunkY, int chunkZ, boolean owned)
      Marks a chunk (and its surrounding radius) as being near a "home".
      Parameters:
      chunkX - chunk x-coordinate.
      chunkY - chunk y-coordinate.
      chunkZ - chunk z-coordinate.
    • removeHomeChunk

      public void removeHomeChunk(int chunkX, int chunkY, int chunkZ, boolean owned)
      Unmarks a chunk (and its surrounding radius) from being near a "home".
      Parameters:
      chunkX - chunk x-coordinate.
      chunkY - chunk y-coordinate.
      chunkZ - chunk z-coordinate.
    • getResourceType

      public static ResourceType<ChunkStore, WildernessTracker> getResourceType()
      Gets the resource type for the wilderness tracker.
      Returns:
      the resource type.
    • getTracker

      @Nonnull public static WildernessTracker getTracker(@Nonnull World world)
      Retrieves the WildernessTracker associated with the given World.
      Parameters:
      world - the World instance for which the WildernessTracker is to be retrieved. Must not be null.
      Returns:
      the WildernessTracker associated with the provided world. Never null.