Skip to content

Commit

Permalink
ensure mlShulkerBoxPreviewSupportEnderChest work with mc1.20.6+ min…
Browse files Browse the repository at this point in the history
…ihud as well

minihud introduced the same check as what tweakeroo introduced in mc1.20.6
resolved #80
  • Loading branch information
Fallen-Breath committed Nov 12, 2024
1 parent a323830 commit e0b95ac
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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+
}
1 change: 1 addition & 0 deletions src/main/resources/tweakermore.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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);
}
}

0 comments on commit e0b95ac

Please sign in to comment.