Skip to content

Commit 6d911db

Browse files
CursedFlamesNotStirred
authored andcommitted
Use CubePos instead of CloPos on Entity
1 parent 258df90 commit 6d911db

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/main/java/io/github/opencubicchunks/cubicchunks/mixin/core/common/world/entity/MixinEntity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.github.notstirred.dasm.api.annotations.selector.MethodSig;
88
import io.github.notstirred.dasm.api.annotations.selector.Ref;
99
import io.github.notstirred.dasm.api.annotations.transform.TransformFromMethod;
10+
import io.github.opencubicchunks.cc_core.api.CubePos;
1011
import io.github.opencubicchunks.cc_core.utils.Coords;
1112
import io.github.opencubicchunks.cc_core.world.level.CloPos;
1213
import io.github.opencubicchunks.cubicchunks.CanBeCubic;
@@ -45,16 +46,16 @@ public abstract class MixinEntity implements EntityCubePosGetter {
4546
@Shadow public abstract int getId();
4647

4748
@AddFieldToSets(sets = ChunkToCubeSet.class, owner = @Ref(Entity.class), field = @FieldSig(type = @Ref(ChunkPos.class), name = "chunkPosition"))
48-
private CloPos cc_cubePosition = CloPos.cube(0, 0, 0);
49+
private CubePos cc_cubePosition = CubePos.of(0, 0, 0);
4950

5051
@AddTransformToSets(ChunkToCubeSet.class) @TransformFromMethod(@MethodSig("chunkPosition()Lnet/minecraft/world/level/ChunkPos;"))
51-
public native CloPos cc_cubePosition();
52+
public native CubePos cc_cubePosition();
5253

5354
// Update cube position when blockpos changes - this is the same location as where vanilla updates the chunk position
5455
@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))
5556
private void cc_onSetPosRaw(double x, double y, double z, CallbackInfo ci) {
5657
if (Coords.blockToCube(x) != cc_cubePosition.getX() || Coords.blockToCube(y) != cc_cubePosition.getY() || Coords.blockToCube(z) != cc_cubePosition.getZ()) {
57-
this.cc_cubePosition = CloPos.cube(this.blockPosition);
58+
this.cc_cubePosition = CubePos.from(this.blockPosition);
5859
}
5960
}
6061

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.opencubicchunks.cubicchunks.world.entity;
22

3-
import io.github.opencubicchunks.cc_core.world.level.CloPos;
3+
import io.github.opencubicchunks.cc_core.api.CubePos;
44

55
public interface EntityCubePosGetter {
6-
CloPos cc_cubePosition();
6+
CubePos cc_cubePosition();
77
}

src/test/java/io/github/opencubicchunks/cubicchunks/test/world/entity/TestEntity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import io.github.opencubicchunks.cc_core.api.CubePos;
1111
import io.github.opencubicchunks.cc_core.api.CubicConstants;
12-
import io.github.opencubicchunks.cc_core.world.level.CloPos;
1312
import io.github.opencubicchunks.cubicchunks.CanBeCubic;
1413
import io.github.opencubicchunks.cubicchunks.test.world.level.TestCubicLevelReader;
1514
import io.github.opencubicchunks.cubicchunks.testutils.BaseTest;
@@ -36,7 +35,7 @@ public class TestEntity extends BaseTest {
3635
for (int i = 0; i < 1000; i++) {
3736
var pos = new BlockPos(random.nextInt(20000)-10000, random.nextInt(20000)-10000, random.nextInt(20000)-10000);
3837
entity.setPos(pos.getX(), pos.getY(), pos.getZ());
39-
assertEquals(CloPos.cube(pos), ((EntityCubePosGetter) entity).cc_cubePosition());
38+
assertEquals(CubePos.from(pos), ((EntityCubePosGetter) entity).cc_cubePosition());
4039
}
4140
}
4241

0 commit comments

Comments
 (0)