Addition of dynamic recipe additions
This commit is contained in:
parent
5d10610a1d
commit
f6af1add93
|
@ -1,5 +1,9 @@
|
||||||
package me.parsell.glowstonewire.core;
|
package me.parsell.glowstonewire.core;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
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.BrewingRecipeRegistryInvoker;
|
||||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||||
|
@ -10,6 +14,7 @@ import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.potion.Potions;
|
import net.minecraft.potion.Potions;
|
||||||
|
import net.minecraft.recipe.Ingredient;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
|
@ -32,11 +37,5 @@ public class glowItems {
|
||||||
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.REGENERATION, GLOWSTONE_DUST, Potions.STRONG_REGENERATION);
|
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.REGENERATION, GLOWSTONE_DUST, Potions.STRONG_REGENERATION);
|
||||||
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.STRENGTH, GLOWSTONE_DUST, Potions.STRONG_STRENGTH);
|
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.STRENGTH, GLOWSTONE_DUST, Potions.STRONG_STRENGTH);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Vanilla Glowstone -> Modded Glowstone
|
|
||||||
// TODO: IF "convert" or "both" config is set
|
|
||||||
if(GlowstoneWire.CONFIG.addConversionRecipe) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package me.parsell.glowstonewire.core;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import me.parsell.glowstonewire.GlowstoneWire;
|
||||||
|
|
||||||
|
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
|
||||||
|
JsonObject cIngredientsKey = new JsonObject();
|
||||||
|
JsonArray cIngredientsList = new JsonArray();
|
||||||
|
|
||||||
|
// 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
|
||||||
|
cIngredientsKey.addProperty("item", "minecraft:glowstone_dust");
|
||||||
|
cIngredientsList.add(cIngredientsKey);
|
||||||
|
VANILLA_TO_MODDED.add("ingredients", cIngredientsList);
|
||||||
|
|
||||||
|
// Adding the result
|
||||||
|
cIngredientsKey.addProperty("item", "glowstonewire:glowstone_dust");
|
||||||
|
VANILLA_TO_MODDED.add("result", cIngredientsKey);
|
||||||
|
|
||||||
|
// Clearing out the old array for new
|
||||||
|
cIngredientsList = new JsonArray();
|
||||||
|
|
||||||
|
// FOR MODDED TO VANILLA
|
||||||
|
MODDED_TO_VANILLA = new JsonObject();
|
||||||
|
|
||||||
|
// Define reccipe type
|
||||||
|
MODDED_TO_VANILLA.addProperty("type", "minecraft:crafting_shapeless");
|
||||||
|
|
||||||
|
// Add ingredients
|
||||||
|
cIngredientsKey.addProperty("item", "glowstonewire:glowstone_dust");
|
||||||
|
cIngredientsList.add(cIngredientsKey);
|
||||||
|
MODDED_TO_VANILLA.add("ingredients", cIngredientsList);
|
||||||
|
|
||||||
|
// Add result
|
||||||
|
cIngredientsKey.addProperty("item", "minecraft:glowstone_dust");
|
||||||
|
MODDED_TO_VANILLA.add("result", cIngredientsKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package me.parsell.glowstonewire.mixin;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import me.parsell.glowstonewire.GlowstoneWire;
|
||||||
|
import me.parsell.glowstonewire.core.glowRecipes;
|
||||||
|
import net.minecraft.recipe.RecipeManager;
|
||||||
|
import net.minecraft.resource.ResourceManager;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.profiler.Profiler;
|
||||||
|
|
||||||
|
@Mixin(RecipeManager.class)
|
||||||
|
public class RecipeManagerInjector {
|
||||||
|
@Inject(method = "apply", at = @At("HEAD"))
|
||||||
|
public void interceptApply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) {
|
||||||
|
if (GlowstoneWire.CONFIG.addConversionRecipe) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,8 @@
|
||||||
"mixins": [
|
"mixins": [
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"BrewingRecipeRegistryInvoker"
|
"BrewingRecipeRegistryInvoker",
|
||||||
|
"RecipeManagerInjector"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
Loading…
Reference in New Issue