Fix camera fluid check in 1.12.2 to use eye position instead of entity position

This commit is contained in:
Vojtěch Šokala
2026-06-07 22:39:53 +02:00
parent 3da97f75d7
commit 1d7cb1e6fc
2 changed files with 13 additions and 1 deletions
@@ -21,7 +21,11 @@ import net.minecraft.world.entity.LivingEntity;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.init.MobEffects;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraft.block.state.IBlockState;
#elif MC_VER < MC_1_17_1
import net.minecraft.world.level.material.FluidState;
import net.minecraft.client.renderer.FogRenderer;
@@ -129,7 +133,11 @@ public class MixinVanillaFogCommon
#endif
{
#if MC_VER <= MC_1_12_2
boolean cameraNotInFluid = mc.getRenderViewEntity() != null && !mc.world.getBlockState(mc.getRenderViewEntity().getPosition()).getMaterial().isLiquid();
Entity view = mc.getRenderViewEntity();
if (view == null) return true;
IBlockState fluidState = mc.world.getBlockState(new BlockPos(view.getPositionEyes(mc.getRenderPartialTicks())));
boolean cameraNotInFluid = !(fluidState.getMaterial().isLiquid() || fluidState.getBlock() instanceof IFluidBlock);
#elif MC_VER < MC_1_17_1
FluidState fluidState = camera.getFluidInCamera();
boolean cameraNotInFluid = fluidState.isEmpty();
@@ -49,7 +49,11 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
// This prevents multiple threads from creating duplicate wrappers for the same level.
synchronized (this.keyedLevelsCache)
{
#if MC_VER <= MC_1_12_2
WorldClient level = (WorldClient) levelWrapper.getWrappedMcObject();
#else
ClientLevel level = (ClientLevel) levelWrapper.getWrappedMcObject();
#endif
// Check the cache first
IServerKeyedClientLevel cached = this.keyedLevelsCache.get(level);