From 1f18c6eb7c73cc6238b2b2b76b1972193e6ee985 Mon Sep 17 00:00:00 2001 From: lucaargolo Date: Sun, 9 Oct 2022 16:06:29 -0300 Subject: [PATCH] Fixes dehumidifier (Closes #165) --- .../kibe/mixin/WorldRendererMixin.java | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/github/lucaargolo/kibe/mixin/WorldRendererMixin.java b/src/main/java/io/github/lucaargolo/kibe/mixin/WorldRendererMixin.java index a867ec30..bacffc5a 100644 --- a/src/main/java/io/github/lucaargolo/kibe/mixin/WorldRendererMixin.java +++ b/src/main/java/io/github/lucaargolo/kibe/mixin/WorldRendererMixin.java @@ -2,35 +2,33 @@ import io.github.lucaargolo.kibe.blocks.miscellaneous.DehumidifierBlockEntity; import net.minecraft.client.render.WorldRenderer; -import net.minecraft.client.world.ClientWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.Heightmap; +import net.minecraft.world.World; import net.minecraft.world.WorldView; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(WorldRenderer.class) public class WorldRendererMixin { -// @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getTopY(Lnet/minecraft/world/Heightmap$Type;II)I"), method = "renderWeather") -// private int onRenderWeather(ClientWorld clientWorld, Heightmap.Type heightmap, int x, int z) { -// if(DehumidifierBlockEntity.Companion.isBeingDehumidified(new ChunkPos(new BlockPos(x, 0, z)))) { -// return 512; -// } -// return clientWorld.getTopY(heightmap, x, z); -// } + @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getTopY(Lnet/minecraft/world/Heightmap$Type;II)I"), method = "renderWeather") + private int onRenderWeather(World world, Heightmap.Type heightmap, int x, int z) { + if(DehumidifierBlockEntity.Companion.isBeingDehumidified(new ChunkPos(new BlockPos(x, 0, z)))) { + return 512; + } + return world.getTopY(heightmap, x, z); + } -// @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getTopPosition(Lnet/minecraft/world/Heightmap$Type;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/math/BlockPos;"), method = "tickRainSplashing") -// private BlockPos onTickRainSplashing(ClientWorld clientWorld, Heightmap.Type heightmap, BlockPos pos) { -// if(DehumidifierBlockEntity.Companion.isBeingDehumidified(new ChunkPos(pos))) { -// return new BlockPos(pos.getX(), 512, pos.getZ()); -// } -// return clientWorld.getTopPosition(heightmap, pos); -// } + @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/WorldView;getTopPosition(Lnet/minecraft/world/Heightmap$Type;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/math/BlockPos;"), method = "tickRainSplashing") + private BlockPos onTickRainSplashing(WorldView world, Heightmap.Type heightmap, BlockPos pos) { + if(DehumidifierBlockEntity.Companion.isBeingDehumidified(new ChunkPos(pos))) { + return new BlockPos(pos.getX(), 512, pos.getZ()); + } + return world.getTopPosition(heightmap, pos); + } }