From e0b95ac26615f28b889d1f22765b60976ee59cfa Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Wed, 13 Nov 2024 01:09:29 +0800 Subject: [PATCH] ensure `mlShulkerBoxPreviewSupportEnderChest` work with mc1.20.6+ minihud as well minihud introduced the same check as what tweakeroo introduced in mc1.20.6 resolved #80 --- .../compat/minihud/RenderHandlerMixin.java | 34 ++++++++++ src/main/resources/tweakermore.mixins.json | 1 + .../compat/minihud/RenderHandlerMixin.java | 63 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mod_tweaks/mlShulkerBoxPreviewSupportEnderChest/compat/minihud/RenderHandlerMixin.java create mode 100644 versions/1.20.6/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mod_tweaks/mlShulkerBoxPreviewSupportEnderChest/compat/minihud/RenderHandlerMixin.java diff --git a/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mod_tweaks/mlShulkerBoxPreviewSupportEnderChest/compat/minihud/RenderHandlerMixin.java b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mod_tweaks/mlShulkerBoxPreviewSupportEnderChest/compat/minihud/RenderHandlerMixin.java new file mode 100644 index 00000000..e0e24189 --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mod_tweaks/mlShulkerBoxPreviewSupportEnderChest/compat/minihud/RenderHandlerMixin.java @@ -0,0 +1,34 @@ +/* + * This file is part of the TweakerMore project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * TweakerMore 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. + * + * TweakerMore 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 TweakerMore. If not, see . + */ + +package me.fallenbreath.tweakermore.mixins.tweaks.mod_tweaks.mlShulkerBoxPreviewSupportEnderChest.compat.minihud; + +import me.fallenbreath.conditionalmixin.api.annotation.Condition; +import me.fallenbreath.conditionalmixin.api.annotation.Restriction; +import me.fallenbreath.tweakermore.util.ModIds; +import me.fallenbreath.tweakermore.util.mixin.DummyClass; +import org.spongepowered.asm.mixin.Mixin; + +@Restriction(require = @Condition(ModIds.tweakeroo)) +@Mixin(DummyClass.class) +public abstract class RenderHandlerMixin +{ + // impl in mc 1.20.6+ +} diff --git a/src/main/resources/tweakermore.mixins.json b/src/main/resources/tweakermore.mixins.json index 0f6b9ea6..4f576f40 100644 --- a/src/main/resources/tweakermore.mixins.json +++ b/src/main/resources/tweakermore.mixins.json @@ -183,6 +183,7 @@ "tweaks.mod_tweaks.minihudHideIfChatScreenOpened.RenderHandlerMixin", "tweaks.mod_tweaks.mlShulkerBoxPreviewSupportEnderChest.BasicInventoryAccessor", "tweaks.mod_tweaks.mlShulkerBoxPreviewSupportEnderChest.RenderUtilsMixin", + "tweaks.mod_tweaks.mlShulkerBoxPreviewSupportEnderChest.compat.minihud.RenderHandlerMixin", "tweaks.mod_tweaks.mlShulkerBoxPreviewSupportEnderChest.compat.tweakeroo.RenderHandlerMixin", "tweaks.mod_tweaks.ofRemoveItemFrameItemRenderDistance.ItemFrameEntityRendererMixin", "tweaks.mod_tweaks.ofRemoveSignTextRenderDistance.SignBlockEntityRendererMixin", diff --git a/versions/1.20.6/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mod_tweaks/mlShulkerBoxPreviewSupportEnderChest/compat/minihud/RenderHandlerMixin.java b/versions/1.20.6/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mod_tweaks/mlShulkerBoxPreviewSupportEnderChest/compat/minihud/RenderHandlerMixin.java new file mode 100644 index 00000000..54d920a9 --- /dev/null +++ b/versions/1.20.6/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mod_tweaks/mlShulkerBoxPreviewSupportEnderChest/compat/minihud/RenderHandlerMixin.java @@ -0,0 +1,63 @@ +/* + * This file is part of the TweakerMore project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * TweakerMore 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. + * + * TweakerMore 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 TweakerMore. If not, see . + */ + +package me.fallenbreath.tweakermore.mixins.tweaks.mod_tweaks.mlShulkerBoxPreviewSupportEnderChest.compat.minihud; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; +import fi.dy.masa.minihud.event.RenderHandler; +import me.fallenbreath.conditionalmixin.api.annotation.Condition; +import me.fallenbreath.conditionalmixin.api.annotation.Restriction; +import me.fallenbreath.tweakermore.impl.mod_tweaks.mlShulkerBoxPreviewSupportEnderChest.EnderChestItemFetcher; +import me.fallenbreath.tweakermore.util.ModIds; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Restriction(require = @Condition(ModIds.minihud)) +@Mixin(RenderHandler.class) +public abstract class RenderHandlerMixin +{ + // at least sakura-ryoko's fork adds these extra checks + + @ModifyExpressionValue( + method = "onRenderTooltipLast", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/component/ComponentMap;contains(Lnet/minecraft/component/DataComponentType;)Z" + ) + ) + private boolean mlShulkerBoxPreviewSupportEnderChest_minihudSkipCheck1(boolean contains, @Local(argsOnly = true) ItemStack stack) + { + return contains || EnderChestItemFetcher.enableFor(stack); + } + + @ModifyExpressionValue( + method = "onRenderTooltipLast", + at = @At( + value = "INVOKE", + target = "Lfi/dy/masa/malilib/util/InventoryUtils;shulkerBoxHasItems(Lnet/minecraft/item/ItemStack;)Z" + ) + ) + private boolean mlShulkerBoxPreviewSupportEnderChest_minihudSkipCheck2(boolean contains, @Local(argsOnly = true) ItemStack stack) + { + return contains || EnderChestItemFetcher.enableFor(stack); + } +}