|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.minecraftforge.common.ForgeChunkManager
public class ForgeChunkManager
Manages chunkloading for mods.
The basic principle is a ticket based system.
1. Mods register a callback setForcedChunkLoadingCallback(Object, LoadingCallback)
2. Mods ask for a ticket requestTicket(Object, World, Type)
and then hold on to that ticket.
3. Mods request chunks to stay loaded forceChunk(Ticket, ChunkCoordIntPair)
or remove chunks from force loading unforceChunk(Ticket, ChunkCoordIntPair)
.
4. When a world unloads, the tickets associated with that world are saved by the chunk manager.
5. When a world loads, saved tickets are offered to the mods associated with the tickets. The ForgeChunkManager.Ticket.getModData()
that is set by the mod should be used to re-register
chunks to stay loaded (and maybe take other actions).
The chunkloading is configurable at runtime. The file "config/forgeChunkLoading.cfg" contains both default configuration for chunkloading, and a sample individual mod
specific override section.
Nested Class Summary | |
---|---|
static interface |
ForgeChunkManager.LoadingCallback
All mods requiring chunkloading need to implement this to handle the re-registration of chunk tickets at world loading time |
static interface |
ForgeChunkManager.OrderedLoadingCallback
This is a special LoadingCallback that can be implemented as well as the LoadingCallback to provide access to additional behaviour. |
static class |
ForgeChunkManager.Ticket
|
static class |
ForgeChunkManager.Type
|
Constructor Summary | |
---|---|
ForgeChunkManager()
|
Method Summary | |
---|---|
static void |
addConfigProperty(Object mod,
String propertyName,
String value,
Property.Type type)
|
static Chunk |
fetchDormantChunk(long coords,
World world)
|
static void |
forceChunk(ForgeChunkManager.Ticket ticket,
ChunkCoordIntPair chunk)
Force the supplied chunk coordinate to be loaded by the supplied ticket. |
static Map<String,Property> |
getConfigMapFor(Object mod)
|
static com.google.common.collect.ImmutableSetMultimap<ChunkCoordIntPair,ForgeChunkManager.Ticket> |
getPersistentChunksFor(World world)
The list of persistent chunks in the world. |
static void |
putDormantChunk(long coords,
Chunk chunk)
|
static void |
releaseTicket(ForgeChunkManager.Ticket ticket)
Release the ticket back to the system. |
static void |
reorderChunk(ForgeChunkManager.Ticket ticket,
ChunkCoordIntPair chunk)
Reorganize the internal chunk list so that the chunk supplied is at the *end* of the list This helps if you wish to guarantee a certain "automatic unload ordering" for the chunks in the ticket list |
static ForgeChunkManager.Ticket |
requestPlayerTicket(Object mod,
EntityPlayer player,
World world,
ForgeChunkManager.Type type)
|
static ForgeChunkManager.Ticket |
requestTicket(Object mod,
World world,
ForgeChunkManager.Type type)
Request a chunkloading ticket of the appropriate type for the supplied mod |
static void |
setForcedChunkLoadingCallback(Object mod,
ForgeChunkManager.LoadingCallback callback)
Set a chunkloading callback for the supplied mod object |
static int |
ticketCountAvailableFor(Object mod,
World world)
Discover the available tickets for the mod in the world |
static void |
unforceChunk(ForgeChunkManager.Ticket ticket,
ChunkCoordIntPair chunk)
Unforce the supplied chunk, allowing it to be unloaded and stop ticking. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ForgeChunkManager()
Method Detail |
---|
public static void setForcedChunkLoadingCallback(Object mod, ForgeChunkManager.LoadingCallback callback)
mod
- The mod instance registering the callbackcallback
- The code to call back when forced chunks are loadedpublic static int ticketCountAvailableFor(Object mod, World world)
mod
- The mod that will own the ticketsworld
- The world
public static ForgeChunkManager.Ticket requestPlayerTicket(Object mod, EntityPlayer player, World world, ForgeChunkManager.Type type)
public static ForgeChunkManager.Ticket requestTicket(Object mod, World world, ForgeChunkManager.Type type)
mod
- The mod requesting a ticketworld
- The world in which it is requesting the tickettype
- The type of ticket
public static void releaseTicket(ForgeChunkManager.Ticket ticket)
ticket
- The ticket to releasepublic static void forceChunk(ForgeChunkManager.Ticket ticket, ChunkCoordIntPair chunk)
ForgeChunkManager.Ticket.maxDepth
is exceeded, the least
recently registered chunk is unforced and may be unloaded.
It is safe to force the chunk several times for a ticket, it will not generate duplication or change the ordering.
ticket
- The ticket registering the chunkchunk
- The chunk to forcepublic static void reorderChunk(ForgeChunkManager.Ticket ticket, ChunkCoordIntPair chunk)
ticket
- The ticket holding the chunk listchunk
- The chunk you wish to push to the end (so that it would be unloaded last)public static void unforceChunk(ForgeChunkManager.Ticket ticket, ChunkCoordIntPair chunk)
ticket
- The ticket holding the chunkchunk
- The chunk to unforcepublic static com.google.common.collect.ImmutableSetMultimap<ChunkCoordIntPair,ForgeChunkManager.Ticket> getPersistentChunksFor(World world)
world
-
public static void putDormantChunk(long coords, Chunk chunk)
public static Chunk fetchDormantChunk(long coords, World world)
public static Map<String,Property> getConfigMapFor(Object mod)
public static void addConfigProperty(Object mod, String propertyName, String value, Property.Type type)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |