Skip to content

Commit

Permalink
Extract Remove Recipe Book Patchouli compatibility to own class
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Mar 14, 2024
1 parent 342fd79 commit 3356302
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package mod.acgaming.universaltweaks.tweaks.misc.recipebook;

import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.LoaderState;

import vazkii.patchouli.common.base.PatchouliConfig;

public class UTRecipeBookPatchouliCompat
{
public static boolean patchouliInventoryButtonBook()
{
return Loader.instance().hasReachedState(LoaderState.AVAILABLE) && Loader.isModLoaded("patchouli") && !PatchouliConfig.inventoryButtonBook.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
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 mod.acgaming.universaltweaks.tweaks.misc.recipebook.UTRecipeBookPatchouliCompat;
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 @@ -23,7 +22,7 @@ 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()))
if (!UTConfigTweaks.MISC.utRecipeBookToggle || UTRecipeBookPatchouliCompat.patchouliInventoryButtonBook())
{
this.recipeButton = value;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@
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;
import mod.acgaming.universaltweaks.tweaks.misc.recipebook.UTRecipeBookPatchouliCompat;
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;
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 || (Loader.isModLoaded("patchouli") && !PatchouliConfig.inventoryButtonBook.isEmpty())) return;
if (!UTConfigTweaks.MISC.utRecipeBookToggle || UTRecipeBookPatchouliCompat.patchouliInventoryButtonBook()) 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,16 +3,15 @@
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 mod.acgaming.universaltweaks.tweaks.misc.recipebook.UTRecipeBookPatchouliCompat;
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 @@ -23,7 +22,7 @@ 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()))
if (!UTConfigTweaks.MISC.utRecipeBookToggle || UTRecipeBookPatchouliCompat.patchouliInventoryButtonBook())
{
this.recipeButton = value;
return;
Expand Down

0 comments on commit 3356302

Please sign in to comment.