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.
This commit is contained in:
Zoë Gidiere
2025-10-05 21:51:40 -06:00
parent 96493ede15
commit 2b09ed8fd9
2 changed files with 9 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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() {