Skip to content

Commit

Permalink
Simplify leaves mixin
Browse files Browse the repository at this point in the history
1.12 doesn't have the bug where leaves render their insides on Fast
graphics, so only need to apply our setting override
  • Loading branch information
embeddedt committed Jan 13, 2024
1 parent a78c989 commit 441746a
Showing 1 changed file with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,17 @@
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(BlockLeaves.class)
public class MixinLeavesBlock extends Block {

@Shadow
protected boolean leavesFancy;

public MixinLeavesBlock(Material blockMaterialIn, MapColor blockMapColorIn) {
super(blockMaterialIn, blockMapColorIn);
}

@Override
public BlockRenderLayer getRenderLayer() {
return SodiumClientMod.options().quality.leavesQuality.isFancy(leavesFancy) ? BlockRenderLayer.CUTOUT_MIPPED : BlockRenderLayer.SOLID;
}

@Override
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
if (SodiumClientMod.options().quality.leavesQuality.isFancy(Minecraft.getMinecraft().gameSettings.fancyGraphics)) {
return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
} else {
return blockAccess.getBlockState(pos.offset(side)).getBlock() instanceof BlockLeaves || super.shouldSideBeRendered(blockState, blockAccess, pos, side);
}
@ModifyVariable(method = "setGraphicsLevel", at = @At("HEAD"), argsOnly = true, index = 1)
private boolean getSodiumLeavesQuality(boolean fancy) {
return SodiumClientMod.options().quality.leavesQuality.isFancy(fancy);
}
}

0 comments on commit 441746a

Please sign in to comment.