disallow disable brewing reccipe, added firestar

This commit is contained in:
Justin Parsell 2021-10-24 22:37:06 -04:00
parent 8aa8895c52
commit 5a3510873b
6 changed files with 45 additions and 29 deletions

View File

@ -5,7 +5,6 @@ import me.shedaniel.autoconfig.annotation.Config;
@Config(name = "GlowstoneWire") @Config(name = "GlowstoneWire")
public class GlowstoneWireConfig implements ConfigData{ public class GlowstoneWireConfig implements ConfigData{
public boolean addPotionRecipes = true; public boolean addConversionRecipes = true;
public boolean replaceGlowstoneDrop = true; public boolean replaceGlowstoneDrop = true;
public boolean addConversionRecipe = true;
} }

View File

@ -19,18 +19,5 @@ public class glowItems {
public static void init(){ public static void init(){
Registry.register(Registry.ITEM, new Identifier(GlowstoneWire.MODID, "glowstone_dust"), GLOWSTONE_DUST); 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);
}
} }
} }

View File

@ -4,15 +4,33 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import me.parsell.glowstonewire.GlowstoneWire; 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 class glowRecipes {
public static JsonObject MODDED_TO_VANILLA; public static JsonObject MODDED_TO_VANILLA;
public static JsonObject VANILLA_TO_MODDED; public static JsonObject VANILLA_TO_MODDED;
public static void init(){ public static void init(){
// Vanilla Glowstone -> Modded Glowstone BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.WATER, glowItems.GLOWSTONE_DUST, Potions.THICK);
if(GlowstoneWire.CONFIG.addConversionRecipe || true) { BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.LEAPING, glowItems.GLOWSTONE_DUST, Potions.STRONG_LEAPING);
// This is the json objects 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 cIngredientVanilla = new JsonObject();
JsonObject CIngredientModded = new JsonObject(); JsonObject CIngredientModded = new JsonObject();
JsonArray cIngredientsList = new JsonArray(); JsonArray cIngredientsList = new JsonArray();
@ -22,14 +40,11 @@ public class glowRecipes {
// FOR VANILLA TO MODDED // FOR VANILLA TO MODDED
VANILLA_TO_MODDED = new JsonObject(); VANILLA_TO_MODDED = new JsonObject();
// Header, defining what type of crafting recipe it is // Header, defining what type of crafting recipe it is
VANILLA_TO_MODDED.addProperty("type", "minecraft:crafting_shapeless"); VANILLA_TO_MODDED.addProperty("type", "minecraft:crafting_shapeless");
// Adding the ingredients // Adding the ingredients
cIngredientsList.add(cIngredientVanilla); cIngredientsList.add(cIngredientVanilla);
VANILLA_TO_MODDED.add("ingredients", cIngredientsList); VANILLA_TO_MODDED.add("ingredients", cIngredientsList);
// Adding the result // Adding the result
VANILLA_TO_MODDED.add("result", CIngredientModded); VANILLA_TO_MODDED.add("result", CIngredientModded);
@ -38,19 +53,13 @@ public class glowRecipes {
// FOR MODDED TO VANILLA // FOR MODDED TO VANILLA
MODDED_TO_VANILLA = new JsonObject(); MODDED_TO_VANILLA = new JsonObject();
// Define recipe type // Define recipe type
MODDED_TO_VANILLA.addProperty("type", "minecraft:crafting_shapeless"); MODDED_TO_VANILLA.addProperty("type", "minecraft:crafting_shapeless");
// Add ingredients // Add ingredients
cIngredientsList.add(CIngredientModded); cIngredientsList.add(CIngredientModded);
MODDED_TO_VANILLA.add("ingredients", cIngredientsList); MODDED_TO_VANILLA.add("ingredients", cIngredientsList);
// Add result // Add result
MODDED_TO_VANILLA.add("result", cIngredientVanilla); MODDED_TO_VANILLA.add("result", cIngredientVanilla);
System.out.println(MODDED_TO_VANILLA.toString());
System.out.println(VANILLA_TO_MODDED.toString());
} }
} }
} }

View File

@ -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();
}
}

View File

@ -20,7 +20,7 @@ import net.minecraft.util.profiler.Profiler;
public class RecipeManagerInjector { public class RecipeManagerInjector {
@Inject(method = "apply", at = @At("HEAD")) @Inject(method = "apply", at = @At("HEAD"))
public void interceptApply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) { public void interceptApply(Map<Identifier, JsonElement> 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_vanilla_modded"), glowRecipes.VANILLA_TO_MODDED);
map.put(new Identifier(GlowstoneWire.MODID, "glowstone_modded_vanilla"), glowRecipes.MODDED_TO_VANILLA); map.put(new Identifier(GlowstoneWire.MODID, "glowstone_modded_vanilla"), glowRecipes.MODDED_TO_VANILLA);
} }

View File

@ -7,7 +7,8 @@
], ],
"client": [ "client": [
"BrewingRecipeRegistryInvoker", "BrewingRecipeRegistryInvoker",
"RecipeManagerInjector" "RecipeManagerInjector",
"FireworkStarRecipeAccessor"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1