YATS/Forge Documentation
 All Classes Namespaces Files Functions Variables Enumerator Pages
net.minecraftforge.common.ForgeChunkManager Class Reference

Classes

class  ForceChunkEvent
 
interface  LoadingCallback
 
interface  OrderedLoadingCallback
 
interface  PlayerOrderedLoadingCallback
 
class  Ticket
 
enum  Type
 
class  UnforceChunkEvent
 

Static Public Member Functions

static boolean savedWorldHasForcedChunkTickets (File chunkDir)
 
static void setForcedChunkLoadingCallback (Object mod, LoadingCallback callback)
 
static int ticketCountAvailableFor (Object mod, World world)
 
static int getMaxTicketLengthFor (String modId)
 
static int getMaxChunkDepthFor (String modId)
 
static int ticketCountAvailableFor (String username)
 
static Ticket requestPlayerTicket (Object mod, String player, World world, Type type)
 
static Ticket requestTicket (Object mod, World world, Type type)
 
static void releaseTicket (Ticket ticket)
 
static void forceChunk (Ticket ticket, ChunkCoordIntPair chunk)
 
static void reorderChunk (Ticket ticket, ChunkCoordIntPair chunk)
 
static void unforceChunk (Ticket ticket, ChunkCoordIntPair chunk)
 
static ImmutableSetMultimap
< ChunkCoordIntPair, Ticket > 
getPersistentChunksFor (World world)
 
static void putDormantChunk (long coords, Chunk chunk)
 
static Chunk fetchDormantChunk (long coords, World world)
 
static ConfigCategory getConfigFor (Object mod)
 
static void addConfigProperty (Object mod, String propertyName, String value, Property.Type type)
 

Detailed Description

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 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.

Author
cpw

Member Function Documentation

static void net.minecraftforge.common.ForgeChunkManager.addConfigProperty ( Object  mod,
String  propertyName,
String  value,
Property.Type  type 
)
static
static Chunk net.minecraftforge.common.ForgeChunkManager.fetchDormantChunk ( long  coords,
World  world 
)
static
static void net.minecraftforge.common.ForgeChunkManager.forceChunk ( Ticket  ticket,
ChunkCoordIntPair  chunk 
)
static

Force the supplied chunk coordinate to be loaded by the supplied ticket. If the ticket's 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.

Parameters
ticketThe ticket registering the chunk
chunkThe chunk to force
static ConfigCategory net.minecraftforge.common.ForgeChunkManager.getConfigFor ( Object  mod)
static
static int net.minecraftforge.common.ForgeChunkManager.getMaxChunkDepthFor ( String  modId)
static
static int net.minecraftforge.common.ForgeChunkManager.getMaxTicketLengthFor ( String  modId)
static
static ImmutableSetMultimap<ChunkCoordIntPair, Ticket> net.minecraftforge.common.ForgeChunkManager.getPersistentChunksFor ( World  world)
static

The list of persistent chunks in the world. This set is immutable.

Parameters
world
Returns
the list of persistent chunks in the world
static void net.minecraftforge.common.ForgeChunkManager.putDormantChunk ( long  coords,
Chunk  chunk 
)
static
static void net.minecraftforge.common.ForgeChunkManager.releaseTicket ( Ticket  ticket)
static

Release the ticket back to the system. This will also unforce any chunks held by the ticket so that they can be unloaded and/or stop ticking.

Parameters
ticketThe ticket to release
static void net.minecraftforge.common.ForgeChunkManager.reorderChunk ( Ticket  ticket,
ChunkCoordIntPair  chunk 
)
static

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

Parameters
ticketThe ticket holding the chunk list
chunkThe chunk you wish to push to the end (so that it would be unloaded last)
static Ticket net.minecraftforge.common.ForgeChunkManager.requestPlayerTicket ( Object  mod,
String  player,
World  world,
Type  type 
)
static
static Ticket net.minecraftforge.common.ForgeChunkManager.requestTicket ( Object  mod,
World  world,
Type  type 
)
static

Request a chunkloading ticket of the appropriate type for the supplied mod

Parameters
modThe mod requesting a ticket
worldThe world in which it is requesting the ticket
typeThe type of ticket
Returns
A ticket with which to register chunks for loading, or null if no further tickets are available
static boolean net.minecraftforge.common.ForgeChunkManager.savedWorldHasForcedChunkTickets ( File  chunkDir)
static

Allows dynamically loading world mods to test if there are chunk tickets in the world Mods that add dynamically generated worlds (like Mystcraft) should call this method to determine if the world should be loaded during server starting.

Parameters
chunkDirThe chunk directory to test: should be equivalent to WorldServer#getChunkSaveLocation()
Returns
if there are tickets outstanding for this world or not
static void net.minecraftforge.common.ForgeChunkManager.setForcedChunkLoadingCallback ( Object  mod,
LoadingCallback  callback 
)
static

Set a chunkloading callback for the supplied mod object

Parameters
modThe mod instance registering the callback
callbackThe code to call back when forced chunks are loaded
static int net.minecraftforge.common.ForgeChunkManager.ticketCountAvailableFor ( Object  mod,
World  world 
)
static

Discover the available tickets for the mod in the world

Parameters
modThe mod that will own the tickets
worldThe world
Returns
The count of tickets left for the mod in the supplied world
static int net.minecraftforge.common.ForgeChunkManager.ticketCountAvailableFor ( String  username)
static
static void net.minecraftforge.common.ForgeChunkManager.unforceChunk ( Ticket  ticket,
ChunkCoordIntPair  chunk 
)
static

Unforce the supplied chunk, allowing it to be unloaded and stop ticking.

Parameters
ticketThe ticket holding the chunk
chunkThe chunk to unforce

The documentation for this class was generated from the following file: