diff options
author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2024-09-21 18:31:34 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-21 10:31:34 +0200 |
commit | 1da7050a5b95e6e1cf0111c3a71b042168d3918e (patch) | |
tree | eedb1c8091ca0b5f5f60033386919f2c91840b51 /src | |
parent | 1062c413cc17b0e99ca527b33568edf71642cab5 (diff) | |
download | skyhanni-1da7050a5b95e6e1cf0111c3a71b042168d3918e.tar.gz skyhanni-1da7050a5b95e6e1cf0111c3a71b042168d3918e.tar.bz2 skyhanni-1da7050a5b95e6e1cf0111c3a71b042168d3918e.zip |
Make Mining Commissions Blocks Colour actually work with connected textures instead of just turning them off 🙂 (#2559)
Diffstat (limited to 'src')
3 files changed, 58 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/OptifineConnectedTexturesHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/OptifineConnectedTexturesHook.kt new file mode 100644 index 000000000..f930e1008 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/OptifineConnectedTexturesHook.kt @@ -0,0 +1,35 @@ +package at.hannibal2.skyhanni.mixins.hooks + +import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor +import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor.CommissionBlock.Companion.onColor +import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor.replaceBlocksMapCache +import at.hannibal2.skyhanni.features.mining.OreType.Companion.isOreType +import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.block.state.IBlockState + +fun modifyConnectedTexturesBlockState(state: IBlockState): IBlockState { + if (state == null) return state + var returnState: IBlockState = state + + if (!LorenzUtils.inSkyBlock) return state + + try { + if (MiningCommissionsBlocksColor.enabled && MiningCommissionsBlocksColor.active) { + returnState = replaceBlocksMapCache.getOrPut(state) { + MiningCommissionsBlocksColor.CommissionBlock.entries.firstOrNull { + state.isOreType(it.oreType) + }?.onColor(state) ?: state + } + } + } catch (e: Exception) { + ErrorManager.logErrorWithData(e, "Error in MiningCommissionsBlocksColor") + } + + if (returnState !== state) { + + return returnState + } + return state +} + diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinOptifineConfig.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinOptifineConfig.java deleted file mode 100644 index 97b20f19a..000000000 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinOptifineConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package at.hannibal2.skyhanni.mixins.transformers; - -import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Pseudo -@Mixin(targets = "Config", remap = false) -public class MixinOptifineConfig { - - @Inject(method = {"isConnectedTextures", "isConnectedTexturesFancy"}, at = @At("HEAD"), cancellable = true) - private static void isConnectedTextures(CallbackInfoReturnable<Boolean> cir) { - if (MiningCommissionsBlocksColor.INSTANCE.getActive()) cir.setReturnValue(false); - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinOptifineConnectedTextures.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinOptifineConnectedTextures.java new file mode 100644 index 000000000..9f3087e8e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinOptifineConnectedTextures.java @@ -0,0 +1,23 @@ +package at.hannibal2.skyhanni.mixins.transformers; + +import at.hannibal2.skyhanni.mixins.hooks.OptifineConnectedTexturesHookKt; +import net.minecraft.block.state.IBlockState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Pseudo +@Mixin(targets = "net.optifine.ConnectedTextures", remap = false) +public class MixinOptifineConnectedTextures { + + @ModifyArg(method = "getConnectedTexture", at = @At(value = "INVOKE", target = "getConnectedTextureMultiPass")) + private static IBlockState modifyGetConnectedTextureMultiPass(IBlockState state) { + return OptifineConnectedTexturesHookKt.modifyConnectedTexturesBlockState(state); + } + + @ModifyArg(method = "getConnectedTexture", at = @At(value = "INVOKE", target = "skipConnectedTexture")) + private static IBlockState modifySkipConnectedTexture(IBlockState state) { + return OptifineConnectedTexturesHookKt.modifyConnectedTexturesBlockState(state); + } +} |