Skip to content

Commit

Permalink
Implement Patchouli compatibility for Remove Recipe Book tweak, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Mar 11, 2024
1 parent 0e4e4ee commit 3d0823f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ dependencies {
compileOnly 'curse.maven:mrtjpcore-229002:2735197'
compileOnly 'curse.maven:netherchest-268888:2655413'
compileOnly 'curse.maven:netherrocks-226140:2628297'
compileOnly 'curse.maven:patchouli-306770:3162874'
compileOnly 'curse.maven:plustic-376903:4703532'
compileOnly 'curse.maven:projectredbase-228702:2745545'
compileOnly 'curse.maven:projectredworld-229049:2745551'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import net.minecraft.client.gui.GuiButtonImage;
import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Loader;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
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.Redirect;
import vazkii.patchouli.common.base.PatchouliConfig;

@Mixin(GuiCrafting.class)
public class UTRecipeBookCraftMixin
Expand All @@ -20,6 +23,11 @@ public class UTRecipeBookCraftMixin
@Redirect(method = "initGui", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/inventory/GuiCrafting;recipeButton:Lnet/minecraft/client/gui/GuiButtonImage;", ordinal = 0))
public void utHideRecipeBook(GuiCrafting instance, GuiButtonImage value)
{
if (!UTConfigTweaks.MISC.utRecipeBookToggle || (Loader.isModLoaded("patchouli") && !PatchouliConfig.inventoryButtonBook.isEmpty()))
{
this.recipeButton = value;
return;
}
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTRecipeBookCraft ::: Initialize GUI");
this.recipeButton = new GuiButtonImage(10, 0, 0, 0, 0, 0, 0, 0, new ResourceLocation("textures/gui/container/crafting_table.png"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.minecraft.client.gui.recipebook.GuiRecipeBook;
import net.minecraft.inventory.InventoryCrafting;

import net.minecraftforge.fml.common.Loader;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
Expand All @@ -11,14 +13,15 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import vazkii.patchouli.common.base.PatchouliConfig;

@Mixin(GuiRecipeBook.class)
public abstract class UTRecipeBookGUIMixin
{
@Inject(method = "initVisuals", at = @At(value = "TAIL"))
public void utHideRecipeBook(boolean p_193014_1_, InventoryCrafting p_193014_2_, CallbackInfo ci)
{
if (!UTConfigTweaks.MISC.utRecipeBookToggle) return;
if (!UTConfigTweaks.MISC.utRecipeBookToggle || (Loader.isModLoaded("patchouli") && !PatchouliConfig.inventoryButtonBook.isEmpty())) return;
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTRecipeBookGUI ::: Initialize visuals");
setVisible(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import net.minecraft.client.gui.GuiButtonImage;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Loader;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
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.Redirect;
import vazkii.patchouli.common.base.PatchouliConfig;

@Mixin(GuiInventory.class)
public class UTRecipeBookInvMixin
Expand All @@ -20,6 +23,11 @@ public class UTRecipeBookInvMixin
@Redirect(method = "initGui", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/inventory/GuiInventory;recipeButton:Lnet/minecraft/client/gui/GuiButtonImage;", ordinal = 0))
public void utHideRecipeBook(GuiInventory instance, GuiButtonImage value)
{
if (!UTConfigTweaks.MISC.utRecipeBookToggle || (Loader.isModLoaded("patchouli") && !PatchouliConfig.inventoryButtonBook.isEmpty()))
{
this.recipeButton = value;
return;
}
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTRecipeBookInv ::: Initialize GUI");
this.recipeButton = new GuiButtonImage(10, 0, 0, 0, 0, 0, 0, 0, new ResourceLocation("textures/gui/container/inventory.png"));
}
Expand Down

0 comments on commit 3d0823f

Please sign in to comment.