mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-04 15:41:38 +00:00
Inject Cooking Recipes
This commit is contained in:
@@ -8,6 +8,7 @@ import net.momirealms.craftengine.core.util.Key;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface RecipeManager<T> extends Reloadable, ConfigSectionParser {
|
||||
@@ -21,11 +22,15 @@ public interface RecipeManager<T> extends Reloadable, ConfigSectionParser {
|
||||
|
||||
boolean isCustomRecipe(Key key);
|
||||
|
||||
Optional<Recipe<T>> getRecipeById(Key id);
|
||||
|
||||
List<Recipe<T>> getRecipes(Key type);
|
||||
|
||||
@Nullable
|
||||
Recipe<T> getRecipe(Key type, RecipeInput input);
|
||||
|
||||
@Nullable Recipe<T> getRecipe(Key type, RecipeInput input, @Nullable Key lastRecipe);
|
||||
|
||||
CompletableFuture<Void> delayedLoad();
|
||||
|
||||
default int loadingSequence() {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class VanillaRecipeReader1_20 extends AbstractRecipeReader {
|
||||
readGroup(json),
|
||||
readShapedIngredientMap(json.getAsJsonObject("key")),
|
||||
readPattern(json),
|
||||
readResult(json.getAsJsonObject("result"))
|
||||
readCraftingResult(json.getAsJsonObject("result"))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class VanillaRecipeReader1_20 extends AbstractRecipeReader {
|
||||
readCraftingCategory(json),
|
||||
readGroup(json),
|
||||
readShapelessIngredients(json.getAsJsonArray("ingredients")),
|
||||
readResult(json.getAsJsonObject("result"))
|
||||
readCraftingResult(json.getAsJsonObject("result"))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class VanillaRecipeReader1_20 extends AbstractRecipeReader {
|
||||
return new VanillaBlastingRecipe(
|
||||
readCookingCategory(json),
|
||||
readGroup(json),
|
||||
readResult(json.getAsJsonObject("result")),
|
||||
readCookingResult(json.get("result")),
|
||||
readCookingIngredients(json.get("ingredient")),
|
||||
readExperience(json),
|
||||
readCookingTime(json)
|
||||
@@ -51,7 +51,7 @@ public class VanillaRecipeReader1_20 extends AbstractRecipeReader {
|
||||
return new VanillaSmeltingRecipe(
|
||||
readCookingCategory(json),
|
||||
readGroup(json),
|
||||
readResult(json.getAsJsonObject("result")),
|
||||
readCookingResult(json.get("result")),
|
||||
readCookingIngredients(json.get("ingredient")),
|
||||
readExperience(json),
|
||||
readCookingTime(json)
|
||||
@@ -63,7 +63,7 @@ public class VanillaRecipeReader1_20 extends AbstractRecipeReader {
|
||||
return new VanillaSmokingRecipe(
|
||||
readCookingCategory(json),
|
||||
readGroup(json),
|
||||
readResult(json.getAsJsonObject("result")),
|
||||
readCookingResult(json.get("result")),
|
||||
readCookingIngredients(json.get("ingredient")),
|
||||
readExperience(json),
|
||||
readCookingTime(json)
|
||||
@@ -75,7 +75,7 @@ public class VanillaRecipeReader1_20 extends AbstractRecipeReader {
|
||||
return new VanillaCampfireRecipe(
|
||||
readCookingCategory(json),
|
||||
readGroup(json),
|
||||
readResult(json.getAsJsonObject("result")),
|
||||
readCookingResult(json.get("result")),
|
||||
readCookingIngredients(json.get("ingredient")),
|
||||
readExperience(json),
|
||||
readCookingTime(json)
|
||||
@@ -99,7 +99,12 @@ public class VanillaRecipeReader1_20 extends AbstractRecipeReader {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected RecipeResult readResult(JsonObject object) {
|
||||
protected RecipeResult readCookingResult(JsonElement object) {
|
||||
return new RecipeResult(object.getAsString(), 1, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected RecipeResult readCraftingResult(JsonObject object) {
|
||||
String item = object.get("item").getAsString();
|
||||
int count = object.has("count") ? object.get("count").getAsInt() : 1;
|
||||
return new RecipeResult(item, count, null);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.craftengine.core.item.recipe.vanilla.impl;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.momirealms.craftengine.core.item.recipe.vanilla.RecipeResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -7,10 +8,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class VanillaRecipeReader1_20_5 extends VanillaRecipeReader1_20 {
|
||||
|
||||
@Override
|
||||
protected @NotNull RecipeResult readResult(JsonObject object) {
|
||||
protected @NotNull RecipeResult readCraftingResult(JsonObject object) {
|
||||
String item = object.get("id").getAsString();
|
||||
JsonObject components = object.has("components") ? object.getAsJsonObject("components") : null;
|
||||
int count = object.has("count") ? object.get("count").getAsInt() : 1;
|
||||
return new RecipeResult(item, count, components);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected RecipeResult readCookingResult(JsonElement object) {
|
||||
return readCraftingResult(object.getAsJsonObject());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user