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

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