Skip to content

Commit

Permalink
fix compatibility with optifine D6 (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
FalsePattern committed Dec 17, 2024
1 parent 58a33ba commit 00d9db9
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* This file is part of FalseTweaks.
*
* Copyright (C) 2022-2024 FalsePattern
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* FalseTweaks is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FalseTweaks is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FalseTweaks. If not, see <https://www.gnu.org/licenses/>.
*/

package com.falsepattern.falsetweaks.mixin.mixins.client.cc.of;

import com.falsepattern.falsetweaks.modules.dynlights.DynamicLightsDrivers;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import net.minecraft.block.Block;
import net.minecraft.world.ChunkCache;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

@Mixin(targets = "ChunkCacheOF",
remap = false)
public abstract class ChunkCacheOF_NonShaderMixin extends ChunkCache {
public ChunkCacheOF_NonShaderMixin(World p_i1964_1_, int p_i1964_2_, int p_i1964_3_, int p_i1964_4_, int p_i1964_5_, int p_i1964_6_, int p_i1964_7_, int p_i1964_8_) {
super(p_i1964_1_, p_i1964_2_, p_i1964_3_, p_i1964_4_, p_i1964_5_, p_i1964_6_, p_i1964_7_, p_i1964_8_);
}

@Dynamic
@Redirect(method = "getLightBrightnessForSkyBlocks",
at = @At(value = "INVOKE",
target = "LConfig;isDynamicLights()Z"),
require = 2)
private boolean ftDynamicLights() {
return DynamicLightsDrivers.frontend.enabled();
}

@Dynamic
@Redirect(method = "getLightBrightnessForSkyBlocks",
at = @At(value = "INVOKE",
target = "LDynamicLights;getCombinedLight(IIII)I"),
require = 2)
private int ftCombinedLights(int x, int y, int z, int combinedLight) {
return DynamicLightsDrivers.frontend.forWorldMesh().getCombinedLight(x, y, z, combinedLight);
}

@Dynamic
@Redirect(method = "getLightBrightnessForSkyBlocks",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/IBlockAccess;getLightBrightnessForSkyBlocks(IIII)I",
remap = true),
require = 2)
private int brightnessFromSuper(IBlockAccess instance, int x, int y, int z, int lightValue) {
return super.getLightBrightnessForSkyBlocks(x, y, z, lightValue);
}

@Dynamic
@Redirect(method = "func_147439_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/IBlockAccess;getBlock(III)Lnet/minecraft/block/Block;",
remap = true),
remap = true,
require = 2)
private Block blockFromSuper(IBlockAccess instance, int x, int y, int z) {
return super.getBlock(x, y, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@

@Mixin(targets = "ChunkCacheOF",
remap = false)
public abstract class ChunkCacheOFMixin extends ChunkCache {
public ChunkCacheOFMixin(World p_i1964_1_, int p_i1964_2_, int p_i1964_3_, int p_i1964_4_, int p_i1964_5_, int p_i1964_6_, int p_i1964_7_, int p_i1964_8_) {
public abstract class ChunkCacheOF_ShaderMixin extends ChunkCache {
public ChunkCacheOF_ShaderMixin(World p_i1964_1_, int p_i1964_2_, int p_i1964_3_, int p_i1964_4_, int p_i1964_5_, int p_i1964_6_, int p_i1964_7_, int p_i1964_8_) {
super(p_i1964_1_, p_i1964_2_, p_i1964_3_, p_i1964_4_, p_i1964_5_, p_i1964_6_, p_i1964_7_, p_i1964_8_);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ public enum Mixin implements IMixin {

//region Chunk Cache Module
CC_WorldRendererMixin(Side.CLIENT, condition(() -> ModuleConfig.DYNAMIC_LIGHTS || ModuleConfig.FASTER_CHUNK_CACHE).and(AVOID_OPTIFINE_WITH_DYNAMIC_LIGHTS), "cc.WorldRendererMixin"),
CC_OF_ChunkCacheOFMixin(Side.CLIENT, REQUIRE_OPTIFINE_WITH_DYNAMIC_LIGHTS, "cc.of.ChunkCacheOFMixin"),
CC_OF_ChunkCacheOF_ShaderMixin(Side.CLIENT, REQUIRE_OPTIFINE_WITH_SHADERS, "cc.of.ChunkCacheOF_ShaderMixin"),
CC_OF_ChunkCacheOF_NonShaderMixin(Side.CLIENT, REQUIRE_OPTIFINE_WITH_DYNAMIC_LIGHTS.and(AVOID_OPTIFINE_WITH_SHADERS), "cc.of.ChunkCacheOF_NonShaderMixin"),
//endregion Chunk Cache Module

//region Misc Modules
Expand Down

0 comments on commit 00d9db9

Please sign in to comment.