diff --git a/src/main/java/io/pyke/vitri/finorza/inference/mixin/ducttape/RecipeBookComponentMixin.java b/src/main/java/io/pyke/vitri/finorza/inference/mixin/ducttape/RecipeBookComponentMixin.java new file mode 100644 index 0000000..2fcc8c1 --- /dev/null +++ b/src/main/java/io/pyke/vitri/finorza/inference/mixin/ducttape/RecipeBookComponentMixin.java @@ -0,0 +1,22 @@ +package io.pyke.vitri.finorza.inference.mixin.ducttape; + +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(RecipeBookComponent.class) +public class RecipeBookComponentMixin { + @Shadow + private EditBox searchBox; + + @Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;IIF)V", at = @At("HEAD"), cancellable = true) + private void render(CallbackInfo ci) { + if (searchBox == null) { + ci.cancel(); + } + } +} diff --git a/src/main/java/io/pyke/vitri/finorza/inference/mixin/ducttape/RecipeButtonMixin.java b/src/main/java/io/pyke/vitri/finorza/inference/mixin/ducttape/RecipeButtonMixin.java new file mode 100644 index 0000000..010ccab --- /dev/null +++ b/src/main/java/io/pyke/vitri/finorza/inference/mixin/ducttape/RecipeButtonMixin.java @@ -0,0 +1,26 @@ +package io.pyke.vitri.finorza.inference.mixin.ducttape; + +import java.util.List; + +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; +import net.minecraft.client.gui.screens.recipebook.RecipeButton; +import net.minecraft.world.item.crafting.Recipe; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(RecipeButton.class) +public abstract class RecipeButtonMixin { + @Shadow + protected abstract List> getOrderedRecipes(); + + @Inject(method = "Lnet/minecraft/client/gui/screens/recipebook/RecipeButton;renderButton(Lcom/mojang/blaze3d/vertex/PoseStack;IIF)V", at = @At(value = "HEAD"), cancellable = true) + private void render(CallbackInfo ci) { + if (this.getOrderedRecipes().isEmpty()) { + ci.cancel(); + } + } +} diff --git a/src/main/resources/finorza.mixins.json b/src/main/resources/finorza.mixins.json index acba918..e1d2e0d 100644 --- a/src/main/resources/finorza.mixins.json +++ b/src/main/resources/finorza.mixins.json @@ -6,6 +6,8 @@ "client": [ "ClientRecipeBookMixin", "MinecraftMixin", + "ducttape.RecipeBookComponentMixin", + "ducttape.RecipeButtonMixin", "input.KeyboardHandlerMixin", "input.MouseHandlerMixin", "input.ScreenMixin",