From 5a3510873b2be5968558804873a63227e4ff690c Mon Sep 17 00:00:00 2001 From: Justin Parsell Date: Sun, 24 Oct 2021 22:37:06 -0400 Subject: [PATCH] disallow disable brewing reccipe, added firestar --- .../glowstonewire/GlowstoneWireConfig.java | 3 +- .../parsell/glowstonewire/core/glowItems.java | 13 -------- .../glowstonewire/core/glowRecipes.java | 33 ++++++++++++------- .../mixin/FireworkStarRecipeAccessor.java | 20 +++++++++++ .../mixin/RecipeManagerInjector.java | 2 +- src/main/resources/glowstonewire.mixins.json | 3 +- 6 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 src/main/java/me/parsell/glowstonewire/mixin/FireworkStarRecipeAccessor.java diff --git a/src/main/java/me/parsell/glowstonewire/GlowstoneWireConfig.java b/src/main/java/me/parsell/glowstonewire/GlowstoneWireConfig.java index 5ad1867..1233c72 100644 --- a/src/main/java/me/parsell/glowstonewire/GlowstoneWireConfig.java +++ b/src/main/java/me/parsell/glowstonewire/GlowstoneWireConfig.java @@ -5,7 +5,6 @@ import me.shedaniel.autoconfig.annotation.Config; @Config(name = "GlowstoneWire") public class GlowstoneWireConfig implements ConfigData{ - public boolean addPotionRecipes = true; + public boolean addConversionRecipes = true; public boolean replaceGlowstoneDrop = true; - public boolean addConversionRecipe = true; } diff --git a/src/main/java/me/parsell/glowstonewire/core/glowItems.java b/src/main/java/me/parsell/glowstonewire/core/glowItems.java index 8263844..e6121db 100644 --- a/src/main/java/me/parsell/glowstonewire/core/glowItems.java +++ b/src/main/java/me/parsell/glowstonewire/core/glowItems.java @@ -19,18 +19,5 @@ public class glowItems { public static void init(){ Registry.register(Registry.ITEM, new Identifier(GlowstoneWire.MODID, "glowstone_dust"), GLOWSTONE_DUST); - - if (GlowstoneWire.CONFIG.addPotionRecipes) { - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.WATER, GLOWSTONE_DUST, Potions.THICK); - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.LEAPING, GLOWSTONE_DUST, Potions.STRONG_LEAPING); - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.SLOWNESS, GLOWSTONE_DUST, Potions.STRONG_SLOWNESS); - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.TURTLE_MASTER, GLOWSTONE_DUST, Potions.STRONG_TURTLE_MASTER); - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.SWIFTNESS, GLOWSTONE_DUST, Potions.STRONG_SWIFTNESS); - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.HEALING, GLOWSTONE_DUST, Potions.STRONG_HEALING); - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.HARMING, GLOWSTONE_DUST, Potions.STRONG_HARMING); - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.POISON, GLOWSTONE_DUST, Potions.STRONG_POISON); - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.REGENERATION, GLOWSTONE_DUST, Potions.STRONG_REGENERATION); - BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.STRENGTH, GLOWSTONE_DUST, Potions.STRONG_STRENGTH); - } } } diff --git a/src/main/java/me/parsell/glowstonewire/core/glowRecipes.java b/src/main/java/me/parsell/glowstonewire/core/glowRecipes.java index 0391799..ca10ab3 100644 --- a/src/main/java/me/parsell/glowstonewire/core/glowRecipes.java +++ b/src/main/java/me/parsell/glowstonewire/core/glowRecipes.java @@ -4,15 +4,33 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import me.parsell.glowstonewire.GlowstoneWire; +import me.parsell.glowstonewire.mixin.BrewingRecipeRegistryInvoker; +import me.parsell.glowstonewire.mixin.FireworkStarRecipeAccessor; +import net.minecraft.item.Items; +import net.minecraft.potion.Potions; +import net.minecraft.recipe.Ingredient; public class glowRecipes { public static JsonObject MODDED_TO_VANILLA; public static JsonObject VANILLA_TO_MODDED; public static void init(){ - // Vanilla Glowstone -> Modded Glowstone - if(GlowstoneWire.CONFIG.addConversionRecipe || true) { - // This is the json objects + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.WATER, glowItems.GLOWSTONE_DUST, Potions.THICK); + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.LEAPING, glowItems.GLOWSTONE_DUST, Potions.STRONG_LEAPING); + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.SLOWNESS, glowItems.GLOWSTONE_DUST, Potions.STRONG_SLOWNESS); + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.TURTLE_MASTER, glowItems.GLOWSTONE_DUST, Potions.STRONG_TURTLE_MASTER); + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.SWIFTNESS, glowItems.GLOWSTONE_DUST, Potions.STRONG_SWIFTNESS); + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.HEALING, glowItems.GLOWSTONE_DUST, Potions.STRONG_HEALING); + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.HARMING, glowItems.GLOWSTONE_DUST, Potions.STRONG_HARMING); + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.POISON, glowItems.GLOWSTONE_DUST, Potions.STRONG_POISON); + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.REGENERATION, glowItems.GLOWSTONE_DUST, Potions.STRONG_REGENERATION); + BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.STRENGTH, glowItems.GLOWSTONE_DUST, Potions.STRONG_STRENGTH); + + // Manually reset the glowstone compability, since i cant find a way to read and reset. + FireworkStarRecipeAccessor.setFlickerModifier(Ingredient.ofItems(Items.GLOWSTONE_DUST, glowItems.GLOWSTONE_DUST)); + + if(GlowstoneWire.CONFIG.addConversionRecipes) { + // Base JsonObjects JsonObject cIngredientVanilla = new JsonObject(); JsonObject CIngredientModded = new JsonObject(); JsonArray cIngredientsList = new JsonArray(); @@ -22,14 +40,11 @@ public class glowRecipes { // FOR VANILLA TO MODDED VANILLA_TO_MODDED = new JsonObject(); - // Header, defining what type of crafting recipe it is VANILLA_TO_MODDED.addProperty("type", "minecraft:crafting_shapeless"); - // Adding the ingredients cIngredientsList.add(cIngredientVanilla); VANILLA_TO_MODDED.add("ingredients", cIngredientsList); - // Adding the result VANILLA_TO_MODDED.add("result", CIngredientModded); @@ -38,19 +53,13 @@ public class glowRecipes { // FOR MODDED TO VANILLA MODDED_TO_VANILLA = new JsonObject(); - // Define recipe type MODDED_TO_VANILLA.addProperty("type", "minecraft:crafting_shapeless"); - // Add ingredients cIngredientsList.add(CIngredientModded); MODDED_TO_VANILLA.add("ingredients", cIngredientsList); - // Add result MODDED_TO_VANILLA.add("result", cIngredientVanilla); - - System.out.println(MODDED_TO_VANILLA.toString()); - System.out.println(VANILLA_TO_MODDED.toString()); } } } diff --git a/src/main/java/me/parsell/glowstonewire/mixin/FireworkStarRecipeAccessor.java b/src/main/java/me/parsell/glowstonewire/mixin/FireworkStarRecipeAccessor.java new file mode 100644 index 0000000..44ced3f --- /dev/null +++ b/src/main/java/me/parsell/glowstonewire/mixin/FireworkStarRecipeAccessor.java @@ -0,0 +1,20 @@ +package me.parsell.glowstonewire.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import net.minecraft.recipe.FireworkStarRecipe; +import net.minecraft.recipe.Ingredient; + +@Mixin(FireworkStarRecipe.class) +public interface FireworkStarRecipeAccessor { + @Accessor("FLICKER_MODIFIER") + public static Ingredient getFlickerModifier(){ + throw new AssertionError(); + } + + @Accessor("FLICKER_MODIFIER") + public static void setFlickerModifier(Ingredient FLICKER_MODIFIER){ + throw new AssertionError(); + } +} diff --git a/src/main/java/me/parsell/glowstonewire/mixin/RecipeManagerInjector.java b/src/main/java/me/parsell/glowstonewire/mixin/RecipeManagerInjector.java index 0ab8248..36d98cd 100644 --- a/src/main/java/me/parsell/glowstonewire/mixin/RecipeManagerInjector.java +++ b/src/main/java/me/parsell/glowstonewire/mixin/RecipeManagerInjector.java @@ -20,7 +20,7 @@ import net.minecraft.util.profiler.Profiler; public class RecipeManagerInjector { @Inject(method = "apply", at = @At("HEAD")) public void interceptApply(Map map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) { - if (GlowstoneWire.CONFIG.addConversionRecipe) { + if (GlowstoneWire.CONFIG.addConversionRecipes) { map.put(new Identifier(GlowstoneWire.MODID, "glowstone_vanilla_modded"), glowRecipes.VANILLA_TO_MODDED); map.put(new Identifier(GlowstoneWire.MODID, "glowstone_modded_vanilla"), glowRecipes.MODDED_TO_VANILLA); } diff --git a/src/main/resources/glowstonewire.mixins.json b/src/main/resources/glowstonewire.mixins.json index 408f534..786365f 100644 --- a/src/main/resources/glowstonewire.mixins.json +++ b/src/main/resources/glowstonewire.mixins.json @@ -7,7 +7,8 @@ ], "client": [ "BrewingRecipeRegistryInvoker", - "RecipeManagerInjector" + "RecipeManagerInjector", + "FireworkStarRecipeAccessor" ], "injectors": { "defaultRequire": 1