Class ForcedChunkManager

java.lang.Object
net.neoforged.neoforge.common.world.chunk.ForcedChunkManager

@ParametersAreNonnullByDefault public class ForcedChunkManager extends Object
  • Field Details

    • LOGGER

      private static final org.apache.logging.log4j.Logger LOGGER
    • initialised

      private static boolean initialised
    • controllers

      private static Map<net.minecraft.resources.ResourceLocation,TicketController> controllers
  • Constructor Details

    • ForcedChunkManager

      public ForcedChunkManager()
  • Method Details

    • init

      @Internal public static void init()
    • hasForcedChunks

      public static boolean hasForcedChunks(net.minecraft.server.level.ServerLevel level)
      Checks if a level has any forced chunks. Mainly used for seeing if a level should continue ticking with no players in it.
    • forceChunk

      static <T extends Comparable<? super T>> boolean forceChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation id, T owner, int chunkX, int chunkZ, boolean add, boolean forceNaturalSpawning, Function<net.minecraft.world.level.TicketStorage,ForcedChunkManager.TicketTracker<T>> ticketGetter)
      Forces a chunk to be loaded for the given mod with the given "owner".
      Parameters:
      add - true to force the chunk, false to unforce the chunk.
    • activateAllDeactivatedTickets

      @Internal public static void activateAllDeactivatedTickets(net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.TicketStorage saveData)
      Reinstates NeoForge's forced chunks when vanilla initially loads a level and reinstates their forced chunks. This method also will validate all the forced chunks with the registered LoadingValidationCallbacks.
    • gatherTicketsById

      private static <T extends Comparable<? super T>> Map<net.minecraft.resources.ResourceLocation,Map<T,TicketSet>> gatherTicketsById(ForcedChunkManager.TicketTracker<T> tickets, boolean includeLoaded, boolean includeDeactivated)
      Gathers tickets into an ID filtered map for use in providing all tickets a controller has registered to its LoadingValidationCallback.
    • gatherTicketsById

      private static <T extends Comparable<? super T>> void gatherTicketsById(it.unimi.dsi.fastutil.longs.Long2ObjectMap<Set<ForcedChunkManager.TicketOwner<T>>> tickets, Function<TicketSet,it.unimi.dsi.fastutil.longs.LongSet> typeGetter, Map<net.minecraft.resources.ResourceLocation,Map<T,TicketSet>> modSortedOwnedChunks)
      Gathers tickets into an ID filtered map for use in providing all tickets a controller has registered to its LoadingValidationCallback.
    • defineExtraStorageParams

      @Internal public static com.mojang.datafixers.kinds.App<com.mojang.serialization.codecs.RecordCodecBuilder.Mu<net.minecraft.world.level.TicketStorage>,List<ForcedChunkManager.OwnedChunks>> defineExtraStorageParams()
      Defines any extra parameters we are adding via a P1#add call
    • readStoredTickets

      @Internal public static net.minecraft.world.level.TicketStorage readStoredTickets(Function<List<com.mojang.datafixers.util.Pair<net.minecraft.world.level.ChunkPos,net.minecraft.server.level.Ticket>>,net.minecraft.world.level.TicketStorage> vanillaInitializer, List<com.mojang.datafixers.util.Pair<net.minecraft.world.level.ChunkPos,net.minecraft.server.level.Ticket>> tickets, List<ForcedChunkManager.OwnedChunks> ownedChunks)
      Reads any forced chunks we might have previously saved.