From 2b09ed8fd9aa92cb840f647266533c02e14d2404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zo=C3=AB=20Gidiere?= Date: Sun, 5 Oct 2025 21:51:40 -0600 Subject: [PATCH] Simplify mixin implementations Refactors mixin implementations to remove unnecessary casting. This change improves code readability and reduces redundancy by directly accessing methods and fields within the mixin context, rather than relying on casting to the target class. --- .../terra/world/ChunkRegionMixin.java | 6 +++--- .../terra/world/ServerWorldMixin.java | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ChunkRegionMixin.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ChunkRegionMixin.java index 9f67a7c12..d44bad513 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ChunkRegionMixin.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ChunkRegionMixin.java @@ -146,11 +146,11 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess { @Intrinsic(displace = true) public BlockState terraWorld$getBlockState(int x, int y, int z) { BlockPos pos = new BlockPos(x, y, z); - return (BlockState) ((ChunkRegion) (Object) this).getBlockState(pos); + return (BlockState) (this).getBlockState(pos); } public BlockEntity terraWorld$getBlockEntity(int x, int y, int z) { - return MinecraftUtil.createState((WorldAccess) this, new BlockPos(x, y, z)); + return MinecraftUtil.createState(this, new BlockPos(x, y, z)); } public int terraWorld$getMinHeight() { @@ -168,7 +168,7 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess { public Entity terraWorld$spawnEntity(double x, double y, double z, EntityType entityType) { net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType) entityType).create(world, SpawnReason.CHUNK_GENERATION); entity.setPos(x, y, z); - ((ChunkRegion) (Object) this).spawnEntity(entity); + spawnEntity(entity); return (Entity) entity; } diff --git a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ServerWorldMixin.java b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ServerWorldMixin.java index 8b5333257..957182f24 100644 --- a/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ServerWorldMixin.java +++ b/platforms/mixin-common/src/main/java/com/dfsek/terra/mod/mixin/implementations/terra/world/ServerWorldMixin.java @@ -129,24 +129,24 @@ public abstract class ServerWorldMixin extends World { } public int terra$getMaxHeight() { - return (((net.minecraft.server.world.ServerWorld) (Object) this).getBottomY()) + - ((net.minecraft.server.world.ServerWorld) (Object) this).getHeight(); + return ((this).getBottomY()) + + (this).getHeight(); } public Chunk terra$getChunkAt(int x, int z) { - return (Chunk) ((net.minecraft.server.world.ServerWorld) (Object) this).getChunk(x, z); + return (Chunk) (this).getChunk(x, z); } public BlockState terra$getBlockState(int x, int y, int z) { - return (BlockState) ((net.minecraft.server.world.ServerWorld) (Object) this).getBlockState(new BlockPos(x, y, z)); + return (BlockState) (this).getBlockState(new BlockPos(x, y, z)); } public BlockEntity terra$getBlockEntity(int x, int y, int z) { - return MinecraftUtil.createState((WorldAccess) this, new BlockPos(x, y, z)); + return MinecraftUtil.createState(this, new BlockPos(x, y, z)); } public int terra$getMinHeight() { - return ((net.minecraft.server.world.ServerWorld) (Object) this).getBottomY(); + return (this).getBottomY(); } public ChunkGenerator terra$getGenerator() {