From 1da7050a5b95e6e1cf0111c3a71b042168d3918e Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:31:34 +1000 Subject: Make Mining Commissions Blocks Colour actually work with connected textures instead of just turning them off 🙂 (#2559) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mixins/hooks/OptifineConnectedTexturesHook.kt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/hooks/OptifineConnectedTexturesHook.kt (limited to 'src/main/java/at/hannibal2/skyhanni/mixins/hooks') 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 +} + -- cgit