aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/OptifineConnectedTexturesHook.kt35
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinOptifineConfig.java18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinOptifineConnectedTextures.java23
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);
+ }
+}