Skip to content

Commit 3b2c5c0

Browse files
authored
Merge branch 'OpenCubicChunks:1.20.4' into 1.20.4_cubeSender
2 parents fdaaa5d + 6d911db commit 3b2c5c0

34 files changed

+527
-147
lines changed

.github/workflows/gradleBuild.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ jobs:
2626
java-version: 17
2727

2828
- name: Build with Gradle
29-
run: ./gradlew build -x test
29+
run: ./gradlew build -x test -x longRunTest
3030
- name: Run tests
3131
run: ./gradlew check
3232

33-
- uses: actions/upload-artifact@v4
33+
- name: Upload compiled jars
34+
uses: actions/upload-artifact@v4
3435
with:
3536
name: compiled-jars
3637
path: build/libs/*.jar

.github/workflows/gradleBuildPR.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
java-version: 17
2525

2626
- name: Build with Gradle
27-
run: ./gradlew build -x test
27+
run: ./gradlew build -x test -x longRunTest
2828
- name: Run tests
2929
run: ./gradlew check
3030

src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/client/multiplayer/MixinClientChunkCache.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets;
1212
import io.github.notstirred.dasm.api.annotations.selector.FieldSig;
1313
import io.github.notstirred.dasm.api.annotations.selector.Ref;
14-
import io.github.opencubicchunks.cc_core.world.level.CloPos;
1514
import io.github.opencubicchunks.cc_core.api.CubePos;
1615
import io.github.opencubicchunks.cc_core.api.CubicConstants;
1716
import io.github.opencubicchunks.cubicchunks.CanBeCubic;
@@ -57,7 +56,7 @@ public abstract class MixinClientChunkCache extends MixinChunkSource implements
5756
private void cc_onConstruct(ClientLevel level, int viewDistance, CallbackInfo ci) {
5857
if (((CanBeCubic) level).cc_isCubic()) {
5958
cc_emptyCube = new EmptyLevelCube(
60-
level, CloPos.cube(0, 0, 0), level.registryAccess().registryOrThrow(Registries.BIOME).getHolderOrThrow(Biomes.PLAINS)
59+
level, CubePos.of(0, 0, 0), level.registryAccess().registryOrThrow(Registries.BIOME).getHolderOrThrow(Biomes.PLAINS)
6160
);
6261
cc_cubeStorage = new ClientCubeCache.Storage(calculateStorageRange(viewDistance), level);
6362
// TODO we could redirect the initial construction instead of immediately resizing. doesn't really matter
@@ -132,7 +131,7 @@ public void cc_replaceBiomes(int x, int y, int z, FriendlyByteBuf buffer) {
132131
LevelCube levelCube = this.cc_cubeStorage.chunks.get(i);
133132
CubePos cubePos = CubePos.of(x, y, z);
134133
if (!cc_isValidCube(levelCube, x, y, z)) {
135-
levelCube = new LevelCube(this.level, CloPos.cube(cubePos));
134+
levelCube = new LevelCube(this.level, cubePos);
136135
levelCube.replaceWithPacketData(buffer, tag, consumer);
137136
this.cc_cubeStorage.replace(i, levelCube);
138137
} else {

src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/client/multiplayer/MixinClientLevel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class MixinClientLevel extends MixinLevel implements CubicClient
1717
return cc_isCubic;
1818
}
1919

20-
@Override public boolean cc_hasCube(int x, int y, int z) {
20+
@Override public boolean cc_hasCube(int cubeX, int cubeY, int cubeZ) {
2121
return true;
2222
}
2323

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

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
66
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
77
import io.github.notstirred.dasm.api.annotations.Dasm;
8+
import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddMethodToSets;
89
import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets;
910
import io.github.notstirred.dasm.api.annotations.selector.MethodSig;
11+
import io.github.notstirred.dasm.api.annotations.selector.Ref;
1012
import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod;
1113
import io.github.opencubicchunks.cc_core.annotation.UsedFromASM;
14+
import io.github.opencubicchunks.cc_core.api.CubePos;
1215
import io.github.opencubicchunks.cc_core.world.level.CloPos;
1316
import io.github.opencubicchunks.cubicchunks.MarkableAsCubic;
1417
import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCloSet;
18+
import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet;
1519
import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.GlobalSet;
1620
import io.github.opencubicchunks.cubicchunks.server.level.CubicDistanceManager;
1721
import io.github.opencubicchunks.cubicchunks.server.level.CubicTicketType;
@@ -72,38 +76,81 @@ public void cc_setCubic() {
7276

7377
@Override
7478
@UsedFromASM
75-
@AddTransformToSets(GlobalSet.class) @TransformFromMethod(@MethodSig("addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
79+
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
7680
public abstract <T> void cc_addTicket(TicketType<T> type, CloPos pos, int level, T value);
7781

7882
@Override
7983
@UsedFromASM
80-
@AddTransformToSets(GlobalSet.class) @TransformFromMethod(@MethodSig("removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
84+
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
8185
public abstract <T> void cc_removeTicket(TicketType<T> type, CloPos pos, int level, T value);
8286

8387
@Override
8488
@UsedFromASM
85-
@AddTransformToSets(GlobalSet.class) @TransformFromMethod(@MethodSig("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
89+
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
8690
public abstract <T> void cc_addRegionTicket(TicketType<T> type, CloPos pos, int distance, T value);
8791

8892
@Override
8993
@UsedFromASM
90-
@AddTransformToSets(GlobalSet.class) @TransformFromMethod(@MethodSig("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V"))
94+
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V"))
9195
public abstract <T> void cc_addRegionTicket(TicketType<T> type, CloPos pos, int distance, T value, boolean forceTicks);
9296

9397
@Override
9498
@UsedFromASM
95-
@AddTransformToSets(GlobalSet.class) @TransformFromMethod(@MethodSig("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
99+
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
96100
public abstract <T> void cc_removeRegionTicket(TicketType<T> type, CloPos pos, int distance, T value);
97101

98102
@Override
99103
@UsedFromASM
100-
@AddTransformToSets(GlobalSet.class) @TransformFromMethod(@MethodSig("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V"))
104+
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V"))
101105
public abstract <T> void cc_removeRegionTicket(TicketType<T> type, CloPos pos, int distance, T value, boolean forceTicks);
102106

103107
@UsedFromASM
104-
@AddTransformToSets(GlobalSet.class) @TransformFromMethod(@MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)V"))
108+
@AddTransformToSets(ChunkToCloSet.class) @TransformFromMethod(@MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)V"))
105109
public abstract void cc_updateCubeForced(CloPos pos, boolean add);
106110

111+
// CubePos equivalents that delegate to their corresponding CloPos method
112+
@UsedFromASM
113+
@AddMethodToSets(sets = ChunkToCubeSet.class, owner = @Ref(DistanceManager.class), method = @MethodSig("addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
114+
public <T> void cc_addTicket(TicketType<T> type, CubePos pos, int level, T value) {
115+
cc_addTicket(type, CloPos.cube(pos), level, value);
116+
}
117+
118+
@UsedFromASM
119+
@AddMethodToSets(sets = ChunkToCubeSet.class, owner = @Ref(DistanceManager.class), method = @MethodSig("removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
120+
public <T> void cc_removeTicket(TicketType<T> type, CubePos pos, int level, T value) {
121+
cc_removeTicket(type, CloPos.cube(pos), level, value);
122+
}
123+
124+
@UsedFromASM
125+
@AddMethodToSets(sets = ChunkToCubeSet.class, owner = @Ref(DistanceManager.class), method = @MethodSig("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
126+
public <T> void cc_addRegionTicket(TicketType<T> type, CubePos pos, int distance, T value) {
127+
cc_addRegionTicket(type, CloPos.cube(pos), distance, value);
128+
}
129+
130+
@UsedFromASM
131+
@AddMethodToSets(sets = ChunkToCubeSet.class, owner = @Ref(DistanceManager.class), method = @MethodSig("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V"))
132+
public <T> void cc_addRegionTicket(TicketType<T> type, CubePos pos, int distance, T value, boolean forceTicks) {
133+
cc_addRegionTicket(type, CloPos.cube(pos), distance, value, forceTicks);
134+
}
135+
136+
@UsedFromASM
137+
@AddMethodToSets(sets = ChunkToCubeSet.class, owner = @Ref(DistanceManager.class), method = @MethodSig("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
138+
public <T> void cc_removeRegionTicket(TicketType<T> type, CubePos pos, int distance, T value) {
139+
cc_removeRegionTicket(type, CloPos.cube(pos), distance, value);
140+
}
141+
142+
@UsedFromASM
143+
@AddMethodToSets(sets = ChunkToCubeSet.class, owner = @Ref(DistanceManager.class), method = @MethodSig("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V"))
144+
public <T> void cc_removeRegionTicket(TicketType<T> type, CubePos pos, int distance, T value, boolean forceTicks) {
145+
cc_removeRegionTicket(type, CloPos.cube(pos), distance, value, forceTicks);
146+
}
147+
148+
@UsedFromASM
149+
@AddMethodToSets(sets = ChunkToCubeSet.class, owner = @Ref(DistanceManager.class), method = @MethodSig("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)V"))
150+
public void cc_updateCubeForced(CubePos pos, boolean add) {
151+
cc_updateCubeForced(CloPos.cube(pos), add);
152+
}
153+
107154
/**
108155
* This function replaces a TicketType with a CubicTicketType.
109156
*/

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.github.notstirred.dasm.api.annotations.selector.Ref;
2424
import io.github.notstirred.dasm.api.annotations.transform.AddUnusedParam;
2525
import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod;
26+
import io.github.opencubicchunks.cc_core.api.CubePos;
2627
import io.github.opencubicchunks.cc_core.utils.Coords;
2728
import io.github.opencubicchunks.cc_core.world.level.CloPos;
2829
import io.github.opencubicchunks.cubicchunks.CanBeCubic;
@@ -130,7 +131,7 @@ private void cc_getCube_supplyAsync(int pChunkX, int pChunkY, int pChunkZ, Chunk
130131
}
131132

132133
// The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the params of getCube
133-
@Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;chunkAsLong(II)J"))
134+
@Dynamic @Redirect(method = "cc_dasm$cc_getCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J"))
134135
private long cc_getCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) {
135136
return CloPos.cubeAsLong(pX, pY, pZ);
136137
}
@@ -145,7 +146,7 @@ private CompletableFuture cc_getCube_getChunkFutureMainThread(ServerChunkCache i
145146
@Override @Nullable public native LevelCube cc_getCubeNow(int pChunkX, @AddUnusedParam int chunkY, int pChunkZ);
146147

147148
// The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the params of getCubeNow
148-
@Dynamic @Redirect(method = "cc_dasm$cc_getCubeNow", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;chunkAsLong(II)J"))
149+
@Dynamic @Redirect(method = "cc_dasm$cc_getCubeNow", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_chunkAsLong(II)J"))
149150
private long cc_getCubeNow_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) {
150151
return CloPos.cubeAsLong(pX, pY, pZ);
151152
}
@@ -196,18 +197,18 @@ private native CompletableFuture<Either<CubeAccess, ChunkHolder.ChunkLoadingFail
196197
);
197198

198199
// The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the params of cc_getCubeFutureMainThread
199-
@Dynamic @Redirect(method = "cc_dasm$cc_getCubeFutureMainThread", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;chunk(II)Lio/github/opencubicchunks/cc_core/world/level/CloPos;"))
200-
private CloPos cc_getCubeFutureMainThread_chunkPosConstruct(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) {
201-
return CloPos.cube(pX, pY, pZ);
200+
@Dynamic @Redirect(method = "cc_dasm$cc_getCubeFutureMainThread", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;"))
201+
private CubePos cc_getCubeFutureMainThread_chunkPosConstruct(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) {
202+
return CubePos.of(pX, pY, pZ);
202203
}
203204

204205
@TransformFromMethod(@MethodSig("hasChunk(II)Z"))
205206
public native boolean cc_hasCube(int pX, @AddUnusedParam int y, int pZ);
206207

207208
// The first two params are the x and z coordinates inside the call being redirected; the next three params are the x/y/z coordinates in the params of cc_hasCube
208-
@Dynamic @Redirect(method = "cc_dasm$cc_hasCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/world/level/CloPos;chunk(II)Lio/github/opencubicchunks/cc_core/world/level/CloPos;"))
209-
private CloPos cc_hasCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) {
210-
return CloPos.cube(pX, pY, pZ);
209+
@Dynamic @Redirect(method = "cc_dasm$cc_hasCube", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cc_core/api/CubePos;dummy_fromChunkCoords(II)Lio/github/opencubicchunks/cc_core/api/CubePos;"))
210+
private CubePos cc_hasCube_posAsLong(int pX, int pZ, int pXRepeated, int pY, int pZRepeated) {
211+
return CubePos.of(pX, pY, pZ);
211212
}
212213

213214
// TODO (P2) - lighting; currently unused. can probably be done with dasm and @AddUnusedParam
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.entity;
2+
3+
import io.github.notstirred.dasm.api.annotations.Dasm;
4+
import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddFieldToSets;
5+
import io.github.notstirred.dasm.api.annotations.redirect.redirects.AddTransformToSets;
6+
import io.github.notstirred.dasm.api.annotations.selector.FieldSig;
7+
import io.github.notstirred.dasm.api.annotations.selector.MethodSig;
8+
import io.github.notstirred.dasm.api.annotations.selector.Ref;
9+
import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod;
10+
import io.github.opencubicchunks.cc_core.api.CubePos;
11+
import io.github.opencubicchunks.cc_core.utils.Coords;
12+
import io.github.opencubicchunks.cc_core.world.level.CloPos;
13+
import io.github.opencubicchunks.cubicchunks.CanBeCubic;
14+
import io.github.opencubicchunks.cubicchunks.mixin.dasmsets.ChunkToCubeSet;
15+
import io.github.opencubicchunks.cubicchunks.server.level.ServerCubeCache;
16+
import io.github.opencubicchunks.cubicchunks.world.entity.EntityCubePosGetter;
17+
import io.github.opencubicchunks.cubicchunks.world.level.CubicLevel;
18+
import io.github.opencubicchunks.cubicchunks.world.level.CubicLevelReader;
19+
import net.minecraft.core.BlockPos;
20+
import net.minecraft.server.level.ServerLevel;
21+
import net.minecraft.server.level.TicketType;
22+
import net.minecraft.util.Mth;
23+
import net.minecraft.world.entity.Entity;
24+
import net.minecraft.world.level.ChunkPos;
25+
import net.minecraft.world.level.Level;
26+
import net.minecraft.world.phys.AABB;
27+
import org.objectweb.asm.Opcodes;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
import org.spongepowered.asm.mixin.Shadow;
30+
import org.spongepowered.asm.mixin.injection.At;
31+
import org.spongepowered.asm.mixin.injection.Inject;
32+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
33+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
34+
35+
/**
36+
* We modify Entity to track its cube position, and to replace calls to chunk-specific methods with their corresponding cubic methods when in a cubic Level.
37+
*/
38+
@Dasm(ChunkToCubeSet.class)
39+
@Mixin(Entity.class)
40+
public abstract class MixinEntity implements EntityCubePosGetter {
41+
@Shadow private Level level;
42+
@Shadow private BlockPos blockPosition;
43+
44+
@Shadow public abstract void teleportTo(double x, double y, double z);
45+
@Shadow public abstract AABB getBoundingBox();
46+
@Shadow public abstract int getId();
47+
48+
@AddFieldToSets(sets = ChunkToCubeSet.class, owner = @Ref(Entity.class), field = @FieldSig(type = @Ref(ChunkPos.class), name = "chunkPosition"))
49+
private CubePos cc_cubePosition = CubePos.of(0, 0, 0);
50+
51+
@AddTransformToSets(ChunkToCubeSet.class) @TransformFromMethod(@MethodSig("chunkPosition()Lnet/minecraft/world/level/ChunkPos;"))
52+
public native CubePos cc_cubePosition();
53+
54+
// Update cube position when blockpos changes - this is the same location as where vanilla updates the chunk position
55+
@Inject(method = "setPosRaw", at = @At(value = "FIELD", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/Entity;blockPosition:Lnet/minecraft/core/BlockPos;", opcode = Opcodes.PUTFIELD))
56+
private void cc_onSetPosRaw(double x, double y, double z, CallbackInfo ci) {
57+
if (Coords.blockToCube(x) != cc_cubePosition.getX() || Coords.blockToCube(y) != cc_cubePosition.getY() || Coords.blockToCube(z) != cc_cubePosition.getZ()) {
58+
this.cc_cubePosition = CubePos.from(this.blockPosition);
59+
}
60+
}
61+
62+
// In cubic levels, force-load the destination cube instead of chunk
63+
@Inject(method = "teleportToWithTicket", at = @At("HEAD"), cancellable = true)
64+
private void cc_onTeleportToWithTicket(double x, double y, double z, CallbackInfo ci) {
65+
if (!((CanBeCubic) this.level).cc_isCubic()) return;
66+
ci.cancel();
67+
if (this.level instanceof ServerLevel) {
68+
CloPos cubePos = CloPos.cube(BlockPos.containing(x, y, z));
69+
((ServerCubeCache) ((ServerLevel) this.level).getChunkSource()).cc_addRegionTicket(TicketType.POST_TELEPORT, cubePos, 0, this.getId());
70+
((CubicLevel) this.level).cc_getCube(cubePos.getX(), cubePos.getY(), cubePos.getZ());
71+
this.teleportTo(x, y, z);
72+
}
73+
}
74+
75+
// In cubic levels, check for unloaded cubes instead of chunks
76+
@Inject(method = "touchingUnloadedChunk", at = @At("HEAD"), cancellable = true)
77+
private void cc_onTouchingUnloadedChunk(CallbackInfoReturnable<Boolean> cir) {
78+
if (!((CanBeCubic) this.level).cc_isCubic()) return;
79+
AABB aabb = this.getBoundingBox().inflate(1.0);
80+
int minX = Mth.floor(aabb.minX);
81+
int maxX = Mth.ceil(aabb.maxX);
82+
int minY = Mth.floor(aabb.minY);
83+
int maxY = Mth.ceil(aabb.maxY);
84+
int minZ = Mth.floor(aabb.minZ);
85+
int maxZ = Mth.ceil(aabb.maxZ);
86+
cir.setReturnValue(!((CubicLevelReader) this.level).cc_hasCubesAt(minX, minY, minZ, maxX, maxY, maxZ));
87+
}
88+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@ParametersAreNonnullByDefault
2+
@MethodsReturnNonnullByDefault
3+
package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.entity;
4+
5+
import javax.annotation.ParametersAreNonnullByDefault;
6+
7+
import io.github.opencubicchunks.cc_core.annotation.MethodsReturnNonnullByDefault;

0 commit comments

Comments
 (0)