Class ForcedChunkManager
java.lang.Object
net.neoforged.neoforge.common.world.chunk.ForcedChunkManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record(package private) static classForcedChunkManager.TicketOwner<T extends Comparable<? super T>>Helper class to keep track of a ticket owner by controller ID and owner objectstatic classForcedChunkManager.TicketTracker<T extends Comparable<? super T>>Helper class to manage tracking and handling loaded tickets. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Map<ResourceLocation, TicketController> private static booleanprivate static final org.apache.logging.log4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidactivateAllDeactivatedTickets(ServerLevel level, TicketStorage saveData) Reinstates NeoForge's forced chunks when vanilla initially loads a level and reinstates their forced chunks.static com.mojang.datafixers.kinds.App<com.mojang.serialization.codecs.RecordCodecBuilder.Mu<TicketStorage>, List<ForcedChunkManager.OwnedChunks>> Defines any extra parameters we are adding via a P1#add call(package private) static <T extends Comparable<? super T>>
booleanforceChunk(ServerLevel level, ResourceLocation id, T owner, int chunkX, int chunkZ, boolean add, boolean forceNaturalSpawning, Function<TicketStorage, ForcedChunkManager.TicketTracker<T>> ticketGetter) Forces a chunk to be loaded for the given mod with the given "owner".private static <T extends Comparable<? super T>>
voidgatherTicketsById(it.unimi.dsi.fastutil.longs.Long2ObjectMap<Set<ForcedChunkManager.TicketOwner<T>>> tickets, Function<TicketSet, it.unimi.dsi.fastutil.longs.LongSet> typeGetter, Map<ResourceLocation, Map<T, TicketSet>> modSortedOwnedChunks) Gathers tickets into an ID filtered map for use in providing all tickets a controller has registered to itsLoadingValidationCallback.private static <T extends Comparable<? super T>>
Map<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 itsLoadingValidationCallback.static booleanhasForcedChunks(ServerLevel level) Checks if a level has any forced chunks.static voidinit()static TicketStoragereadStoredTickets(Function<List<com.mojang.datafixers.util.Pair<ChunkPos, Ticket>>, TicketStorage> vanillaInitializer, List<com.mojang.datafixers.util.Pair<ChunkPos, Ticket>> tickets, List<ForcedChunkManager.OwnedChunks> ownedChunks) Reads any forced chunks we might have previously saved.
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
initialised
private static boolean initialised -
controllers
-
-
Constructor Details
-
ForcedChunkManager
public ForcedChunkManager()
-
-
Method Details
-
init
@Internal public static void init() -
hasForcedChunks
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(ServerLevel level, ResourceLocation id, T owner, int chunkX, int chunkZ, boolean add, boolean forceNaturalSpawning, Function<TicketStorage, ForcedChunkManager.TicketTracker<T>> ticketGetter) Forces a chunk to be loaded for the given mod with the given "owner".- Parameters:
add-trueto force the chunk,falseto unforce the chunk.
-
activateAllDeactivatedTickets
@Internal public static void activateAllDeactivatedTickets(ServerLevel 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 registeredLoadingValidationCallbacks. -
gatherTicketsById
private static <T extends Comparable<? super T>> Map<ResourceLocation,Map<T, gatherTicketsByIdTicketSet>> (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 itsLoadingValidationCallback. -
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<ResourceLocation, Map<T, TicketSet>> modSortedOwnedChunks) Gathers tickets into an ID filtered map for use in providing all tickets a controller has registered to itsLoadingValidationCallback. -
defineExtraStorageParams
@Internal public static com.mojang.datafixers.kinds.App<com.mojang.serialization.codecs.RecordCodecBuilder.Mu<TicketStorage>,List<ForcedChunkManager.OwnedChunks>> defineExtraStorageParams()Defines any extra parameters we are adding via a P1#add call -
readStoredTickets
@Internal public static TicketStorage readStoredTickets(Function<List<com.mojang.datafixers.util.Pair<ChunkPos, Ticket>>, TicketStorage> vanillaInitializer, List<com.mojang.datafixers.util.Pair<ChunkPos, Ticket>> tickets, List<ForcedChunkManager.OwnedChunks> ownedChunks) Reads any forced chunks we might have previously saved.
-