Class ForcedChunkManager
java.lang.Object
net.neoforged.neoforge.common.world.chunk.ForcedChunkManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
(package private) static class
ForcedChunkManager.TicketOwner<T extends Comparable<? super T>>
Helper class to keep track of a ticket owner by controller ID and owner objectstatic class
ForcedChunkManager.TicketTracker<T extends Comparable<? super T>>
Helper class to manage tracking and handling loaded tickets. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Map
<net.minecraft.resources.ResourceLocation, TicketController> private static boolean
private static final org.apache.logging.log4j.Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static com.mojang.datafixers.kinds.App
<com.mojang.serialization.codecs.RecordCodecBuilder.Mu<net.minecraft.world.level.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
(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".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<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 itsLoadingValidationCallback
.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 itsLoadingValidationCallback
.static boolean
hasForcedChunks
(net.minecraft.server.level.ServerLevel level) Checks if a level has any forced chunks.static void
init()
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.
-
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
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 registeredLoadingValidationCallback
s. -
gatherTicketsById
private static <T extends Comparable<? super T>> Map<net.minecraft.resources.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<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 itsLoadingValidationCallback
. -
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.
-