diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/UTRecipeBookPatchouliCompat.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/UTRecipeBookPatchouliCompat.java new file mode 100644 index 00000000..27f88ce0 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/UTRecipeBookPatchouliCompat.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookCraftMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookCraftMixin.java index fbe89b39..620ca081 100644 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookCraftMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookCraftMixin.java @@ -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 @@ -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; diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookGUIMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookGUIMixin.java index c008b84a..4817e5b7 100644 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookGUIMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookGUIMixin.java @@ -3,17 +3,15 @@ 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 @@ -21,7 +19,7 @@ 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); } diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookInvMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookInvMixin.java index a34aeb60..1ec55c79 100644 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookInvMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/recipebook/mixin/UTRecipeBookInvMixin.java @@ -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 @@ -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;