Skip to content

Commit 5f85b3b

Browse files
committed
Add ServerCubeCache test for creating a cubic region ticket
Also add a misssing dasm redirect in MixinChunkMap. Currently still fails due to excessive memory usage.
1 parent 04eefdb commit 5f85b3b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/server/level/MixinChunkMap.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.github.opencubicchunks.cubicchunks.mixin.core.common.server.level;
22

3-
import static java.util.Collections.swap;
4-
53
import java.util.ArrayList;
64
import java.util.List;
75
import java.util.Optional;
@@ -429,6 +427,9 @@ public String toString() {
429427
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("protoChunkToFullChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;"))
430428
private native CompletableFuture<Either<CloAccess, ChunkHolder.ChunkLoadingFailure>> cc_protoChunkToFullChunk(ChunkHolder holder);
431429

430+
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("prepareEntityTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;"))
431+
public native CompletableFuture<Either<LevelClo, ChunkHolder.ChunkLoadingFailure>> cc_prepareEntityTickingChunk(ChunkHolder holder);
432+
432433
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("prepareTickingChunk(Lnet/minecraft/server/level/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;"))
433434
public native CompletableFuture<Either<LevelClo, ChunkHolder.ChunkLoadingFailure>> cc_prepareTickingChunk(ChunkHolder holder);
434435

src/test/java/io/github/opencubicchunks/cubicchunks/integrationtest/server/level/IntegrationTestServerCubeCache.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import io.github.opencubicchunks.cc_core.api.CubePos;
2020
import io.github.opencubicchunks.cc_core.api.CubicConstants;
21+
import io.github.opencubicchunks.cc_core.utils.Coords;
22+
import io.github.opencubicchunks.cc_core.world.level.CloPos;
2123
import io.github.opencubicchunks.cubicchunks.CanBeCubic;
2224
import io.github.opencubicchunks.cubicchunks.server.level.ServerCubeCache;
2325
import io.github.opencubicchunks.cubicchunks.testutils.BaseTest;
@@ -28,7 +30,9 @@
2830
import net.minecraft.server.level.DistanceManager;
2931
import net.minecraft.server.level.ServerChunkCache;
3032
import net.minecraft.server.level.ServerLevel;
33+
import net.minecraft.server.level.TicketType;
3134
import net.minecraft.server.level.progress.ProcessorChunkProgressListener;
35+
import net.minecraft.util.Unit;
3236
import net.minecraft.world.level.ChunkPos;
3337
import net.minecraft.world.level.chunk.ChunkStatus;
3438
import net.minecraft.world.level.chunk.LevelChunk;
@@ -395,4 +399,18 @@ public void hasCube() throws Exception {
395399
}
396400
}
397401
}
402+
403+
@Test public void testAddCubicRegionTicket() throws Exception {
404+
try(var serverChunkCacheRef = createServerChunkCache(false)) {
405+
var serverChunkCache = serverChunkCacheRef.value();
406+
var cubicServerChunkCache = ((ServerCubeCache) serverChunkCache);
407+
int spawnRadius = Coords.sectionToCube(11);
408+
cubicServerChunkCache.cc_addRegionTicket(TicketType.START, CloPos.cube(0, 0, 0), spawnRadius, Unit.INSTANCE);
409+
serverChunkCache.tick(()->true, false);
410+
var cubeAccess = cubicServerChunkCache.cc_getCube(0, 0, 0, ChunkStatus.FULL, true);
411+
assertNotNull(cubeAccess);
412+
assertTrue(cubeAccess.getStatus().isOrAfter(ChunkStatus.FULL));
413+
assertInstanceOf(LevelCube.class, cubeAccess);
414+
}
415+
}
398416
}

0 commit comments

Comments
 (0)