Water color option, disabling color if sodium is installed

This commit is contained in:
paulevsGitch 2021-01-23 01:37:52 +03:00
parent 7d178dedb0
commit f62f88e4bd
2 changed files with 50 additions and 33 deletions

View file

@ -1,16 +1,22 @@
package ru.betterend.client; package ru.betterend.client;
import net.fabricmc.loader.api.FabricLoader;
import ru.betterend.config.Configs; import ru.betterend.config.Configs;
public class ClientOptions { public class ClientOptions {
private static boolean customSky; private static boolean customSky;
private static boolean useFogDensity; private static boolean useFogDensity;
private static boolean blendBiomeMusic; private static boolean blendBiomeMusic;
private static boolean sulfurWaterColor;
public static void init() { public static void init() {
setCustomSky(Configs.CLENT_CONFIG.getBooleanRoot("customSky", true)); customSky = Configs.CLENT_CONFIG.getBooleanRoot("customSky", true);
setUseFogDensity(Configs.CLENT_CONFIG.getBooleanRoot("useFogDensity", true)); useFogDensity = Configs.CLENT_CONFIG.getBooleanRoot("useFogDensity", true);
setBlendBiomeMusic(Configs.CLENT_CONFIG.getBooleanRoot("blendBiomeMusic", true)); blendBiomeMusic = Configs.CLENT_CONFIG.getBooleanRoot("blendBiomeMusic", true);
sulfurWaterColor = Configs.CLENT_CONFIG.getBooleanRoot("sulfurWaterColor", true);
if (sulfurWaterColor) {
sulfurWaterColor = !FabricLoader.getInstance().isModLoaded("sodium");
}
Configs.CLENT_CONFIG.saveChanges(); Configs.CLENT_CONFIG.saveChanges();
} }
@ -37,4 +43,12 @@ public class ClientOptions {
public static void setBlendBiomeMusic(boolean blendBiomeMusic) { public static void setBlendBiomeMusic(boolean blendBiomeMusic) {
ClientOptions.blendBiomeMusic = blendBiomeMusic; ClientOptions.blendBiomeMusic = blendBiomeMusic;
} }
public static boolean useSulfurWaterColor() {
return sulfurWaterColor;
}
public static void setSulfurWaterColor(boolean sulfurWaterColor) {
ClientOptions.sulfurWaterColor = sulfurWaterColor && !FabricLoader.getInstance().isModLoaded("sodium");
}
} }

View file

@ -10,6 +10,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockRenderView; import net.minecraft.world.BlockRenderView;
import ru.betterend.client.ClientOptions;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper; import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper; import ru.betterend.util.MHelper;
@ -21,41 +22,43 @@ public class BiomeColorsMixin {
@Inject(method = "getWaterColor", at = @At("RETURN"), cancellable = true) @Inject(method = "getWaterColor", at = @At("RETURN"), cancellable = true)
private static void be_getWaterColor(BlockRenderView world, BlockPos pos, CallbackInfoReturnable<Integer> info) { private static void be_getWaterColor(BlockRenderView world, BlockPos pos, CallbackInfoReturnable<Integer> info) {
int color = info.getReturnValue(); if (ClientOptions.useSulfurWaterColor()) {
int color = info.getReturnValue();
boolean scanDeep = true;
Mutable mut = new Mutable(); boolean scanDeep = true;
for (Direction d: BlocksHelper.HORIZONTAL) { Mutable mut = new Mutable();
mut.set(pos).move(d); for (Direction d: BlocksHelper.HORIZONTAL) {
if ((world.getBlockState(mut).isOf(EndBlocks.BRIMSTONE))) { mut.set(pos).move(d);
color = POISON_COLOR; if ((world.getBlockState(mut).isOf(EndBlocks.BRIMSTONE))) {
scanDeep = false; color = POISON_COLOR;
break; scanDeep = false;
break;
}
} }
}
if (scanDeep) {
if (scanDeep) { int x1 = pos.getX() - 2;
int x1 = pos.getX() - 2; int z1 = pos.getZ() - 2;
int z1 = pos.getZ() - 2;
int x2 = pos.getX() + 3;
int x2 = pos.getX() + 3; int z2 = pos.getZ() + 3;
int z2 = pos.getZ() + 3;
mut.setY(pos.getY());
mut.setY(pos.getY()); for (int x = x1; x < x2 && scanDeep; x++) {
for (int x = x1; x < x2 && scanDeep; x++) { mut.setX(x);
mut.setX(x); for (int z = z1; z < z2 && scanDeep; z++) {
for (int z = z1; z < z2 && scanDeep; z++) { mut.setZ(z);
mut.setZ(z); if (Math.abs(pos.getX() - x) != 2 || Math.abs(pos.getZ() - z) != 2) {
if (Math.abs(pos.getX() - x) != 2 || Math.abs(pos.getZ() - z) != 2) { if ((world.getBlockState(mut).isOf(EndBlocks.BRIMSTONE))) {
if ((world.getBlockState(mut).isOf(EndBlocks.BRIMSTONE))) { color = STREAM_COLOR;
color = STREAM_COLOR; scanDeep = false;
scanDeep = false; }
} }
} }
} }
} }
info.setReturnValue(color);
} }
info.setReturnValue(color);
} }
} }