diff --git a/src/main/java/net/minestom/server/instance/Chunk.java b/src/main/java/net/minestom/server/instance/Chunk.java index dc0816e36..c52170bc5 100644 --- a/src/main/java/net/minestom/server/instance/Chunk.java +++ b/src/main/java/net/minestom/server/instance/Chunk.java @@ -60,8 +60,6 @@ public abstract class Chunk implements Viewable, DataContainer { public static final int BIOME_COUNT = 1024; // 4x4x4 blocks group - @NotNull - protected final Instance instance; @NotNull protected final Biome[] biomes; protected final int chunkX, chunkZ; @@ -84,8 +82,7 @@ public abstract class Chunk implements Viewable, DataContainer { // Data protected Data data; - public Chunk(@NotNull Instance instance, @Nullable Biome[] biomes, int chunkX, int chunkZ, boolean shouldGenerate) { - this.instance = instance; + public Chunk(@Nullable Biome[] biomes, int chunkX, int chunkZ, boolean shouldGenerate) { this.chunkX = chunkX; this.chunkZ = chunkZ; this.shouldGenerate = shouldGenerate; @@ -236,13 +233,12 @@ public abstract class Chunk implements Viewable, DataContainer { *
* The instance and chunk position (X/Z) can be modified using the given arguments.
*
- * @param instance the instance of the new chunk
- * @param chunkX the new chunk X
- * @param chunkZ the new chunK Z
+ * @param chunkX the new chunk X
+ * @param chunkZ the new chunk Z
* @return a copy of this chunk with a potentially new instance and position
*/
@NotNull
- public abstract Chunk copy(@NotNull Instance instance, int chunkX, int chunkZ);
+ public abstract Chunk copy(int chunkX, int chunkZ);
/**
* Gets the {@link CustomBlock} at a position.
diff --git a/src/main/java/net/minestom/server/instance/DynamicChunk.java b/src/main/java/net/minestom/server/instance/DynamicChunk.java
index f378a3b7f..2bf81c6a9 100644
--- a/src/main/java/net/minestom/server/instance/DynamicChunk.java
+++ b/src/main/java/net/minestom/server/instance/DynamicChunk.java
@@ -60,8 +60,8 @@ public class DynamicChunk extends Chunk {
// Block entities
protected final Set
- * Chunks are copied with {@link Chunk#copy(Instance, int, int)},
+ * Chunks are copied with {@link Chunk#copy(int, int)},
* {@link UUID} is randomized, {@link DimensionType} is passed over and the {@link StorageLocation} is null.
*
* @return an {@link InstanceContainer} with the exact same chunks as 'this'
@@ -635,7 +635,7 @@ public class InstanceContainer extends Instance {
final long index = entry.getKey();
final Chunk chunk = entry.getValue();
- final Chunk copiedChunk = chunk.copy(copiedInstance, chunk.getChunkX(), chunk.getChunkZ());
+ final Chunk copiedChunk = chunk.copy(chunk.getChunkX(), chunk.getChunkZ());
copiedChunks.put(index, copiedChunk);
UPDATE_MANAGER.signalChunkLoad(copiedInstance, chunk.getChunkX(), chunk.getChunkZ());
diff --git a/src/main/java/net/minestom/server/instance/MinestomBasicChunkLoader.java b/src/main/java/net/minestom/server/instance/MinestomBasicChunkLoader.java
index f87b33c1c..50ee59561 100644
--- a/src/main/java/net/minestom/server/instance/MinestomBasicChunkLoader.java
+++ b/src/main/java/net/minestom/server/instance/MinestomBasicChunkLoader.java
@@ -77,7 +77,7 @@ public class MinestomBasicChunkLoader implements IChunkLoader {
// Found, load from result bytes
BinaryReader reader = new BinaryReader(bytes);
// Create the chunk object using the instance's ChunkSupplier to support multiple implementations
- Chunk chunk = instanceContainer.getChunkSupplier().getChunk(instance, null, chunkX, chunkZ);
+ Chunk chunk = instanceContainer.getChunkSupplier().getChunk(null, chunkX, chunkZ);
// Execute the callback once all blocks are placed (allow for multithreaded implementations)
chunk.readChunk(reader, callback);
return true;
diff --git a/src/main/java/net/minestom/server/instance/StaticChunk.java b/src/main/java/net/minestom/server/instance/StaticChunk.java
index 7fd749d26..7a6fccd43 100644
--- a/src/main/java/net/minestom/server/instance/StaticChunk.java
+++ b/src/main/java/net/minestom/server/instance/StaticChunk.java
@@ -28,8 +28,8 @@ public class StaticChunk extends Chunk {
protected final BlockProvider blockProvider;
- public StaticChunk(Instance instance, Biome[] biomes, int chunkX, int chunkZ, BlockProvider blockProvider) {
- super(instance, biomes, chunkX, chunkZ, false);
+ public StaticChunk(Biome[] biomes, int chunkX, int chunkZ, BlockProvider blockProvider) {
+ super(biomes, chunkX, chunkZ, false);
this.blockProvider = blockProvider;
setReadOnly(true);
}
@@ -114,8 +114,8 @@ public class StaticChunk extends Chunk {
@NotNull
@Override
- public Chunk copy(@NotNull Instance instance, int chunkX, int chunkZ) {
- StaticChunk staticChunk = new StaticChunk(instance, biomes.clone(), chunkX, chunkZ, blockProvider);
+ public Chunk copy(int chunkX, int chunkZ) {
+ StaticChunk staticChunk = new StaticChunk(biomes.clone(), chunkX, chunkZ, blockProvider);
// Prevent re-writing the whole packet since it is static anyway
final ByteBuf packetBuffer = getFullDataPacket();
if (packetBuffer != null) {
diff --git a/src/main/java/net/minestom/server/utils/chunk/ChunkSupplier.java b/src/main/java/net/minestom/server/utils/chunk/ChunkSupplier.java
index 78c3ca742..56d11b687 100644
--- a/src/main/java/net/minestom/server/utils/chunk/ChunkSupplier.java
+++ b/src/main/java/net/minestom/server/utils/chunk/ChunkSupplier.java
@@ -1,8 +1,9 @@
package net.minestom.server.utils.chunk;
import net.minestom.server.instance.Chunk;
-import net.minestom.server.instance.Instance;
import net.minestom.server.world.biomes.Biome;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Used to customize which type of {@link Chunk} an implementation should use.
@@ -11,13 +12,13 @@ import net.minestom.server.world.biomes.Biome;
public interface ChunkSupplier {
/**
- * Create a {@link Chunk} object.
+ * Creates a {@link Chunk} object.
*
- * @param instance the {@link Instance} assigned to the chunk
- * @param biomes the biomes of the chunk, can be null
- * @param chunkX the chunk X
- * @param chunkZ the chunk Z
+ * @param biomes the biomes of the chunk, can be null
+ * @param chunkX the chunk X
+ * @param chunkZ the chunk Z
* @return a newly {@link Chunk} object, cannot be null
*/
- Chunk getChunk(Instance instance, Biome[] biomes, int chunkX, int chunkZ);
+ @NotNull
+ Chunk getChunk(@Nullable Biome[] biomes, int chunkX, int chunkZ);
}