From 68cbb4b57ba04e1d9bab0530855c901938d66790 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 5 Mar 2019 12:45:56 +0200 Subject: [PATCH] Some quality of life adjustments --- build.gradle | 14 ++++++++++++ gradle.properties | 1 + .../com/minelittlepony/unicopia/Unicopia.java | 22 +++++++++---------- .../unicopia/inventory/gui/GuiSpellBook.java | 2 +- .../util/crafting/CraftingManager.java | 12 +++++++--- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index 734bda1e..911fee13 100644 --- a/build.gradle +++ b/build.gradle @@ -54,9 +54,23 @@ repositories { flatDir { dir 'lib' } + maven { + // location of the maven that hosts JEI files + name = "Progwml6 maven" + url = "http://dvs1.progwml6.com/files/maven" + } + maven { + // location of a maven mirror for JEI files, as a fallback + name = "ModMaven" + url = "modmaven.k-4u.nl" + } } dependencies { deobfCompile('com.minelittlepony:jumpingcastle:1.12.2.1.0.0:universal') + // compile against the JEI API but do not include it at runtime + deobfProvided "mezz.jei:jei_${project.mcVersion}:${project.jeiVersion}:api" + // at runtime, use the full JEI jar + runtime "mezz.jei:jei_${project.mcVersion}:${project.jeiVersion}" } processResources { diff --git a/gradle.properties b/gradle.properties index 7076971a..555f42dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,6 +8,7 @@ buildVersion=2 buildRevision=6 mcVersion=1.12.2 mcfVersion=14.23.2.2654 +jeiVersion=4.15.0.268 mcMappings=stable_39 refCore=mixins.unicopia.refmap.json forgeGradleVersion=2.3-SNAPSHOT diff --git a/src/main/java/com/minelittlepony/unicopia/Unicopia.java b/src/main/java/com/minelittlepony/unicopia/Unicopia.java index c29122d2..73d0aee7 100644 --- a/src/main/java/com/minelittlepony/unicopia/Unicopia.java +++ b/src/main/java/com/minelittlepony/unicopia/Unicopia.java @@ -57,7 +57,16 @@ public class Unicopia implements IGuiHandler { private static IChannel channel; - private static CraftingManager craftingManager; + private static CraftingManager craftingManager = new CraftingManager(MODID, "enchanting") { + @Override + protected void registerRecipeTypes(Map> types) { + super.registerRecipeTypes(types); + + types.put("unicopia:crafting_spell", SpellRecipe::deserialize); + + AffineIngredients.instance().load(); + } + }; public static CraftingManager getCraftingManager() { return craftingManager; @@ -106,16 +115,7 @@ public class Unicopia implements IGuiHandler { @EventHandler public void posInit(FMLPostInitializationEvent event) { - craftingManager = new CraftingManager(MODID, "enchanting") { - @Override - protected void registerRecipeTypes(Map> types) { - super.registerRecipeTypes(types); - - types.put("unicopia:crafting_spell", SpellRecipe::deserialize); - - AffineIngredients.instance().load(); - } - }; + craftingManager.load(); Pages.instance().load(); diff --git a/src/main/java/com/minelittlepony/unicopia/inventory/gui/GuiSpellBook.java b/src/main/java/com/minelittlepony/unicopia/inventory/gui/GuiSpellBook.java index 93f76aec..7d210f0a 100644 --- a/src/main/java/com/minelittlepony/unicopia/inventory/gui/GuiSpellBook.java +++ b/src/main/java/com/minelittlepony/unicopia/inventory/gui/GuiSpellBook.java @@ -27,7 +27,7 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener { private static IPage currentIPage; - private static final ResourceLocation spellBookGuiTextures = new ResourceLocation("unicopia", "textures/gui/container/book.png"); + public static final ResourceLocation spellBookGuiTextures = new ResourceLocation("unicopia", "textures/gui/container/book.png"); private IPlayer playerExtension; diff --git a/src/main/java/com/minelittlepony/unicopia/util/crafting/CraftingManager.java b/src/main/java/com/minelittlepony/unicopia/util/crafting/CraftingManager.java index 0b232a83..20a21cc4 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/crafting/CraftingManager.java +++ b/src/main/java/com/minelittlepony/unicopia/util/crafting/CraftingManager.java @@ -1,5 +1,6 @@ package com.minelittlepony.unicopia.util.crafting; +import java.util.Collection; import java.util.Map; import java.util.function.Function; @@ -40,8 +41,6 @@ public class CraftingManager { public CraftingManager(@Nonnull ResourceLocation id) { crafting_id = id; assets = new AssetWalker(id, this::handleJson); - - load(); } protected void handleJson(ResourceLocation id, JsonObject json) throws JsonParseException { @@ -87,7 +86,7 @@ public class CraftingManager { public IRecipe findMatchingRecipe(InventoryCrafting craftMatrix, World worldIn) { load(); - for (IRecipe irecipe : REGISTRY.values()) { + for (IRecipe irecipe : getRecipes()) { if (irecipe.matches(craftMatrix, worldIn)) { return irecipe; } @@ -96,6 +95,13 @@ public class CraftingManager { return null; } + public Collection getRecipes() { + if (REGISTRY.isEmpty()) { + load(); + } + return REGISTRY.values(); + } + public NonNullList getRemainingItems(InventoryCrafting craftMatrix, World worldIn) { IRecipe recipe = findMatchingRecipe(craftMatrix, worldIn);