Fix leaf rendering issue (#247)

* Fix and simplify leaf code

* Add SettingsManager.graphicsUpdated() call

Fixes an additional leaf rendering issue and some other things.
This commit is contained in:
jss2a98aj authored and GitHub committed 2024-01-28 14:18:30 -08:00
1 parent 64087f53c5
commit db49a613a0
9 files changed
+41 -39

No files matched your search

@@ -31,17 +31,17 @@ public abstract class MixinBlockLeaves extends BlockLeavesBase {
//A mod dev had no idea what they were doing.
return getIcon(side, world.getBlockMetadata(x, y, z));
}
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
renderMode = switch (renderMode) {
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
case 4 -> world.getBlock(
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
default -> renderMode > 1 ? 0 : renderMode;
};
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
maskedMeta = maskedMeta >= field_150129_M[renderMode].length ? 0 : maskedMeta;
return field_150129_M[renderMode][maskedMeta];
}
@@ -20,17 +20,17 @@ public abstract class MixinBlockMagicalLeaves extends Block implements ILeafBloc
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
renderMode = switch (renderMode) {
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
case 4 -> world.getBlock(
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
default -> renderMode > 1 ? 0 : renderMode;
};
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
return icon[renderMode + maskedMeta * 2];
}
@@ -17,17 +17,17 @@ public abstract class MixinBlockTFLeaves extends BlockLeaves {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
renderMode = switch (renderMode) {
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
case 4 -> world.getBlock(
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
default -> renderMode > 1 ? 0 : renderMode;
};
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
return Blocks.leaves.field_150129_M[renderMode][maskedMeta];
}
@@ -17,16 +17,16 @@ public abstract class MixinBlockTFLeaves3 extends BlockLeaves {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
renderMode = switch (renderMode) {
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
case 4 -> world.getBlock(
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
default -> renderMode > 1 ? 0 : renderMode;
};
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
return Blocks.leaves.field_150129_M[renderMode][0];
}
@@ -16,17 +16,17 @@ import twilightforest.block.BlockTFMagicLeaves;
public abstract class MixinBlockTFMagicLeaves extends BlockLeaves {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
renderMode = switch (renderMode) {
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
case 4 -> world.getBlock(
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
default -> renderMode > 1 ? 0 : renderMode;
};
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
return switch (maskedMeta) {
case 1 -> renderMode == 1 ? SPR_TRANSLEAVES_OPAQUE : SPR_TRANSLEAVES;
@@ -28,17 +28,17 @@ public abstract class MixinBlockWitchLeaves extends BlockLeavesBase {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
renderMode = switch (renderMode) {
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
case 4 -> world.getBlock(
int renderMode;
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
renderMode = world.getBlock(
x + Facing.offsetsXForSide[side],
y + Facing.offsetsYForSide[side],
z + Facing.offsetsZForSide[side]
) instanceof ILeafBlock ? 1 : 0;
default -> renderMode > 1 ? 0 : renderMode;
};
} else {
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
}
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
return iconsForModes[renderMode][maskedMeta];
}
@@ -85,7 +85,7 @@ public class SettingsManager {
//Do not re-enable, see MixinBlockLeaves workaround for Angelica/Sodium style menus.
//mc.renderGlobal.loadRenderers();
LeavesQuality value = (LeavesQuality)Settings.MODE_LEAVES.option.getStore();
leavesOpaque = value == LeavesQuality.FANCY || (value == LeavesQuality.DEFAULT && !mc.gameSettings.fancyGraphics);
leavesOpaque = value == LeavesQuality.FAST || (value == LeavesQuality.DEFAULT && !mc.gameSettings.fancyGraphics);
Blocks.leaves.setGraphicsLevel(!leavesOpaque);
Blocks.leaves2.setGraphicsLevel(!leavesOpaque);
}
@@ -32,7 +32,7 @@ public class LeafRenderUtil {
}
if(otherBlock instanceof ILeafBlock) {
switch ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()) {
case FANCY, SMART -> {
case FAST, SMART -> {
return false;
}
case SHELLED_FANCY, SHELLED_FAST -> {
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import jss.notfine.core.Settings;
import jss.notfine.core.SettingsManager;
import me.flashyreese.mods.reeses_sodium_options.client.gui.ReeseSodiumVideoOptionsScreen;
import me.jellysquid.mods.sodium.client.gui.options.OptionFlag;
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup;
@@ -162,7 +163,8 @@ public class SodiumGameOptionPages {
.setTooltip(I18n.format("sodium.options.graphics_quality.tooltip"))
.setControl(option -> new CyclingControl<>(option, GraphicsMode.class))
.setBinding(
(opts, value) -> opts.fancyGraphics = value.isFancy(),
(opts, value) -> { opts.fancyGraphics = value.isFancy();
SettingsManager.graphicsUpdated(); },
opts -> GraphicsMode.fromBoolean(opts.fancyGraphics))
.setImpact(OptionImpact.HIGH)
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)