Skip to content

ChunkTickets

Namespace Mc.Scripting.Worlds · Kind class (sealed)

public sealed class ChunkTickets

Chunk tickets of one plugin (plugin.ChunkTickets): they are released automatically when the plugin unloads or reloads.

Member Description
const int MaxTicketsPerPlugin = 4096 How many chunks one plugin may hold at once (a ticket keeps a chunk in memory and ticking: a runaway loop must not load the whole world).
public const int MaxTicketsPerPlugin = 4096;

How many chunks one plugin may hold at once (a ticket keeps a chunk in memory and ticking: a runaway loop must not load the whole world).

Member Description
int ActiveCount { get; } How many tickets this plugin currently holds.
public int ActiveCount { get; }

How many tickets this plugin currently holds.

Member Description
ChunkTicket Add(World world, int chunkX, int chunkZ) Asks for a chunk to be loaded and kept.
IReadOnlyList<ChunkTicket> AddArea(World world, int centerX, int centerZ, int radius) Asks for the chunks of a square around a centre chunk (radius 0 is one chunk, 1 is 3 x 3).
public ChunkTicket Add(World world, int chunkX, int chunkZ)

Asks for a chunk to be loaded and kept.

Parameters

Name Type Description
world World The dimension.
chunkX int The chunk x (block x >> 4).
chunkZ int The chunk z.

Returns ChunkTicket: The ticket. Check ChunkTicket.IsLoaded (or poll World.IsChunkLoaded): loading is asynchronous.

Throws

  • System.InvalidOperationException: The dimension does not exist, or the plugin already holds ChunkTickets.MaxTicketsPerPlugin chunks.
  • System.ArgumentOutOfRangeException: The chunk is outside the world border (blocks beyond +-30,000,000).
public IReadOnlyList<ChunkTicket> AddArea(World world, int centerX, int centerZ, int radius)

Asks for the chunks of a square around a centre chunk (radius 0 is one chunk, 1 is 3 x 3).

Parameters

Name Type Description
world World The dimension.
centerX int The centre chunk x.
centerZ int The centre chunk z.
radius int The radius in chunks (at most 32).

Returns IReadOnlyList<ChunkTicket>: The tickets, one per chunk.

ChunkTicket · World