Skip to content

Commit

Permalink
Fix water not respecting custom biome colormaps
Browse files Browse the repository at this point in the history
  • Loading branch information
kvverti committed Jul 29, 2019
1 parent 9d48179 commit 5662b29
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
package io.github.kvverti.colormatic.mixin.color;

import io.github.kvverti.colormatic.Colormatic;
import io.github.kvverti.colormatic.colormap.BiomeColormaps;

import net.minecraft.block.BlockState;
import net.minecraft.client.color.world.BiomeColors;
import net.minecraft.tag.FluidTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ExtendedBlockView;
import net.minecraft.world.biome.Biome;

import org.spongepowered.asm.mixin.Dynamic;
Expand All @@ -43,6 +47,18 @@ private static void onWaterColor(Biome biome, BlockPos pos, CallbackInfoReturnab
}
}

/**
* The FluidRenderer calls BiomeColors#getWaterColor directly, instead of
* going through BlockColors. So, we must check for custom water color here.
*/
@Inject(method = "getWaterColor", at = @At("HEAD"), cancellable = true)
private static void onWaterColorPre(ExtendedBlockView world, BlockPos pos, CallbackInfoReturnable<Integer> info) {
BlockState state = world.getBlockState(pos);
if(state.getFluidState().matches(FluidTags.WATER) && BiomeColormaps.isCustomColored(state)) {
info.setReturnValue(BiomeColormaps.getBiomeColor(state, world, pos));
}
}

// currently unused in vanilla
@Dynamic("underwater color lambda method")
@Inject(method = "method_4964", at = @At("HEAD"), cancellable = true)
Expand Down

0 comments on commit 5662b29

Please sign in to comment.