Refactor recipe system.
This commit is contained in:
commit
17e8911978
41 changed files with 693 additions and 495 deletions
|
@ -9,3 +9,6 @@ indent_style = tab
|
||||||
|
|
||||||
[*.json]
|
[*.json]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
|
|
||||||
|
[*.groovy]
|
||||||
|
indent_style = tab
|
||||||
|
|
|
@ -48,7 +48,6 @@ import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.chunk.ChunkStatus;
|
import net.minecraft.world.chunk.ChunkStatus;
|
||||||
import reborncore.client.ItemStackRenderManager;
|
import reborncore.client.ItemStackRenderManager;
|
||||||
import reborncore.common.crafting.RecipeManager;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -79,17 +78,6 @@ public class RebornCoreCommands {
|
||||||
dispatcher.register(
|
dispatcher.register(
|
||||||
literal("reborncore")
|
literal("reborncore")
|
||||||
|
|
||||||
.then(
|
|
||||||
literal("recipes")
|
|
||||||
.then(literal("validate")
|
|
||||||
.requires(source -> source.hasPermissionLevel(3))
|
|
||||||
.executes(ctx -> {
|
|
||||||
RecipeManager.validateRecipes(ctx.getSource().getWorld());
|
|
||||||
return Command.SINGLE_SUCCESS;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
.then(
|
.then(
|
||||||
literal("generate")
|
literal("generate")
|
||||||
.requires(source -> source.hasPermissionLevel(3))
|
.requires(source -> source.hasPermissionLevel(3))
|
||||||
|
|
|
@ -24,67 +24,25 @@
|
||||||
|
|
||||||
package reborncore.common.crafting;
|
package reborncore.common.crafting;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.fluid.Fluid;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
import reborncore.common.fluid.FluidValue;
|
|
||||||
import reborncore.common.fluid.container.FluidInstance;
|
import reborncore.common.fluid.container.FluidInstance;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class RebornFluidRecipe extends RebornRecipe {
|
public abstract class RebornFluidRecipe extends RebornRecipe {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private FluidInstance fluidInstance = FluidInstance.EMPTY;
|
private final FluidInstance fluidInstance;
|
||||||
|
|
||||||
public RebornFluidRecipe(RebornRecipeType<?> type, Identifier name) {
|
public RebornFluidRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, @NotNull FluidInstance fluidInstance) {
|
||||||
super(type, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RebornFluidRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time) {
|
|
||||||
super(type, name, ingredients, outputs, power, time);
|
super(type, name, ingredients, outputs, power, time);
|
||||||
}
|
|
||||||
|
|
||||||
public RebornFluidRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, FluidInstance fluidInstance) {
|
|
||||||
this(type, name, ingredients, outputs, power, time);
|
|
||||||
this.fluidInstance = fluidInstance;
|
this.fluidInstance = fluidInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserialize(JsonObject jsonObject) {
|
|
||||||
super.deserialize(jsonObject);
|
|
||||||
if(jsonObject.has("tank")){
|
|
||||||
JsonObject tank = jsonObject.get("tank").getAsJsonObject();
|
|
||||||
|
|
||||||
Identifier identifier = new Identifier(JsonHelper.getString(tank, "fluid"));
|
|
||||||
Fluid fluid = Registry.FLUID.get(identifier);
|
|
||||||
|
|
||||||
FluidValue value = FluidValue.BUCKET;
|
|
||||||
if(tank.has("amount")){
|
|
||||||
value = FluidValue.parseFluidValue(tank.get("amount"));
|
|
||||||
}
|
|
||||||
|
|
||||||
fluidInstance = new FluidInstance(fluid, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(JsonObject jsonObject) {
|
|
||||||
super.serialize(jsonObject);
|
|
||||||
|
|
||||||
JsonObject tankObject = new JsonObject();
|
|
||||||
tankObject.addProperty("fluid", Registry.FLUID.getId(fluidInstance.getFluid()).toString());
|
|
||||||
tankObject.addProperty("value", fluidInstance.getAmount().getRawValue());
|
|
||||||
|
|
||||||
jsonObject.add("tank", tankObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Tank getTank(BlockEntity be);
|
public abstract Tank getTank(BlockEntity be);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,32 +24,20 @@
|
||||||
|
|
||||||
package reborncore.common.crafting;
|
package reborncore.common.crafting;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.mojang.serialization.Dynamic;
|
|
||||||
import com.mojang.serialization.JsonOps;
|
|
||||||
import io.github.cottonmc.libcd.api.CustomOutputRecipe;
|
import io.github.cottonmc.libcd.api.CustomOutputRecipe;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtOps;
|
|
||||||
import net.minecraft.network.PacketByteBuf;
|
|
||||||
import net.minecraft.recipe.Ingredient;
|
import net.minecraft.recipe.Ingredient;
|
||||||
import net.minecraft.recipe.Recipe;
|
import net.minecraft.recipe.Recipe;
|
||||||
import net.minecraft.recipe.RecipeSerializer;
|
import net.minecraft.recipe.RecipeSerializer;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||||
import reborncore.common.crafting.ingredient.DummyIngredient;
|
|
||||||
import reborncore.common.crafting.ingredient.IngredientManager;
|
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
import reborncore.common.util.DefaultedListCollector;
|
import reborncore.common.util.DefaultedListCollector;
|
||||||
import reborncore.common.util.serialization.SerializationUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -57,85 +45,23 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
|
public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
|
||||||
|
|
||||||
private final RebornRecipeType<?> type;
|
private final RebornRecipeType<?> type;
|
||||||
private final Identifier name;
|
private final Identifier name;
|
||||||
|
|
||||||
private DefaultedList<RebornIngredient> ingredients = DefaultedList.of();
|
private final List<RebornIngredient> ingredients;
|
||||||
private DefaultedList<ItemStack> outputs = DefaultedList.of();
|
private final List<ItemStack> outputs;
|
||||||
protected int power;
|
protected final int power;
|
||||||
protected int time;
|
protected final int time;
|
||||||
|
|
||||||
protected boolean dummy = false;
|
public RebornRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time) {
|
||||||
|
|
||||||
public RebornRecipe(RebornRecipeType<?> type, Identifier name) {
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
|
||||||
|
|
||||||
public RebornRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time) {
|
|
||||||
this(type, name);
|
|
||||||
this.ingredients = ingredients;
|
this.ingredients = ingredients;
|
||||||
this.outputs = outputs;
|
this.outputs = outputs;
|
||||||
this.power = power;
|
this.power = power;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deserialize(JsonObject jsonObject) {
|
|
||||||
if (jsonObject.has("dummy")) {
|
|
||||||
makeDummy();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Crash if the recipe has all ready been deserialized
|
|
||||||
Validate.isTrue(ingredients.isEmpty());
|
|
||||||
|
|
||||||
power = JsonHelper.getInt(jsonObject, "power");
|
|
||||||
time = JsonHelper.getInt(jsonObject, "time");
|
|
||||||
|
|
||||||
ingredients = SerializationUtil.stream(JsonHelper.getArray(jsonObject, "ingredients"))
|
|
||||||
.map(IngredientManager::deserialize)
|
|
||||||
.collect(DefaultedListCollector.toList());
|
|
||||||
|
|
||||||
JsonArray resultsJson = JsonHelper.getArray(jsonObject, "results");
|
|
||||||
outputs = RecipeUtils.deserializeItems(resultsJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void serialize(JsonObject jsonObject) {
|
|
||||||
if (isDummy()) {
|
|
||||||
jsonObject.addProperty("dummy", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
jsonObject.addProperty("power", power);
|
|
||||||
jsonObject.addProperty("time", time);
|
|
||||||
|
|
||||||
JsonArray ingredientsArray = new JsonArray();
|
|
||||||
getRebornIngredients().stream().map(RebornIngredient::witeToJson).forEach(ingredientsArray::add);
|
|
||||||
jsonObject.add("ingredients", ingredientsArray);
|
|
||||||
|
|
||||||
JsonArray resultsArray = new JsonArray();
|
|
||||||
for (ItemStack stack : outputs) {
|
|
||||||
JsonObject stackObject = new JsonObject();
|
|
||||||
stackObject.addProperty("item", Registry.ITEM.getId(stack.getItem()).toString());
|
|
||||||
if (stack.getCount() > 1) {
|
|
||||||
stackObject.addProperty("count", stack.getCount());
|
|
||||||
}
|
|
||||||
if (stack.hasNbt()) {
|
|
||||||
stackObject.add("nbt", Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, stack.getNbt()));
|
|
||||||
}
|
|
||||||
resultsArray.add(stackObject);
|
|
||||||
}
|
|
||||||
jsonObject.add("results", resultsArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void serialize(PacketByteBuf byteBuf) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deserialize(PacketByteBuf byteBuf) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier getId() {
|
public Identifier getId() {
|
||||||
return name;
|
return name;
|
||||||
|
@ -162,7 +88,7 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
|
||||||
return ingredients.stream().map(RebornIngredient::getPreview).collect(DefaultedListCollector.toList());
|
return ingredients.stream().map(RebornIngredient::getPreview).collect(DefaultedListCollector.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultedList<RebornIngredient> getRebornIngredients() {
|
public List<RebornIngredient> getRebornIngredients() {
|
||||||
return ingredients;
|
return ingredients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,9 +109,6 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
|
||||||
* @return if true the recipe will craft, if false it will not
|
* @return if true the recipe will craft, if false it will not
|
||||||
*/
|
*/
|
||||||
public boolean canCraft(BlockEntity blockEntity) {
|
public boolean canCraft(BlockEntity blockEntity) {
|
||||||
if (isDummy()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (blockEntity instanceof IRecipeCrafterProvider) {
|
if (blockEntity instanceof IRecipeCrafterProvider) {
|
||||||
return ((IRecipeCrafterProvider) blockEntity).canCraft(this);
|
return ((IRecipeCrafterProvider) blockEntity).canCraft(this);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +147,7 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getOutput() {
|
public ItemStack getOutput() {
|
||||||
if (isDummy() || outputs.isEmpty()) {
|
if (outputs.isEmpty()) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
return outputs.get(0);
|
return outputs.get(0);
|
||||||
|
@ -241,15 +164,6 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDummy() {
|
|
||||||
return dummy;
|
|
||||||
}
|
|
||||||
|
|
||||||
void makeDummy() {
|
|
||||||
this.ingredients.add(new DummyIngredient());
|
|
||||||
this.dummy = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Item> getOutputItems() {
|
public Collection<Item> getOutputItems() {
|
||||||
List<Item> items = new ArrayList<>();
|
List<Item> items = new ArrayList<>();
|
||||||
|
|
|
@ -26,21 +26,19 @@ package reborncore.common.crafting;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.minecraft.network.PacketByteBuf;
|
import net.minecraft.network.PacketByteBuf;
|
||||||
import net.minecraft.recipe.Recipe;
|
|
||||||
import net.minecraft.recipe.RecipeSerializer;
|
import net.minecraft.recipe.RecipeSerializer;
|
||||||
import net.minecraft.recipe.RecipeType;
|
import net.minecraft.recipe.RecipeType;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
import net.minecraft.util.JsonHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.RebornCore;
|
import reborncore.common.crafting.serde.RecipeSerde;
|
||||||
import reborncore.common.util.serialization.SerializationUtil;
|
import reborncore.common.util.serialization.SerializationUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
|
|
||||||
public record RebornRecipeType<R extends RebornRecipe>(
|
public record RebornRecipeType<R extends RebornRecipe>(
|
||||||
BiFunction<RebornRecipeType<R>, Identifier, R> recipeFunction,
|
RecipeSerde<R> recipeSerde,
|
||||||
Identifier name) implements RecipeType, RecipeSerializer {
|
Identifier name) implements RecipeType<R>, RecipeSerializer<R> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R read(Identifier recipeId, JsonObject json) {
|
public R read(Identifier recipeId, JsonObject json) {
|
||||||
|
@ -49,53 +47,29 @@ public record RebornRecipeType<R extends RebornRecipe>(
|
||||||
throw new RuntimeException("RebornRecipe type not supported!");
|
throw new RuntimeException("RebornRecipe type not supported!");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return recipeSerde.fromJson(json, this, recipeId);
|
||||||
R recipe = newRecipe(recipeId);
|
|
||||||
|
|
||||||
recipe.deserialize(json);
|
|
||||||
return recipe;
|
|
||||||
} catch (Throwable t) {
|
|
||||||
RebornCore.LOGGER.error("Failed to read recipe: " + recipeId, t);
|
|
||||||
// Make a new recipe - don't reuse the existing recipe object because it might be in an invalid state if an
|
|
||||||
// exception was thrown in the middle of its deserialization.
|
|
||||||
R recipe = newRecipe(recipeId);
|
|
||||||
recipe.makeDummy();
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonObject toJson(R recipe) {
|
private JsonObject toJson(R recipe) {
|
||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
jsonObject.addProperty("type", name.toString());
|
jsonObject.addProperty("type", name.toString());
|
||||||
|
|
||||||
recipe.serialize(jsonObject);
|
recipeSerde.toJson(recipe, jsonObject);
|
||||||
|
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public R fromJson(Identifier recipeType, JsonObject json) {
|
|
||||||
return read(recipeType, json);
|
|
||||||
}
|
|
||||||
|
|
||||||
R newRecipe(Identifier recipeId) {
|
|
||||||
return recipeFunction.apply(this, recipeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R read(Identifier recipeId, PacketByteBuf buffer) {
|
public R read(Identifier recipeId, PacketByteBuf buffer) {
|
||||||
String input = buffer.readString(buffer.readInt());
|
String jsonSize = buffer.readString(buffer.readInt());
|
||||||
R r = read(recipeId, SerializationUtil.GSON_FLAT.fromJson(input, JsonObject.class));
|
return read(recipeId, SerializationUtil.GSON_FLAT.fromJson(jsonSize, JsonObject.class));
|
||||||
r.deserialize(buffer);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(PacketByteBuf buffer, Recipe recipe) {
|
public void write(PacketByteBuf buffer, R recipe) {
|
||||||
JsonObject jsonObject = toJson((R) recipe);
|
String output = SerializationUtil.GSON_FLAT.toJson(toJson(recipe));
|
||||||
String output = SerializationUtil.GSON_FLAT.toJson(jsonObject);
|
|
||||||
buffer.writeInt(output.length());
|
buffer.writeInt(output.length());
|
||||||
buffer.writeString(output);
|
buffer.writeString(output);
|
||||||
((R) recipe).serialize(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<R> getRecipes(World world) {
|
public List<R> getRecipes(World world) {
|
||||||
|
|
|
@ -24,32 +24,30 @@
|
||||||
|
|
||||||
package reborncore.common.crafting;
|
package reborncore.common.crafting;
|
||||||
|
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.network.PacketByteBuf;
|
|
||||||
import net.minecraft.recipe.Recipe;
|
|
||||||
import net.minecraft.recipe.RecipeSerializer;
|
import net.minecraft.recipe.RecipeSerializer;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.World;
|
import reborncore.common.crafting.serde.RebornRecipeSerde;
|
||||||
import org.apache.commons.lang3.Validate;
|
import reborncore.common.crafting.serde.RecipeSerde;
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class RecipeManager {
|
public class RecipeManager {
|
||||||
|
|
||||||
private static final Map<Identifier, RebornRecipeType<?>> recipeTypes = new HashMap<>();
|
private static final Map<Identifier, RebornRecipeType<?>> recipeTypes = new HashMap<>();
|
||||||
|
|
||||||
public static <R extends RebornRecipe> RebornRecipeType<R> newRecipeType(BiFunction<RebornRecipeType<R>, Identifier, R> recipeFunction, Identifier name) {
|
public static RebornRecipeType<reborncore.common.crafting.RebornRecipe> newRecipeType(Identifier name) {
|
||||||
|
return newRecipeType(RebornRecipeSerde.BASIC, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <R extends RebornRecipe> RebornRecipeType<R> newRecipeType(RecipeSerde<R> recipeSerde, Identifier name) {
|
||||||
if (recipeTypes.containsKey(name)) {
|
if (recipeTypes.containsKey(name)) {
|
||||||
throw new RuntimeException("RebornRecipe type with this name already registered");
|
throw new RuntimeException("RebornRecipe type with this name already registered");
|
||||||
}
|
}
|
||||||
RebornRecipeType<R> type = new RebornRecipeType<>(recipeFunction, name);
|
RebornRecipeType<R> type = new RebornRecipeType<>(recipeSerde, name);
|
||||||
recipeTypes.put(name, type);
|
recipeTypes.put(name, type);
|
||||||
|
|
||||||
Registry.register(Registry.RECIPE_SERIALIZER, name, (RecipeSerializer<?>) type);
|
Registry.register(Registry.RECIPE_SERIALIZER, name, (RecipeSerializer<?>) type);
|
||||||
|
@ -67,64 +65,4 @@ public class RecipeManager {
|
||||||
public static List<RebornRecipeType> getRecipeTypes(String namespace) {
|
public static List<RebornRecipeType> getRecipeTypes(String namespace) {
|
||||||
return recipeTypes.values().stream().filter(rebornRecipeType -> rebornRecipeType.name().getNamespace().equals(namespace)).collect(Collectors.toList());
|
return recipeTypes.values().stream().filter(rebornRecipeType -> rebornRecipeType.name().getNamespace().equals(namespace)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validateRecipes(World world) {
|
|
||||||
//recipeTypes.forEach((key, value) -> validate(value, world));
|
|
||||||
|
|
||||||
System.out.println("Validating recipes");
|
|
||||||
world.getRecipeManager().keys().forEach(identifier -> {
|
|
||||||
try {
|
|
||||||
Recipe recipe = world.getRecipeManager().get(identifier).get();
|
|
||||||
RecipeSerializer recipeSerializer = recipe.getSerializer();
|
|
||||||
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
|
|
||||||
recipeSerializer.write(buf, recipe);
|
|
||||||
|
|
||||||
Recipe readback = recipeSerializer.read(identifier, buf);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Failed to read " + identifier, e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
System.out.println("Done");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <R extends RebornRecipe> void validate(RebornRecipeType<R> rebornRecipeType, World world) {
|
|
||||||
List<R> recipes = rebornRecipeType.getRecipes(world);
|
|
||||||
|
|
||||||
for (RebornRecipe recipe1 : recipes) {
|
|
||||||
for (RebornRecipe recipe2 : recipes) {
|
|
||||||
if (recipe1 == recipe2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Validate.isTrue(recipe1.getRebornIngredients().size() > 0, recipe1.getId() + " has no inputs");
|
|
||||||
Validate.isTrue(recipe2.getRebornIngredients().size() > 0, recipe2.getId() + " has no inputs");
|
|
||||||
Validate.isTrue(recipe1.getOutputs().size() > 0, recipe1.getId() + " has no outputs");
|
|
||||||
Validate.isTrue(recipe2.getOutputs().size() > 0, recipe2.getId() + " has no outputs");
|
|
||||||
|
|
||||||
boolean hasAll = true;
|
|
||||||
|
|
||||||
for (RebornIngredient recipe1Input : recipe1.getRebornIngredients()) {
|
|
||||||
boolean matches = false;
|
|
||||||
for (ItemStack testStack : recipe1Input.getPreviewStacks()) {
|
|
||||||
for (RebornIngredient recipe2Input : recipe2.getRebornIngredients()) {
|
|
||||||
if (recipe2Input.test(testStack)) {
|
|
||||||
matches = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!matches) {
|
|
||||||
hasAll = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasAll) {
|
|
||||||
System.out.println(recipe1.getId() + " conflicts with " + recipe2.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,13 @@ import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.mojang.serialization.Dynamic;
|
import com.mojang.serialization.Dynamic;
|
||||||
import com.mojang.serialization.JsonOps;
|
import com.mojang.serialization.JsonOps;
|
||||||
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.NbtOps;
|
import net.minecraft.nbt.NbtOps;
|
||||||
|
import net.minecraft.recipe.Recipe;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
import net.minecraft.util.JsonHelper;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
|
@ -42,15 +44,17 @@ import reborncore.common.util.DefaultedListCollector;
|
||||||
import reborncore.common.util.serialization.SerializationUtil;
|
import reborncore.common.util.serialization.SerializationUtil;
|
||||||
import reborncore.mixin.common.AccessorRecipeManager;
|
import reborncore.mixin.common.AccessorRecipeManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RecipeUtils {
|
public class RecipeUtils {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T extends RebornRecipe> List<T> getRecipes(World world, RebornRecipeType<?> type) {
|
public static <T extends RebornRecipe> List<T> getRecipes(World world, RebornRecipeType<T> type) {
|
||||||
AccessorRecipeManager accessorRecipeManager = (AccessorRecipeManager) world.getRecipeManager();
|
final AccessorRecipeManager accessorRecipeManager = (AccessorRecipeManager) world.getRecipeManager();
|
||||||
|
final Collection<Recipe<Inventory>> recipes = accessorRecipeManager.getAll(type).values();
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return new ArrayList<>(accessorRecipeManager.getAll(type).values());
|
return Collections.unmodifiableList((List<T>) (Object) recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DefaultedList<ItemStack> deserializeItems(JsonElement jsonObject) {
|
public static DefaultedList<ItemStack> deserializeItems(JsonElement jsonObject) {
|
||||||
|
|
|
@ -25,16 +25,18 @@
|
||||||
package reborncore.common.crafting.ingredient;
|
package reborncore.common.crafting.ingredient;
|
||||||
|
|
||||||
import net.minecraft.tag.Tag;
|
import net.minecraft.tag.Tag;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SimpleTag<T> implements Tag<T> {
|
public class SimpleTag<T> implements Tag.Identified<T> {
|
||||||
|
|
||||||
private final List<T> entries;
|
private final List<T> entries;
|
||||||
|
private final Identifier identifier;
|
||||||
|
|
||||||
public SimpleTag(List<T> entries) {
|
public SimpleTag(List<T> entries, Identifier identifier) {
|
||||||
this.entries = entries;
|
this.entries = entries;
|
||||||
|
this.identifier = identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,4 +48,9 @@ public class SimpleTag<T> implements Tag<T> {
|
||||||
public List<T> values() {
|
public List<T> values() {
|
||||||
return Collections.unmodifiableList(entries);
|
return Collections.unmodifiableList(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier getId() {
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
import net.minecraft.util.JsonHelper;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -49,22 +50,23 @@ public class StackIngredient extends RebornIngredient {
|
||||||
private final List<ItemStack> stacks;
|
private final List<ItemStack> stacks;
|
||||||
|
|
||||||
private final Optional<Integer> count;
|
private final Optional<Integer> count;
|
||||||
private final Optional<NbtCompound> tag;
|
private final Optional<NbtCompound> nbt;
|
||||||
private final boolean requireEmptyTag;
|
private final boolean requireEmptyNbt;
|
||||||
|
|
||||||
public StackIngredient(List<ItemStack> stacks, Optional<Integer> count, Optional<NbtCompound> tag, boolean requireEmptyTag) {
|
public StackIngredient(List<ItemStack> stacks, Optional<Integer> count, Optional<NbtCompound> nbt, boolean requireEmptyNbt) {
|
||||||
super(IngredientManager.STACK_RECIPE_TYPE);
|
super(IngredientManager.STACK_RECIPE_TYPE);
|
||||||
this.stacks = stacks;
|
this.stacks = stacks;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
this.tag = tag;
|
this.nbt = nbt;
|
||||||
this.requireEmptyTag = requireEmptyTag;
|
this.requireEmptyNbt = requireEmptyNbt;
|
||||||
Validate.isTrue(stacks.size() == 1, "stack size must 1");
|
Validate.isTrue(stacks.size() == 1, "stack size must 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StackIngredient(List<ItemStack> stacks, int count, @Nullable NbtCompound nbt, boolean requireEmptyNbt) {
|
||||||
|
this(stacks, count > 1 ? Optional.of(count) : Optional.empty(), Optional.ofNullable(nbt), requireEmptyNbt);
|
||||||
|
}
|
||||||
|
|
||||||
public static RebornIngredient deserialize(JsonObject json) {
|
public static RebornIngredient deserialize(JsonObject json) {
|
||||||
if (!json.has("item")) {
|
|
||||||
System.out.println("nope");
|
|
||||||
}
|
|
||||||
Identifier identifier = new Identifier(JsonHelper.getString(json, "item"));
|
Identifier identifier = new Identifier(JsonHelper.getString(json, "item"));
|
||||||
Item item = Registry.ITEM.getOrEmpty(identifier).orElseThrow(() -> new JsonSyntaxException("Unknown item '" + identifier + "'"));
|
Item item = Registry.ITEM.getOrEmpty(identifier).orElseThrow(() -> new JsonSyntaxException("Unknown item '" + identifier + "'"));
|
||||||
|
|
||||||
|
@ -101,7 +103,7 @@ public class StackIngredient extends RebornIngredient {
|
||||||
if (count.isPresent() && count.get() > itemStack.getCount()) {
|
if (count.isPresent() && count.get() > itemStack.getCount()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (tag.isPresent()) {
|
if (nbt.isPresent()) {
|
||||||
if (!itemStack.hasNbt()) {
|
if (!itemStack.hasNbt()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -113,11 +115,11 @@ public class StackIngredient extends RebornIngredient {
|
||||||
JsonElement jsonElement = Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, compoundTag);
|
JsonElement jsonElement = Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, compoundTag);
|
||||||
compoundTag = (NbtCompound) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, jsonElement);
|
compoundTag = (NbtCompound) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, jsonElement);
|
||||||
|
|
||||||
if (!tag.get().equals(compoundTag)) {
|
if (!nbt.get().equals(compoundTag)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !requireEmptyTag || !itemStack.hasNbt();
|
return !requireEmptyNbt || !itemStack.hasNbt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -131,7 +133,7 @@ public class StackIngredient extends RebornIngredient {
|
||||||
stacks.stream()
|
stacks.stream()
|
||||||
.map(ItemStack::copy)
|
.map(ItemStack::copy)
|
||||||
.peek(itemStack -> itemStack.setCount(count.orElse(1)))
|
.peek(itemStack -> itemStack.setCount(count.orElse(1)))
|
||||||
.peek(itemStack -> itemStack.setNbt(tag.orElse(null)))
|
.peek(itemStack -> itemStack.setNbt(nbt.orElse(null)))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,10 +144,10 @@ public class StackIngredient extends RebornIngredient {
|
||||||
jsonObject.addProperty("item", Registry.ITEM.getId(stacks.get(0).getItem()).toString());
|
jsonObject.addProperty("item", Registry.ITEM.getId(stacks.get(0).getItem()).toString());
|
||||||
count.ifPresent(integer -> jsonObject.addProperty("count", integer));
|
count.ifPresent(integer -> jsonObject.addProperty("count", integer));
|
||||||
|
|
||||||
if (requireEmptyTag) {
|
if (requireEmptyNbt) {
|
||||||
jsonObject.addProperty("nbt", "empty");
|
jsonObject.addProperty("nbt", "empty");
|
||||||
} else {
|
} else {
|
||||||
tag.ifPresent(compoundTag -> jsonObject.add("nbt", Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, compoundTag)));
|
nbt.ifPresent(compoundTag -> jsonObject.add("nbt", Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, compoundTag)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
|
|
|
@ -26,6 +26,7 @@ package reborncore.common.crafting.ingredient;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
import net.fabricmc.fabric.api.tag.TagFactory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
@ -43,18 +44,19 @@ import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class TagIngredient extends RebornIngredient {
|
public class TagIngredient extends RebornIngredient {
|
||||||
|
private final Tag.Identified<Item> tag;
|
||||||
private final Identifier tagIdentifier;
|
|
||||||
private final Tag<Item> tag;
|
|
||||||
private final Optional<Integer> count;
|
private final Optional<Integer> count;
|
||||||
|
|
||||||
public TagIngredient(Identifier tagIdentifier, Tag<Item> tag, Optional<Integer> count) {
|
public TagIngredient(Tag.Identified<Item> tag, Optional<Integer> count) {
|
||||||
super(IngredientManager.TAG_RECIPE_TYPE);
|
super(IngredientManager.TAG_RECIPE_TYPE);
|
||||||
this.tagIdentifier = tagIdentifier;
|
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TagIngredient(Tag.Identified<Item> tag, int count) {
|
||||||
|
this(tag, count > 1 ? Optional.of(count) : Optional.empty());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(ItemStack itemStack) {
|
public boolean test(ItemStack itemStack) {
|
||||||
if (count.isPresent() && count.get() > itemStack.getCount()) {
|
if (count.isPresent() && count.get() > itemStack.getCount()) {
|
||||||
|
@ -88,16 +90,17 @@ public class TagIngredient extends RebornIngredient {
|
||||||
Validate.isTrue(item != Items.AIR, "item cannot be air");
|
Validate.isTrue(item != Items.AIR, "item cannot be air");
|
||||||
items.add(item);
|
items.add(item);
|
||||||
}
|
}
|
||||||
return new TagIngredient(tagIdent, new SimpleTag<>(items), count);
|
return new TagIngredient(new SimpleTag<>(items, tagIdent), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier identifier = new Identifier(JsonHelper.getString(json, "tag"));
|
Identifier identifier = new Identifier(JsonHelper.getString(json, "tag"));
|
||||||
|
|
||||||
Tag<Item> tag = ServerTagManagerHolder.getTagManager().getOrCreateTagGroup(Registry.ITEM_KEY).getTag(identifier);
|
Tag.Identified<Item> tag = TagFactory.of(() -> ServerTagManagerHolder.getTagManager().getOrCreateTagGroup(Registry.ITEM_KEY)).create(identifier);
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
throw new JsonSyntaxException("Unknown item tag '" + identifier + "'");
|
throw new JsonSyntaxException("Unknown item tag '" + identifier + "'");
|
||||||
}
|
}
|
||||||
return new TagIngredient(identifier, tag, count);
|
|
||||||
|
return new TagIngredient(tag, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,7 +116,7 @@ public class TagIngredient extends RebornIngredient {
|
||||||
}
|
}
|
||||||
|
|
||||||
count.ifPresent(integer -> jsonObject.addProperty("count", integer));
|
count.ifPresent(integer -> jsonObject.addProperty("count", integer));
|
||||||
jsonObject.addProperty("tag_identifier", tagIdentifier.toString());
|
jsonObject.addProperty("tag_identifier", tag.getId().toString());
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TechReborn
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package reborncore.common.crafting.serde;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.mojang.serialization.Dynamic;
|
||||||
|
import com.mojang.serialization.JsonOps;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NbtOps;
|
||||||
|
import net.minecraft.util.JsonHelper;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RecipeUtils;
|
||||||
|
import reborncore.common.crafting.ingredient.IngredientManager;
|
||||||
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
import reborncore.common.util.DefaultedListCollector;
|
||||||
|
import reborncore.common.util.serialization.SerializationUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class AbstractRecipeSerde<R extends RebornRecipe> implements RecipeSerde<R> {
|
||||||
|
protected int getPower(JsonObject jsonObject) {
|
||||||
|
return JsonHelper.getInt(jsonObject, "power");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getTime(JsonObject jsonObject) {
|
||||||
|
return JsonHelper.getInt(jsonObject, "time");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<RebornIngredient> getIngredients(JsonObject jsonObject) {
|
||||||
|
return SerializationUtil.stream(JsonHelper.getArray(jsonObject, "ingredients"))
|
||||||
|
.map(IngredientManager::deserialize)
|
||||||
|
.collect(DefaultedListCollector.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<ItemStack> getOutputs(JsonObject jsonObject) {
|
||||||
|
final JsonArray resultsJson = JsonHelper.getArray(jsonObject, "results");
|
||||||
|
return RecipeUtils.deserializeItems(resultsJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeIngredients(R recipe, JsonObject jsonObject) {
|
||||||
|
final JsonArray ingredientsArray = new JsonArray();
|
||||||
|
recipe.getRebornIngredients().stream().map(RebornIngredient::witeToJson).forEach(ingredientsArray::add);
|
||||||
|
jsonObject.add("ingredients", ingredientsArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeOutputs(R recipe, JsonObject jsonObject) {
|
||||||
|
final JsonArray resultsArray = new JsonArray();
|
||||||
|
|
||||||
|
for (ItemStack stack : recipe.getOutputs()) {
|
||||||
|
final JsonObject stackObject = new JsonObject();
|
||||||
|
stackObject.addProperty("item", Registry.ITEM.getId(stack.getItem()).toString());
|
||||||
|
|
||||||
|
if (stack.getCount() > 1) {
|
||||||
|
stackObject.addProperty("count", stack.getCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.hasNbt()) {
|
||||||
|
stackObject.add("nbt", Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, stack.getNbt()));
|
||||||
|
}
|
||||||
|
resultsArray.add(stackObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonObject.add("results", resultsArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writePower(R recipe, JsonObject jsonObject) {
|
||||||
|
jsonObject.addProperty("power", recipe.getPower());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeTime(R recipe, JsonObject jsonObject) {
|
||||||
|
jsonObject.addProperty("time", recipe.getTime());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TechReborn
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package reborncore.common.crafting.serde;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import net.minecraft.fluid.Fluid;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.JsonHelper;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import reborncore.common.crafting.RebornFluidRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
|
import reborncore.common.fluid.container.FluidInstance;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class RebornFluidRecipeSerde<R extends RebornFluidRecipe> extends RebornRecipeSerde<R> {
|
||||||
|
protected abstract R fromJson(JsonObject jsonObject, RebornRecipeType<R> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, @NotNull FluidInstance fluidInstance);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected final R fromJson(JsonObject jsonObject, RebornRecipeType<R> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time) {
|
||||||
|
final JsonObject tank = JsonHelper.getObject(jsonObject, "tank");
|
||||||
|
final Identifier identifier = new Identifier(JsonHelper.getString(tank, "fluid"));
|
||||||
|
final Fluid fluid = Registry.FLUID.get(identifier);
|
||||||
|
|
||||||
|
FluidValue value = FluidValue.BUCKET;
|
||||||
|
if(tank.has("amount")){
|
||||||
|
value = FluidValue.parseFluidValue(tank.get("amount"));
|
||||||
|
}
|
||||||
|
|
||||||
|
FluidInstance fluidInstance = new FluidInstance(fluid, value);
|
||||||
|
|
||||||
|
return fromJson(jsonObject, type, name, ingredients, outputs, power, time, fluidInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectJsonData(R recipe, JsonObject jsonObject) {
|
||||||
|
final JsonObject tankObject = new JsonObject();
|
||||||
|
tankObject.addProperty("fluid", Registry.FLUID.getId(recipe.getFluidInstance().getFluid()).toString());
|
||||||
|
tankObject.addProperty("value", recipe.getFluidInstance().getAmount().getRawValue());
|
||||||
|
|
||||||
|
jsonObject.add("tank", tankObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <R extends RebornFluidRecipe> RebornFluidRecipeSerde<R> create(SimpleFluidRecipeFactory<R> factory) {
|
||||||
|
return new RebornFluidRecipeSerde<>() {
|
||||||
|
@Override
|
||||||
|
protected R fromJson(JsonObject jsonObject, RebornRecipeType<R> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, @NotNull FluidInstance fluidInstance) {
|
||||||
|
return factory.create(type, name, ingredients, outputs, power, time, fluidInstance);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface SimpleFluidRecipeFactory<R extends RebornFluidRecipe> {
|
||||||
|
R create(RebornRecipeType<R> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, @NotNull FluidInstance fluidInstance);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TechReborn
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package reborncore.common.crafting.serde;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class RebornRecipeSerde<R extends RebornRecipe> extends AbstractRecipeSerde<R> {
|
||||||
|
public static final RebornRecipeSerde<RebornRecipe> BASIC = create(RebornRecipe::new);
|
||||||
|
|
||||||
|
protected abstract R fromJson(JsonObject jsonObject, RebornRecipeType<R> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final R fromJson(JsonObject jsonObject, RebornRecipeType<R> type, Identifier name) {
|
||||||
|
final int power = getPower(jsonObject);
|
||||||
|
final int time = getTime(jsonObject);
|
||||||
|
final List<RebornIngredient> ingredients = getIngredients(jsonObject);
|
||||||
|
final List<ItemStack> outputs = getOutputs(jsonObject);
|
||||||
|
|
||||||
|
return fromJson(jsonObject, type, name, ingredients, outputs, power, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void collectJsonData(R recipe, JsonObject jsonObject);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void toJson(R recipe, JsonObject jsonObject) {
|
||||||
|
writePower(recipe, jsonObject);
|
||||||
|
writeTime(recipe, jsonObject);
|
||||||
|
writeIngredients(recipe, jsonObject);
|
||||||
|
writeOutputs(recipe, jsonObject);
|
||||||
|
|
||||||
|
collectJsonData(recipe, jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <R extends RebornRecipe> RebornRecipeSerde<R> create(SimpleRecipeFactory<R> factory) {
|
||||||
|
return new RebornRecipeSerde<R>() {
|
||||||
|
@Override
|
||||||
|
protected R fromJson(JsonObject jsonObject, RebornRecipeType<R> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time) {
|
||||||
|
return factory.create(type, name, ingredients, outputs, power, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void collectJsonData(R recipe, JsonObject jsonObject) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface SimpleRecipeFactory<R extends RebornRecipe> {
|
||||||
|
R create(RebornRecipeType<R> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time);
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,15 +22,15 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package techreborn.datagen.tags
|
package reborncore.common.crafting.serde;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.tag.TagFactory
|
import com.google.gson.JsonObject;
|
||||||
import net.minecraft.item.Item
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.tag.Tag
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import net.minecraft.util.Identifier
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
|
||||||
trait CommonTagsTrait {
|
public interface RecipeSerde<R extends RebornRecipe> {
|
||||||
static Tag.Identified<Item> cItem(String path) {
|
R fromJson(JsonObject jsonObject, RebornRecipeType<R> type, Identifier name);
|
||||||
return TagFactory.ITEM.create(new Identifier("c", path))
|
|
||||||
}
|
void toJson(R recipe, JsonObject jsonObject);
|
||||||
}
|
}
|
|
@ -30,52 +30,52 @@ import net.minecraft.item.ItemConvertible
|
||||||
import net.minecraft.item.Items
|
import net.minecraft.item.Items
|
||||||
import net.minecraft.recipe.CookingRecipeSerializer
|
import net.minecraft.recipe.CookingRecipeSerializer
|
||||||
import net.minecraft.recipe.RecipeSerializer
|
import net.minecraft.recipe.RecipeSerializer
|
||||||
import techreborn.datagen.tags.CommonTagsTrait
|
import techreborn.datagen.tags.CommonTags
|
||||||
import techreborn.init.TRContent
|
import techreborn.init.TRContent
|
||||||
|
|
||||||
class SmeltingRecipesProvider extends TechRebornRecipesProvider implements CommonTagsTrait {
|
class SmeltingRecipesProvider extends TechRebornRecipesProvider {
|
||||||
SmeltingRecipesProvider(FabricDataGenerator dataGenerator) {
|
SmeltingRecipesProvider(FabricDataGenerator dataGenerator) {
|
||||||
super(dataGenerator)
|
super(dataGenerator)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void generateRecipes() {
|
void generateRecipes() {
|
||||||
// Add smelting and blasting recipes.
|
// Add smelting and blasting recipes.
|
||||||
[
|
[
|
||||||
(TRContent.Ingots.MIXED_METAL): TRContent.Ingots.ADVANCED_ALLOY,
|
(TRContent.Ingots.MIXED_METAL) : TRContent.Ingots.ADVANCED_ALLOY,
|
||||||
(cItem("brass_dusts")): TRContent.Ingots.BRASS,
|
(CommonTags.Items.brassDusts) : TRContent.Ingots.BRASS,
|
||||||
(TRContent.Dusts.BRONZE): TRContent.Ingots.BRONZE,
|
(TRContent.Dusts.BRONZE) : TRContent.Ingots.BRONZE,
|
||||||
(cItem("electrum_dusts")): TRContent.Ingots.ELECTRUM,
|
(CommonTags.Items.electrumDusts): TRContent.Ingots.ELECTRUM,
|
||||||
(TRContent.Dusts.INVAR): TRContent.Ingots.INVAR,
|
(TRContent.Dusts.INVAR) : TRContent.Ingots.INVAR,
|
||||||
(cItem("lead_ores")): TRContent.Ingots.LEAD,
|
(CommonTags.Items.leadOres) : TRContent.Ingots.LEAD,
|
||||||
(cItem("raw_lead_ores")): TRContent.Ingots.LEAD,
|
(CommonTags.Items.rawLeadOres) : TRContent.Ingots.LEAD,
|
||||||
(TRContent.Dusts.NICKEL): TRContent.Ingots.NICKEL,
|
(TRContent.Dusts.NICKEL) : TRContent.Ingots.NICKEL,
|
||||||
(cItem("sheldonite_ores")): TRContent.Ingots.PLATINUM,
|
(CommonTags.Items.sheldoniteOres) : TRContent.Ingots.PLATINUM,
|
||||||
(cItem("platinum_dusts")): TRContent.Ingots.PLATINUM,
|
(CommonTags.Items.platinumDusts) : TRContent.Ingots.PLATINUM,
|
||||||
(Items.IRON_INGOT): TRContent.Ingots.REFINED_IRON,
|
(Items.IRON_INGOT) : TRContent.Ingots.REFINED_IRON,
|
||||||
(cItem("iron_plates")): TRContent.Plates.REFINED_IRON,
|
(CommonTags.Items.ironPlates) : TRContent.Plates.REFINED_IRON,
|
||||||
(cItem("silver_ores")): TRContent.Ingots.SILVER,
|
(CommonTags.Items.silverOres) : TRContent.Ingots.SILVER,
|
||||||
(cItem("raw_silver_ores")): TRContent.Ingots.SILVER,
|
(CommonTags.Items.rawSilverOres) : TRContent.Ingots.SILVER,
|
||||||
(cItem("tin_ores")): TRContent.Ingots.TIN,
|
(CommonTags.Items.tinOres) : TRContent.Ingots.TIN,
|
||||||
(cItem("raw_tin_ores")): TRContent.Ingots.TIN,
|
(CommonTags.Items.rawTinOres) : TRContent.Ingots.TIN,
|
||||||
(cItem("zinc_dusts")): TRContent.Ingots.ZINC
|
(CommonTags.Items.zincDusts) : TRContent.Ingots.ZINC
|
||||||
].each {input, output ->
|
].each { input, output ->
|
||||||
offerSmelting(input, output)
|
offerSmelting(input, output)
|
||||||
offerBlasting(input, output)
|
offerBlasting(input, output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def offerSmelting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
|
def offerSmelting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
|
||||||
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.SMELTING, "smelting/")
|
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.SMELTING, "smelting/")
|
||||||
}
|
}
|
||||||
|
|
||||||
def offerBlasting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
|
def offerBlasting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
|
||||||
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.BLASTING, "blasting/")
|
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.BLASTING, "blasting/")
|
||||||
}
|
}
|
||||||
|
|
||||||
def offerCookingRecipe(def input, ItemConvertible output, float experience, int cookingTime, CookingRecipeSerializer<?> serializer, String prefix = "") {
|
def offerCookingRecipe(def input, ItemConvertible output, float experience, int cookingTime, CookingRecipeSerializer<?> serializer, String prefix = "") {
|
||||||
CookingRecipeJsonFactory.create(createIngredient(input), output, experience, cookingTime, serializer)
|
CookingRecipeJsonFactory.create(createIngredient(input), output, experience, cookingTime, serializer)
|
||||||
.criterion(getCriterionName(input), getCriterionConditions(input))
|
.criterion(getCriterionName(input), getCriterionConditions(input))
|
||||||
.offerTo(this.exporter, prefix + getInputPath(output) + "_from_" + getInputPath(input))
|
.offerTo(this.exporter, prefix + getInputPath(output) + "_from_" + getInputPath(input))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
54
src/datagen/groovy/techreborn/datagen/tags/CommonTags.groovy
Normal file
54
src/datagen/groovy/techreborn/datagen/tags/CommonTags.groovy
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TechReborn
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package techreborn.datagen.tags
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.tag.TagFactory
|
||||||
|
import net.minecraft.util.Identifier
|
||||||
|
|
||||||
|
class CommonTags {
|
||||||
|
static class Items {
|
||||||
|
public static zincIngots = create("zinc_ingots")
|
||||||
|
|
||||||
|
public static brassDusts = create("brass_dusts")
|
||||||
|
public static electrumDusts = create("electrum_dusts")
|
||||||
|
public static platinumDusts = create("platinum_dusts")
|
||||||
|
public static zincDusts = create("zinc_dusts")
|
||||||
|
|
||||||
|
public static leadOres = create("lead_ores")
|
||||||
|
public static sheldoniteOres = create("sheldonite_ores")
|
||||||
|
public static silverOres = create("silver_ores")
|
||||||
|
public static tinOres = create("tin_ores")
|
||||||
|
|
||||||
|
public static rawLeadOres = create("raw_lead_ores")
|
||||||
|
public static rawSilverOres = create("raw_silver_ores")
|
||||||
|
public static rawTinOres = create("raw_tin_ores")
|
||||||
|
|
||||||
|
public static ironPlates = create("iron_plates")
|
||||||
|
|
||||||
|
private static def create(String path) {
|
||||||
|
return TagFactory.ITEM.create(new Identifier("c", path))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,26 +24,20 @@
|
||||||
|
|
||||||
package techreborn.api.recipe.recipes;
|
package techreborn.api.recipe.recipes;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEntity;
|
import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BlastFurnaceRecipe extends RebornRecipe {
|
public class BlastFurnaceRecipe extends RebornRecipe {
|
||||||
|
private final int heat;
|
||||||
|
|
||||||
private int heat;
|
public BlastFurnaceRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, int heat) {
|
||||||
|
|
||||||
public BlastFurnaceRecipe(RebornRecipeType<?> type, Identifier name) {
|
|
||||||
super(type, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlastFurnaceRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, int heat) {
|
|
||||||
super(type, name, ingredients, outputs, power, time);
|
super(type, name, ingredients, outputs, power, time);
|
||||||
this.heat = heat;
|
this.heat = heat;
|
||||||
}
|
}
|
||||||
|
@ -52,18 +46,6 @@ public class BlastFurnaceRecipe extends RebornRecipe {
|
||||||
return heat;
|
return heat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserialize(JsonObject jsonObject) {
|
|
||||||
super.deserialize(jsonObject);
|
|
||||||
heat = JsonHelper.getInt(jsonObject, "heat");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(JsonObject jsonObject) {
|
|
||||||
super.serialize(jsonObject);
|
|
||||||
jsonObject.addProperty("heat", heat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canCraft(final BlockEntity blockEntity) {
|
public boolean canCraft(final BlockEntity blockEntity) {
|
||||||
if (blockEntity instanceof final IndustrialBlastFurnaceBlockEntity blastFurnace) {
|
if (blockEntity instanceof final IndustrialBlastFurnaceBlockEntity blastFurnace) {
|
||||||
|
|
|
@ -29,27 +29,19 @@ import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import reborncore.common.crafting.RebornFluidRecipe;
|
import reborncore.common.crafting.RebornFluidRecipe;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
import reborncore.common.fluid.FluidUtils;
|
||||||
import reborncore.common.fluid.container.FluidInstance;
|
import reborncore.common.fluid.container.FluidInstance;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
|
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
|
||||||
import reborncore.common.fluid.FluidUtils;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class FluidReplicatorRecipe extends RebornFluidRecipe {
|
public class FluidReplicatorRecipe extends RebornFluidRecipe {
|
||||||
|
public FluidReplicatorRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, FluidInstance fluid) {
|
||||||
public FluidReplicatorRecipe(RebornRecipeType<?> type, Identifier name) {
|
|
||||||
super(type, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FluidReplicatorRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time) {
|
|
||||||
super(type, name, ingredients, outputs, power, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FluidReplicatorRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, FluidInstance fluid) {
|
|
||||||
super(type, name, ingredients, outputs, power, time, fluid);
|
super(type, name, ingredients, outputs, power, time, fluid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,30 +24,24 @@
|
||||||
|
|
||||||
package techreborn.api.recipe.recipes;
|
package techreborn.api.recipe.recipes;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
|
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
*/
|
*/
|
||||||
public class FusionReactorRecipe extends RebornRecipe {
|
public class FusionReactorRecipe extends RebornRecipe {
|
||||||
|
private final int startE;
|
||||||
|
private final int minSize;
|
||||||
|
|
||||||
private int startE;
|
public FusionReactorRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, int startE, int minSize) {
|
||||||
private int minSize;
|
|
||||||
|
|
||||||
public FusionReactorRecipe(RebornRecipeType<?> type, Identifier name) {
|
|
||||||
super(type, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FusionReactorRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, int startE, int minSize) {
|
|
||||||
super(type, name, ingredients, outputs, power, time);
|
super(type, name, ingredients, outputs, power, time);
|
||||||
this.startE = startE;
|
this.startE = startE;
|
||||||
this.minSize = minSize;
|
this.minSize = minSize;
|
||||||
|
@ -57,18 +51,8 @@ public class FusionReactorRecipe extends RebornRecipe {
|
||||||
return startE;
|
return startE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getMinSize() {
|
||||||
public void deserialize(JsonObject jsonObject) {
|
return minSize;
|
||||||
super.deserialize(jsonObject);
|
|
||||||
startE = JsonHelper.getInt(jsonObject, "start-power");
|
|
||||||
minSize = JsonHelper.getInt(jsonObject, "min-size");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(JsonObject jsonObject) {
|
|
||||||
super.serialize(jsonObject);
|
|
||||||
jsonObject.addProperty("start-power", startE);
|
|
||||||
jsonObject.addProperty("min-size", minSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,7 +27,6 @@ package techreborn.api.recipe.recipes;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
|
||||||
import reborncore.common.crafting.RebornFluidRecipe;
|
import reborncore.common.crafting.RebornFluidRecipe;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
@ -35,17 +34,10 @@ import reborncore.common.fluid.container.FluidInstance;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity;
|
import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class IndustrialGrinderRecipe extends RebornFluidRecipe {
|
public class IndustrialGrinderRecipe extends RebornFluidRecipe {
|
||||||
|
public IndustrialGrinderRecipe(RebornRecipeType<IndustrialGrinderRecipe> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, FluidInstance fluid) {
|
||||||
public IndustrialGrinderRecipe(RebornRecipeType<?> type, Identifier name) {
|
|
||||||
super(type, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IndustrialGrinderRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time) {
|
|
||||||
super(type, name, ingredients, outputs, power, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IndustrialGrinderRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, FluidInstance fluid) {
|
|
||||||
super(type, name, ingredients, outputs, power, time, fluid);
|
super(type, name, ingredients, outputs, power, time, fluid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ package techreborn.api.recipe.recipes;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
|
||||||
import reborncore.common.crafting.RebornFluidRecipe;
|
import reborncore.common.crafting.RebornFluidRecipe;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
@ -35,17 +34,10 @@ import reborncore.common.fluid.container.FluidInstance;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity;
|
import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class IndustrialSawmillRecipe extends RebornFluidRecipe {
|
public class IndustrialSawmillRecipe extends RebornFluidRecipe {
|
||||||
|
public IndustrialSawmillRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, FluidInstance fluid) {
|
||||||
public IndustrialSawmillRecipe(RebornRecipeType<?> type, Identifier name) {
|
|
||||||
super(type, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IndustrialSawmillRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time) {
|
|
||||||
super(type, name, ingredients, outputs, power, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IndustrialSawmillRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, FluidInstance fluid) {
|
|
||||||
super(type, name, ingredients, outputs, power, time, fluid);
|
super(type, name, ingredients, outputs, power, time, fluid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,9 @@ import com.google.gson.JsonObject;
|
||||||
import net.minecraft.inventory.CraftingInventory;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.PacketByteBuf;
|
|
||||||
import net.minecraft.recipe.Ingredient;
|
import net.minecraft.recipe.Ingredient;
|
||||||
import net.minecraft.recipe.RecipeSerializer;
|
|
||||||
import net.minecraft.recipe.ShapedRecipe;
|
import net.minecraft.recipe.ShapedRecipe;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
|
@ -44,41 +41,13 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RollingMachineRecipe extends RebornRecipe {
|
public class RollingMachineRecipe extends RebornRecipe {
|
||||||
|
private final ShapedRecipe shapedRecipe;
|
||||||
|
private final JsonObject shapedRecipeJson;
|
||||||
|
|
||||||
private ShapedRecipe shapedRecipe;
|
public RollingMachineRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, ShapedRecipe shapedRecipe, JsonObject shapedRecipeJson) {
|
||||||
|
super(type, name, ingredients, outputs, power, time);
|
||||||
public RollingMachineRecipe(RebornRecipeType<?> type, Identifier name) {
|
this.shapedRecipe = shapedRecipe;
|
||||||
super(type, name);
|
this.shapedRecipeJson = shapedRecipeJson;
|
||||||
}
|
|
||||||
|
|
||||||
public RollingMachineRecipe(RebornRecipeType<?> type, Identifier name, ShapedRecipe recipe) {
|
|
||||||
super(type, name);
|
|
||||||
this.shapedRecipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserialize(JsonObject jsonObject) {
|
|
||||||
if (jsonObject.has("shaped")) {
|
|
||||||
JsonObject json = JsonHelper.getObject(jsonObject, "shaped");
|
|
||||||
shapedRecipe = RecipeSerializer.SHAPED.read(getId(), json);
|
|
||||||
} else {
|
|
||||||
//This will be handled by the PacketByteBuf deserialize
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(PacketByteBuf byteBuf) {
|
|
||||||
String s = shapedRecipe.getId().toString();
|
|
||||||
byteBuf.writeInt(s.length());
|
|
||||||
byteBuf.writeString(s);
|
|
||||||
RecipeSerializer.SHAPED.write(byteBuf, shapedRecipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserialize(PacketByteBuf byteBuf) {
|
|
||||||
Identifier identifier = new Identifier(byteBuf.readString(byteBuf.readInt()));
|
|
||||||
shapedRecipe = RecipeSerializer.SHAPED.read(identifier, byteBuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,4 +88,8 @@ public class RollingMachineRecipe extends RebornRecipe {
|
||||||
public ShapedRecipe getShapedRecipe() {
|
public ShapedRecipe getShapedRecipe() {
|
||||||
return shapedRecipe;
|
return shapedRecipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonObject getShapedRecipeJson() {
|
||||||
|
return shapedRecipeJson;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TechReborn
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package techreborn.api.recipe.recipes.serde;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.JsonHelper;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
import reborncore.common.crafting.serde.RebornRecipeSerde;
|
||||||
|
import techreborn.api.recipe.recipes.BlastFurnaceRecipe;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BlastFurnaceRecipeSerde extends RebornRecipeSerde<BlastFurnaceRecipe> {
|
||||||
|
@Override
|
||||||
|
protected BlastFurnaceRecipe fromJson(JsonObject jsonObject, RebornRecipeType<BlastFurnaceRecipe> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time) {
|
||||||
|
final int heat = JsonHelper.getInt(jsonObject, "heat");
|
||||||
|
return new BlastFurnaceRecipe(type, name, ingredients, outputs, power, time, heat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectJsonData(BlastFurnaceRecipe recipe, JsonObject jsonObject) {
|
||||||
|
jsonObject.addProperty("heat", recipe.getHeat());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TechReborn
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package techreborn.api.recipe.recipes.serde;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.JsonHelper;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
import reborncore.common.crafting.serde.RebornRecipeSerde;
|
||||||
|
import techreborn.api.recipe.recipes.FusionReactorRecipe;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FusionReactorRecipeSerde extends RebornRecipeSerde<FusionReactorRecipe> {
|
||||||
|
@Override
|
||||||
|
protected FusionReactorRecipe fromJson(JsonObject jsonObject, RebornRecipeType<FusionReactorRecipe> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time) {
|
||||||
|
final int startE = JsonHelper.getInt(jsonObject, "start-power");
|
||||||
|
final int minSize = JsonHelper.getInt(jsonObject, "min-size");
|
||||||
|
return new FusionReactorRecipe(type, name, ingredients, outputs, power, time, startE, minSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void collectJsonData(FusionReactorRecipe recipe, JsonObject jsonObject) {
|
||||||
|
jsonObject.addProperty("start-power", recipe.getStartEnergy());
|
||||||
|
jsonObject.addProperty("min-size", recipe.getMinSize());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package techreborn.api.recipe.recipes.serde;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.recipe.RecipeSerializer;
|
||||||
|
import net.minecraft.recipe.ShapedRecipe;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.JsonHelper;
|
||||||
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||||
|
import reborncore.common.crafting.serde.RebornRecipeSerde;
|
||||||
|
import techreborn.api.recipe.recipes.RollingMachineRecipe;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RollingMachineRecipeSerde extends RebornRecipeSerde<RollingMachineRecipe> {
|
||||||
|
@Override
|
||||||
|
protected RollingMachineRecipe fromJson(JsonObject jsonObject, RebornRecipeType<RollingMachineRecipe> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time) {
|
||||||
|
final JsonObject shapedRecipeJson = JsonHelper.getObject(jsonObject, "shaped");
|
||||||
|
final ShapedRecipe shapedRecipe = RecipeSerializer.SHAPED.read(name, shapedRecipeJson);
|
||||||
|
return new RollingMachineRecipe(type, name, ingredients, outputs, power, time, shapedRecipe, shapedRecipeJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectJsonData(RollingMachineRecipe recipe, JsonObject jsonObject) {
|
||||||
|
jsonObject.add("shaped", recipe.getShapedRecipeJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<RebornIngredient> getIngredients(JsonObject jsonObject) {
|
||||||
|
// Inputs are handled by the shaped recipe.
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<ItemStack> getOutputs(JsonObject jsonObject) {
|
||||||
|
// Outputs are handled by the shaped recipe.
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void writeIngredients(RollingMachineRecipe recipe, JsonObject jsonObject) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void writeOutputs(RollingMachineRecipe recipe, JsonObject jsonObject) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -126,7 +126,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentRecipeOutput.isEmpty() && canMake(craftMatrix)) {
|
if (!currentRecipeOutput.isEmpty() && canMake(craftMatrix)) {
|
||||||
if (tickTime >= Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1)) {
|
if (tickTime >= Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1)) {
|
||||||
currentRecipeOutput = findMatchingRecipeOutput(craftMatrix, world);
|
currentRecipeOutput = findMatchingRecipeOutput(craftMatrix, world);
|
||||||
if (!currentRecipeOutput.isEmpty()) {
|
if (!currentRecipeOutput.isEmpty()) {
|
||||||
boolean hasCrafted = false;
|
boolean hasCrafted = false;
|
||||||
|
@ -159,10 +159,10 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
tickTime = 0;
|
tickTime = 0;
|
||||||
}
|
}
|
||||||
if (!currentRecipeOutput.isEmpty()) {
|
if (!currentRecipeOutput.isEmpty()) {
|
||||||
if (getStored() > getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick)
|
if (getStored() > getEuPerTick(currentRecipe.getPower())
|
||||||
&& tickTime < Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1)
|
&& tickTime < Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1)
|
||||||
&& canMake(craftMatrix)) {
|
&& canMake(craftMatrix)) {
|
||||||
useEnergy(getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick));
|
useEnergy(getEuPerTick(currentRecipe.getPower()));
|
||||||
tickTime++;
|
tickTime++;
|
||||||
} else {
|
} else {
|
||||||
setIsActive(false);
|
setIsActive(false);
|
||||||
|
@ -375,10 +375,10 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBurnTimeRemainingScaled(final int scale) {
|
public int getBurnTimeRemainingScaled(final int scale) {
|
||||||
if (tickTime == 0 || Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1) == 0) {
|
if (tickTime == 0 || Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1) == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1);
|
return tickTime * scale / Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -405,8 +405,8 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgressScaled(final int scale) {
|
public int getProgressScaled(final int scale) {
|
||||||
if (tickTime != 0 && Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1) != 0) {
|
if (tickTime != 0 && Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1) != 0) {
|
||||||
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1);
|
return tickTime * scale / Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,12 +366,6 @@ public class TechRebornConfig {
|
||||||
@Config(config = "machines", category = "rolling_machine", key = "RollingMachineMaxInput", comment = "Rolling Machine Max Input (Energy per tick)")
|
@Config(config = "machines", category = "rolling_machine", key = "RollingMachineMaxInput", comment = "Rolling Machine Max Input (Energy per tick)")
|
||||||
public static int rollingMachineMaxInput = 32;
|
public static int rollingMachineMaxInput = 32;
|
||||||
|
|
||||||
@Config(config = "machines", category = "rolling_machine", key = "RollingMachineEnergyPerTick", comment = "Rolling Machine Energy usage (Energy per tick)")
|
|
||||||
public static int rollingMachineEnergyPerTick = 5;
|
|
||||||
|
|
||||||
@Config(config = "machines", category = "rolling_machine", key = "RollingMachineEnergyRunTime", comment = "Rolling Machine Run Time")
|
|
||||||
public static int rollingMachineRunTime = 250;
|
|
||||||
|
|
||||||
@Config(config = "machines", category = "rolling_machine", key = "RollingMachineMaxEnergy", comment = "Rolling Machine Max Energy")
|
@Config(config = "machines", category = "rolling_machine", key = "RollingMachineMaxEnergy", comment = "Rolling Machine Max Energy")
|
||||||
public static int rollingMachineMaxEnergy = 10000;
|
public static int rollingMachineMaxEnergy = 10000;
|
||||||
|
|
||||||
|
|
|
@ -29,31 +29,42 @@ import net.minecraft.util.registry.Registry;
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
import reborncore.common.crafting.RecipeManager;
|
import reborncore.common.crafting.RecipeManager;
|
||||||
|
import reborncore.common.crafting.serde.RebornFluidRecipeSerde;
|
||||||
|
import reborncore.common.crafting.serde.RebornRecipeSerde;
|
||||||
import techreborn.api.recipe.recipes.*;
|
import techreborn.api.recipe.recipes.*;
|
||||||
|
import techreborn.api.recipe.recipes.serde.BlastFurnaceRecipeSerde;
|
||||||
|
import techreborn.api.recipe.recipes.serde.FusionReactorRecipeSerde;
|
||||||
|
import techreborn.api.recipe.recipes.serde.RollingMachineRecipeSerde;
|
||||||
|
|
||||||
public class ModRecipes {
|
public class ModRecipes {
|
||||||
|
public static final BlastFurnaceRecipeSerde BLAST_FURNACE_RECIPE_SERDE = new BlastFurnaceRecipeSerde();
|
||||||
|
public static final RebornFluidRecipeSerde<IndustrialGrinderRecipe> INDUSTRIAL_GRINDER_RECIPE_SERDE = RebornFluidRecipeSerde.create(IndustrialGrinderRecipe::new);
|
||||||
|
public static final RebornFluidRecipeSerde<IndustrialSawmillRecipe> INDUSTRIAL_SAWILL_RECIPE_SERDE = RebornFluidRecipeSerde.create(IndustrialSawmillRecipe::new);
|
||||||
|
public static final RebornFluidRecipeSerde<FluidReplicatorRecipe> FLUID_REPLICATOR_RECIPE_SERDE = RebornFluidRecipeSerde.create(FluidReplicatorRecipe::new);
|
||||||
|
public static final FusionReactorRecipeSerde FUSION_REACTOR_RECIPE_SERDE = new FusionReactorRecipeSerde();
|
||||||
|
public static final RollingMachineRecipeSerde ROLLING_MACHINE_RECIPE_SERDE = new RollingMachineRecipeSerde();
|
||||||
|
|
||||||
public static final RebornRecipeType<RebornRecipe> ALLOY_SMELTER = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:alloy_smelter"));
|
public static final RebornRecipeType<RebornRecipe> ALLOY_SMELTER = RecipeManager.newRecipeType(new Identifier("techreborn:alloy_smelter"));
|
||||||
public static final RebornRecipeType<RebornRecipe> ASSEMBLING_MACHINE = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:assembling_machine"));
|
public static final RebornRecipeType<RebornRecipe> ASSEMBLING_MACHINE = RecipeManager.newRecipeType(new Identifier("techreborn:assembling_machine"));
|
||||||
public static final RebornRecipeType<BlastFurnaceRecipe> BLAST_FURNACE = RecipeManager.newRecipeType(BlastFurnaceRecipe::new, new Identifier("techreborn:blast_furnace"));
|
public static final RebornRecipeType<BlastFurnaceRecipe> BLAST_FURNACE = RecipeManager.newRecipeType(BLAST_FURNACE_RECIPE_SERDE, new Identifier("techreborn:blast_furnace"));
|
||||||
public static final RebornRecipeType<RebornRecipe> CENTRIFUGE = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:centrifuge"));
|
public static final RebornRecipeType<RebornRecipe> CENTRIFUGE = RecipeManager.newRecipeType(new Identifier("techreborn:centrifuge"));
|
||||||
public static final RebornRecipeType<RebornRecipe> CHEMICAL_REACTOR = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:chemical_reactor"));
|
public static final RebornRecipeType<RebornRecipe> CHEMICAL_REACTOR = RecipeManager.newRecipeType(new Identifier("techreborn:chemical_reactor"));
|
||||||
public static final RebornRecipeType<RebornRecipe> COMPRESSOR = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:compressor"));
|
public static final RebornRecipeType<RebornRecipe> COMPRESSOR = RecipeManager.newRecipeType(new Identifier("techreborn:compressor"));
|
||||||
public static final RebornRecipeType<RebornRecipe> DISTILLATION_TOWER = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:distillation_tower"));
|
public static final RebornRecipeType<RebornRecipe> DISTILLATION_TOWER = RecipeManager.newRecipeType(new Identifier("techreborn:distillation_tower"));
|
||||||
public static final RebornRecipeType<RebornRecipe> EXTRACTOR = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:extractor"));
|
public static final RebornRecipeType<RebornRecipe> EXTRACTOR = RecipeManager.newRecipeType(new Identifier("techreborn:extractor"));
|
||||||
public static final RebornRecipeType<RebornRecipe> GRINDER = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:grinder"));
|
public static final RebornRecipeType<RebornRecipe> GRINDER = RecipeManager.newRecipeType(new Identifier("techreborn:grinder"));
|
||||||
public static final RebornRecipeType<RebornRecipe> IMPLOSION_COMPRESSOR = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:implosion_compressor"));
|
public static final RebornRecipeType<RebornRecipe> IMPLOSION_COMPRESSOR = RecipeManager.newRecipeType(new Identifier("techreborn:implosion_compressor"));
|
||||||
public static final RebornRecipeType<RebornRecipe> INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:industrial_electrolyzer"));
|
public static final RebornRecipeType<RebornRecipe> INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(new Identifier("techreborn:industrial_electrolyzer"));
|
||||||
public static final RebornRecipeType<IndustrialGrinderRecipe> INDUSTRIAL_GRINDER = RecipeManager.newRecipeType(IndustrialGrinderRecipe::new, new Identifier("techreborn:industrial_grinder"));
|
public static final RebornRecipeType<IndustrialGrinderRecipe> INDUSTRIAL_GRINDER = RecipeManager.newRecipeType(INDUSTRIAL_GRINDER_RECIPE_SERDE, new Identifier("techreborn:industrial_grinder"));
|
||||||
public static final RebornRecipeType<IndustrialSawmillRecipe> INDUSTRIAL_SAWMILL = RecipeManager.newRecipeType(IndustrialSawmillRecipe::new, new Identifier("techreborn:industrial_sawmill"));
|
public static final RebornRecipeType<IndustrialSawmillRecipe> INDUSTRIAL_SAWMILL = RecipeManager.newRecipeType(INDUSTRIAL_SAWILL_RECIPE_SERDE, new Identifier("techreborn:industrial_sawmill"));
|
||||||
public static final RebornRecipeType<RebornRecipe> RECYCLER = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:recycler"));
|
public static final RebornRecipeType<RebornRecipe> RECYCLER = RecipeManager.newRecipeType(new Identifier("techreborn:recycler"));
|
||||||
public static final RebornRecipeType<RebornRecipe> SCRAPBOX = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:scrapbox"));
|
public static final RebornRecipeType<RebornRecipe> SCRAPBOX = RecipeManager.newRecipeType(new Identifier("techreborn:scrapbox"));
|
||||||
public static final RebornRecipeType<RebornRecipe> VACUUM_FREEZER = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:vacuum_freezer"));
|
public static final RebornRecipeType<RebornRecipe> VACUUM_FREEZER = RecipeManager.newRecipeType(new Identifier("techreborn:vacuum_freezer"));
|
||||||
public static final RebornRecipeType<FluidReplicatorRecipe> FLUID_REPLICATOR = RecipeManager.newRecipeType(FluidReplicatorRecipe::new, new Identifier("techreborn:fluid_replicator"));
|
public static final RebornRecipeType<FluidReplicatorRecipe> FLUID_REPLICATOR = RecipeManager.newRecipeType(FLUID_REPLICATOR_RECIPE_SERDE, new Identifier("techreborn:fluid_replicator"));
|
||||||
public static final RebornRecipeType<FusionReactorRecipe> FUSION_REACTOR = RecipeManager.newRecipeType(FusionReactorRecipe::new, new Identifier("techreborn:fusion_reactor"));
|
public static final RebornRecipeType<FusionReactorRecipe> FUSION_REACTOR = RecipeManager.newRecipeType(FUSION_REACTOR_RECIPE_SERDE, new Identifier("techreborn:fusion_reactor"));
|
||||||
public static final RebornRecipeType<RollingMachineRecipe> ROLLING_MACHINE = RecipeManager.newRecipeType(RollingMachineRecipe::new, new Identifier("techreborn:rolling_machine"));
|
public static final RebornRecipeType<RollingMachineRecipe> ROLLING_MACHINE = RecipeManager.newRecipeType(ROLLING_MACHINE_RECIPE_SERDE, new Identifier("techreborn:rolling_machine"));
|
||||||
public static final RebornRecipeType<RebornRecipe> SOLID_CANNING_MACHINE = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:solid_canning_machine"));
|
public static final RebornRecipeType<RebornRecipe> SOLID_CANNING_MACHINE = RecipeManager.newRecipeType(new Identifier("techreborn:solid_canning_machine"));
|
||||||
public static final RebornRecipeType<RebornRecipe> WIRE_MILL = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:wire_mill"));
|
public static final RebornRecipeType<RebornRecipe> WIRE_MILL = RecipeManager.newRecipeType(new Identifier("techreborn:wire_mill"));
|
||||||
|
|
||||||
public static RebornRecipeType<?> byName(Identifier identifier) {
|
public static RebornRecipeType<?> byName(Identifier identifier) {
|
||||||
return (RebornRecipeType<?>) Registry.RECIPE_SERIALIZER.get(identifier);
|
return (RebornRecipeType<?>) Registry.RECIPE_SERIALIZER.get(identifier);
|
||||||
|
|
|
@ -21,5 +21,7 @@
|
||||||
"item": "minecraft:activator_rail",
|
"item": "minecraft:activator_rail",
|
||||||
"count": 8
|
"count": 8
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -15,5 +15,7 @@
|
||||||
"item": "minecraft:bucket",
|
"item": "minecraft:bucket",
|
||||||
"count": 2
|
"count": 2
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -18,5 +18,7 @@
|
||||||
"item": "techreborn:cupronickel_heating_coil",
|
"item": "techreborn:cupronickel_heating_coil",
|
||||||
"count": 3
|
"count": 3
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -21,5 +21,7 @@
|
||||||
"item": "minecraft:detector_rail",
|
"item": "minecraft:detector_rail",
|
||||||
"count": 8
|
"count": 8
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -13,5 +13,7 @@
|
||||||
"item": "minecraft:heavy_weighted_pressure_plate",
|
"item": "minecraft:heavy_weighted_pressure_plate",
|
||||||
"count": 2
|
"count": 2
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -14,5 +14,7 @@
|
||||||
"item": "minecraft:iron_bars",
|
"item": "minecraft:iron_bars",
|
||||||
"count": 24
|
"count": 24
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -15,5 +15,7 @@
|
||||||
"item": "minecraft:iron_door",
|
"item": "minecraft:iron_door",
|
||||||
"count": 4
|
"count": 4
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -13,5 +13,7 @@
|
||||||
"item": "minecraft:light_weighted_pressure_plate",
|
"item": "minecraft:light_weighted_pressure_plate",
|
||||||
"count": 2
|
"count": 2
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -18,5 +18,7 @@
|
||||||
"item": "techreborn:magnalium_plate",
|
"item": "techreborn:magnalium_plate",
|
||||||
"count": 3
|
"count": 3
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -14,5 +14,7 @@
|
||||||
"item": "minecraft:minecart",
|
"item": "minecraft:minecart",
|
||||||
"count": 1
|
"count": 1
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -18,5 +18,7 @@
|
||||||
"item": "techreborn:nichrome_heating_coil",
|
"item": "techreborn:nichrome_heating_coil",
|
||||||
"count": 2
|
"count": 2
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -21,5 +21,7 @@
|
||||||
"item": "minecraft:powered_rail",
|
"item": "minecraft:powered_rail",
|
||||||
"count": 8
|
"count": 8
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
|
@ -18,5 +18,7 @@
|
||||||
"item": "minecraft:rail",
|
"item": "minecraft:rail",
|
||||||
"count": 24
|
"count": 24
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"power": 5,
|
||||||
|
"time": 250
|
||||||
}
|
}
|
Loading…
Reference in a new issue