From f056eb5a458ae95dff2cdbd84217e491f72a3d06 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 21 Sep 2024 10:32:43 +0200 Subject: MiningCommissionsBlocksColor.processState --- .../mixins/hooks/BlockRendererDispatcherHook.kt | 21 +++------------- .../mixins/hooks/OptifineConnectedTexturesHook.kt | 28 ++-------------------- 2 files changed, 5 insertions(+), 44 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/mixins/hooks') diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt index f72d56739..cf4e4ba40 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt @@ -1,10 +1,6 @@ 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 import net.minecraft.client.renderer.BlockRendererDispatcher @@ -21,24 +17,13 @@ fun modifyGetModelFromBlockState( pos: BlockPos?, cir: CallbackInfoReturnable, ) { - if (state == null || pos == null) return - var returnState: IBlockState = state + if (pos == null) return if (!LorenzUtils.inSkyBlock) return - 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") - } + val returnState = MiningCommissionsBlocksColor.processState(state) - if (returnState !== state) { + if (returnState != state) { cir.returnValue = blockRendererDispatcher.blockModelShapes.getModelForState(returnState) } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/OptifineConnectedTexturesHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/OptifineConnectedTexturesHook.kt index f930e1008..fe4619cf2 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/OptifineConnectedTexturesHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/OptifineConnectedTexturesHook.kt @@ -1,35 +1,11 @@ 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 - +fun modifyConnectedTexturesBlockState(state: IBlockState?): IBlockState? { 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 + return MiningCommissionsBlocksColor.processState(state) } -- cgit