mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-16 12:21:32 +01:00
Updated Chunks managment (markdown)
parent
3790f8bcdf
commit
12d425feb0
@ -1,6 +1,6 @@
|
||||
This page describes the behavior of an InstanceContainer when asked to load or save a chunk
|
||||
This page describes what you need to know about chunks management, more specifically for InstanceContainer
|
||||
|
||||
# Steps
|
||||
# Load/Save Steps
|
||||
When trying to load a chunk, the instance container does multiple checks in this order:
|
||||
1. Verify if the chunk is already loaded (stop here if yes)
|
||||
2. Try to load the chunk from the instance [IChunkLoader](https://github.com/Minestom/Minestom/blob/master/src/main/java/net/minestom/server/instance/IChunkLoader.java) using [IChunkLoader#loadChunk](https://github.com/Minestom/Minestom/blob/master/src/main/java/net/minestom/server/instance/IChunkLoader.java#L21) (stop here if the chunk loading is successful)
|
||||
@ -8,11 +8,24 @@ When trying to load a chunk, the instance container does multiple checks in this
|
||||
|
||||
When trying to save a chunk, [IChunkLoader#saveChunk](https://github.com/Minestom/Minestom/blob/master/src/main/java/net/minestom/server/instance/IChunkLoader.java#L30) is called
|
||||
|
||||
# Default behavior
|
||||
[BasicChunkLoader](https://github.com/Minestom/Minestom/blob/master/src/main/java/net/minestom/server/instance/MinestomBasicChunkLoader.java) is the default chunk loader used by all InstanceContainer, it does make use of the StorageLocation of the instance (WARNING: will not work if the storage location is null)
|
||||
## Default behavior
|
||||
[BasicChunkLoader](https://github.com/Minestom/Minestom/blob/master/src/main/java/net/minestom/server/instance/MinestomBasicChunkLoader.java) is the default chunk loader used by all InstanceContainer, it does make use of the storage location of the instance (WARNING: will not work if the storage location is null)
|
||||
|
||||
# I still cannot join the instance
|
||||
Even if your instance is able to load chunks it doesn't mean that it will do so automatically. However, you can configure it to load them if itself.
|
||||
## I still cannot join the instance
|
||||
Even if your instance is able to load chunks it doesn't mean that it will do so automatically. However, you can configure it to do so with the following:
|
||||
```java
|
||||
instanceContainer.enableAutoChunkLoad(true);
|
||||
```
|
||||
```
|
||||
It is required because some servers could prefer to have complete control over which chunks are loaded, in order to save memory or for performance purpose.
|
||||
|
||||
# Create your own chunk type
|
||||
[Chunk](https://github.com/Minestom/Minestom/blob/master/src/main/java/net/minestom/server/instance/Chunk.java) is an abstract class, you can simply create a new class extending it to create your own implementation.
|
||||
|
||||
Making your own chunk implementation allows you to customize how you want blocks to be stored, how you want chunks tick to happen, etc...
|
||||
|
||||
## How to make my instance use my implementation
|
||||
If you are using a simple [InstanceContainer](https://github.com/Minestom/Minestom/blob/master/src/main/java/net/minestom/server/instance/InstanceContainer.java) with the default [IChunkLoader](https://github.com/Minestom/Minestom/blob/master/src/main/java/net/minestom/server/instance/IChunkLoader.java) you will just need to change the instance's chunk supplier
|
||||
```java
|
||||
instanceContainer.setChunkSupplier(YOUR_CHUNK_SUPPLIER);
|
||||
```
|
||||
It will be called when a chunk object needs to be provided.
|
||||
|
Loading…
Reference in New Issue
Block a user