remove some @Shadow methods in favor of casts

This commit is contained in:
dfsek 2022-05-26 12:16:40 -07:00
parent 68ef5a5a32
commit 5275c40c6a
2 changed files with 7 additions and 9 deletions

View File

@ -24,6 +24,7 @@ import net.minecraft.world.ChunkRegion;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.tick.MultiTickScheduler;
import net.minecraft.world.tick.OrderedTick; import net.minecraft.world.tick.OrderedTick;
import net.minecraft.world.tick.QueryableTickScheduler; import net.minecraft.world.tick.QueryableTickScheduler;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@ -70,7 +71,8 @@ public abstract class ChunkRegionMixin {
private Chunk centerPos; private Chunk centerPos;
@Shadow @Shadow
public abstract QueryableTickScheduler<Fluid> getFluidTickScheduler(); @Final
private MultiTickScheduler<Fluid> fluidTickScheduler;
@Inject(at = @At("RETURN"), @Inject(at = @At("RETURN"),
method = "<init>(Lnet/minecraft/server/world/ServerWorld;Ljava/util/List;Lnet/minecraft/world/chunk/ChunkStatus;I)V") method = "<init>(Lnet/minecraft/server/world/ServerWorld;Ljava/util/List;Lnet/minecraft/world/chunk/ChunkStatus;I)V")
@ -94,7 +96,7 @@ public abstract class ChunkRegionMixin {
BlockPos pos = new BlockPos(x, y, z); BlockPos pos = new BlockPos(x, y, z);
((ChunkRegion) (Object) this).setBlockState(pos, (net.minecraft.block.BlockState) data, physics ? 3 : 1042); ((ChunkRegion) (Object) this).setBlockState(pos, (net.minecraft.block.BlockState) data, physics ? 3 : 1042);
if(physics && ((net.minecraft.block.BlockState) data).getBlock() instanceof FluidBlock) { if(physics && ((net.minecraft.block.BlockState) data).getBlock() instanceof FluidBlock) {
getFluidTickScheduler().scheduleTick( fluidTickScheduler.scheduleTick(
OrderedTick.create(((FluidBlock) ((net.minecraft.block.BlockState) data).getBlock()).getFluidState( OrderedTick.create(((FluidBlock) ((net.minecraft.block.BlockState) data).getBlock()).getFluidState(
(net.minecraft.block.BlockState) data).getFluid(), pos)); (net.minecraft.block.BlockState) data).getFluid(), pos));
} }

View File

@ -44,10 +44,6 @@ import com.dfsek.terra.fabric.util.FabricUtil;
@Mixin(net.minecraft.server.world.ServerWorld.class) @Mixin(net.minecraft.server.world.ServerWorld.class)
@Implements(@Interface(iface = ServerWorld.class, prefix = "terra$")) @Implements(@Interface(iface = ServerWorld.class, prefix = "terra$"))
public abstract class ServerWorldMixin { public abstract class ServerWorldMixin {
@Shadow
@Final
private ServerChunkManager chunkManager;
public Entity terra$spawnEntity(double x, double y, double z, EntityType entityType) { public Entity terra$spawnEntity(double x, double y, double z, EntityType entityType) {
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create( net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(
((net.minecraft.server.world.ServerWorld) (Object) this)); ((net.minecraft.server.world.ServerWorld) (Object) this));
@ -89,7 +85,7 @@ public abstract class ServerWorldMixin {
} }
public ChunkGenerator terra$getGenerator() { public ChunkGenerator terra$getGenerator() {
return ((FabricChunkGeneratorWrapper) chunkManager.getChunkGenerator()).getHandle(); return ((FabricChunkGeneratorWrapper) ((net.minecraft.server.world.ServerWorld) (Object) this).getChunkManager().getChunkGenerator()).getHandle();
} }
public BiomeProvider terra$getBiomeProvider() { public BiomeProvider terra$getBiomeProvider() {
@ -99,7 +95,7 @@ public abstract class ServerWorldMixin {
} }
public ConfigPack terra$getPack() { public ConfigPack terra$getPack() {
net.minecraft.world.gen.chunk.ChunkGenerator generator = chunkManager.getChunkGenerator(); net.minecraft.world.gen.chunk.ChunkGenerator generator = (((net.minecraft.server.world.ServerWorld) (Object) this).getChunkManager()).getChunkGenerator();
if(generator instanceof FabricChunkGeneratorWrapper fabricChunkGeneratorWrapper) { if(generator instanceof FabricChunkGeneratorWrapper fabricChunkGeneratorWrapper) {
return fabricChunkGeneratorWrapper.getPack(); return fabricChunkGeneratorWrapper.getPack();
} }