Record Class TicketController

java.lang.Object
java.lang.Record
net.neoforged.neoforge.common.world.chunk.TicketController
Record Components:
id - the ID of this controller
callback - a callback to be called when the tickets are loaded, in order to validate whether they're still active or not. null should be used when a callback needn't be provided

@ParametersAreNonnullByDefault public record TicketController(net.minecraft.resources.ResourceLocation id, @Nullable LoadingValidationCallback callback) extends Record
A class used to manage chunk loading tickets associated with a specific ID.

Controllers must be registered via RegisterTicketControllersEvent. A controller that isn't registered will have all of its tickets discarded when the world is loaded, and any attempts at force-loading a chunk through it will result in an IllegalArgumentException.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final @Nullable LoadingValidationCallback
    The field for the callback record component.
    private final net.minecraft.resources.ResourceLocation
    The field for the id record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TicketController(net.minecraft.resources.ResourceLocation id)
    Creates a ticket controller without a validation callback.
    TicketController(net.minecraft.resources.ResourceLocation id, @Nullable LoadingValidationCallback callback)
    Creates an instance of a TicketController record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the callback record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
    forceChunk(net.minecraft.server.level.ServerLevel level, UUID owner, int chunkX, int chunkZ, boolean add, boolean ticking)
    Forces a chunk to be loaded with the "owner" of the ticket being a given UUID.
    boolean
    forceChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos owner, int chunkX, int chunkZ, boolean add, boolean forceNaturalSpawning)
    Forces a chunk to be loaded with the "owner" of the ticket being a given block position.
    boolean
    forceChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.Entity owner, int chunkX, int chunkZ, boolean add, boolean forceNaturalSpawning)
    Forces a chunk to be loaded with the "owner" of the ticket being the UUID of the given entity.
    final int
    Returns a hash code value for this object.
    net.minecraft.resources.ResourceLocation
    id()
    Returns the value of the id record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • id

      private final net.minecraft.resources.ResourceLocation id
      The field for the id record component.
    • callback

      @Nullable private final @Nullable LoadingValidationCallback callback
      The field for the callback record component.
  • Constructor Details

    • TicketController

      public TicketController(net.minecraft.resources.ResourceLocation id, @Nullable @Nullable LoadingValidationCallback callback)
      Creates an instance of a TicketController record class.
      Parameters:
      id - the value for the id record component
      callback - the value for the callback record component
    • TicketController

      public TicketController(net.minecraft.resources.ResourceLocation id)
      Creates a ticket controller without a validation callback.
      Parameters:
      id - the ID of the controller
  • Method Details

    • forceChunk

      public boolean forceChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos owner, int chunkX, int chunkZ, boolean add, boolean forceNaturalSpawning)
      Forces a chunk to be loaded with the "owner" of the ticket being a given block position.
      Parameters:
      add - true to force the chunk, false to unforce the chunk.
      forceNaturalSpawning - true to make the chunk allow natural mob spawns even if there is no player nearby.
    • forceChunk

      public boolean forceChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.Entity owner, int chunkX, int chunkZ, boolean add, boolean forceNaturalSpawning)
      Forces a chunk to be loaded with the "owner" of the ticket being the UUID of the given entity.
      Parameters:
      add - true to force the chunk, false to unforce the chunk.
      forceNaturalSpawning - true to make the chunk allow natural mob spawns even if there is no player nearby.
    • forceChunk

      public boolean forceChunk(net.minecraft.server.level.ServerLevel level, UUID owner, int chunkX, int chunkZ, boolean add, boolean ticking)
      Forces a chunk to be loaded with the "owner" of the ticket being a given UUID.
      Parameters:
      add - true to force the chunk, false to unforce the chunk.
      ticking - true to make the chunk receive full chunk ticks even if there is no player nearby.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public net.minecraft.resources.ResourceLocation id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • callback

      @Nullable public @Nullable LoadingValidationCallback callback()
      Returns the value of the callback record component.
      Returns:
      the value of the callback record component