Refactor recipe system.

This commit is contained in:
modmuss50 2022-01-20 19:55:40 +00:00 committed by GitHub
commit 17e8911978
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 693 additions and 495 deletions

View file

@ -30,52 +30,52 @@ import net.minecraft.item.ItemConvertible
import net.minecraft.item.Items
import net.minecraft.recipe.CookingRecipeSerializer
import net.minecraft.recipe.RecipeSerializer
import techreborn.datagen.tags.CommonTagsTrait
import techreborn.datagen.tags.CommonTags
import techreborn.init.TRContent
class SmeltingRecipesProvider extends TechRebornRecipesProvider implements CommonTagsTrait {
class SmeltingRecipesProvider extends TechRebornRecipesProvider {
SmeltingRecipesProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator)
}
@Override
void generateRecipes() {
// Add smelting and blasting recipes.
[
(TRContent.Ingots.MIXED_METAL): TRContent.Ingots.ADVANCED_ALLOY,
(cItem("brass_dusts")): TRContent.Ingots.BRASS,
(TRContent.Dusts.BRONZE): TRContent.Ingots.BRONZE,
(cItem("electrum_dusts")): TRContent.Ingots.ELECTRUM,
(TRContent.Dusts.INVAR): TRContent.Ingots.INVAR,
(cItem("lead_ores")): TRContent.Ingots.LEAD,
(cItem("raw_lead_ores")): TRContent.Ingots.LEAD,
(TRContent.Dusts.NICKEL): TRContent.Ingots.NICKEL,
(cItem("sheldonite_ores")): TRContent.Ingots.PLATINUM,
(cItem("platinum_dusts")): TRContent.Ingots.PLATINUM,
(Items.IRON_INGOT): TRContent.Ingots.REFINED_IRON,
(cItem("iron_plates")): TRContent.Plates.REFINED_IRON,
(cItem("silver_ores")): TRContent.Ingots.SILVER,
(cItem("raw_silver_ores")): TRContent.Ingots.SILVER,
(cItem("tin_ores")): TRContent.Ingots.TIN,
(cItem("raw_tin_ores")): TRContent.Ingots.TIN,
(cItem("zinc_dusts")): TRContent.Ingots.ZINC
].each {input, output ->
offerSmelting(input, output)
offerBlasting(input, output)
}
// Add smelting and blasting recipes.
[
(TRContent.Ingots.MIXED_METAL) : TRContent.Ingots.ADVANCED_ALLOY,
(CommonTags.Items.brassDusts) : TRContent.Ingots.BRASS,
(TRContent.Dusts.BRONZE) : TRContent.Ingots.BRONZE,
(CommonTags.Items.electrumDusts): TRContent.Ingots.ELECTRUM,
(TRContent.Dusts.INVAR) : TRContent.Ingots.INVAR,
(CommonTags.Items.leadOres) : TRContent.Ingots.LEAD,
(CommonTags.Items.rawLeadOres) : TRContent.Ingots.LEAD,
(TRContent.Dusts.NICKEL) : TRContent.Ingots.NICKEL,
(CommonTags.Items.sheldoniteOres) : TRContent.Ingots.PLATINUM,
(CommonTags.Items.platinumDusts) : TRContent.Ingots.PLATINUM,
(Items.IRON_INGOT) : TRContent.Ingots.REFINED_IRON,
(CommonTags.Items.ironPlates) : TRContent.Plates.REFINED_IRON,
(CommonTags.Items.silverOres) : TRContent.Ingots.SILVER,
(CommonTags.Items.rawSilverOres) : TRContent.Ingots.SILVER,
(CommonTags.Items.tinOres) : TRContent.Ingots.TIN,
(CommonTags.Items.rawTinOres) : TRContent.Ingots.TIN,
(CommonTags.Items.zincDusts) : TRContent.Ingots.ZINC
].each { input, output ->
offerSmelting(input, output)
offerBlasting(input, output)
}
}
def offerSmelting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.SMELTING, "smelting/")
}
def offerSmelting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.SMELTING, "smelting/")
}
def offerBlasting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.BLASTING, "blasting/")
}
def offerBlasting(def input, ItemConvertible output, float experience = 0.5f, int cookingTime = 200) {
offerCookingRecipe(input, output, experience, cookingTime, RecipeSerializer.BLASTING, "blasting/")
}
def offerCookingRecipe(def input, ItemConvertible output, float experience, int cookingTime, CookingRecipeSerializer<?> serializer, String prefix = "") {
CookingRecipeJsonFactory.create(createIngredient(input), output, experience, cookingTime, serializer)
.criterion(getCriterionName(input), getCriterionConditions(input))
.offerTo(this.exporter, prefix + getInputPath(output) + "_from_" + getInputPath(input))
def offerCookingRecipe(def input, ItemConvertible output, float experience, int cookingTime, CookingRecipeSerializer<?> serializer, String prefix = "") {
CookingRecipeJsonFactory.create(createIngredient(input), output, experience, cookingTime, serializer)
.criterion(getCriterionName(input), getCriterionConditions(input))
.offerTo(this.exporter, prefix + getInputPath(output) + "_from_" + getInputPath(input))
}
}

View file

@ -25,12 +25,30 @@
package techreborn.datagen.tags
import net.fabricmc.fabric.api.tag.TagFactory
import net.minecraft.item.Item
import net.minecraft.tag.Tag
import net.minecraft.util.Identifier
trait CommonTagsTrait {
static Tag.Identified<Item> cItem(String path) {
return TagFactory.ITEM.create(new Identifier("c", path))
}
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))
}
}
}

View file

@ -24,26 +24,20 @@
package techreborn.api.recipe.recipes;
import com.google.gson.JsonObject;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
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.RebornRecipeType;
import reborncore.common.crafting.ingredient.RebornIngredient;
import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEntity;
import java.util.List;
public class BlastFurnaceRecipe extends RebornRecipe {
private final int heat;
private 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) {
public BlastFurnaceRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, int heat) {
super(type, name, ingredients, outputs, power, time);
this.heat = heat;
}
@ -52,18 +46,6 @@ public class BlastFurnaceRecipe extends RebornRecipe {
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
public boolean canCraft(final BlockEntity blockEntity) {
if (blockEntity instanceof final IndustrialBlastFurnaceBlockEntity blastFurnace) {

View file

@ -29,27 +29,19 @@ import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import reborncore.common.crafting.RebornFluidRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.ingredient.RebornIngredient;
import reborncore.common.fluid.FluidUtils;
import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.util.Tank;
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
import reborncore.common.fluid.FluidUtils;
import java.util.List;
public class FluidReplicatorRecipe extends RebornFluidRecipe {
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) {
public FluidReplicatorRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, FluidInstance fluid) {
super(type, name, ingredients, outputs, power, time, fluid);
}

View file

@ -24,30 +24,24 @@
package techreborn.api.recipe.recipes;
import com.google.gson.JsonObject;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
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.RebornRecipeType;
import reborncore.common.crafting.ingredient.RebornIngredient;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
import java.util.List;
/**
* @author drcrazy
*/
public class FusionReactorRecipe extends RebornRecipe {
private final int startE;
private final int minSize;
private int startE;
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) {
public FusionReactorRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, int startE, int minSize) {
super(type, name, ingredients, outputs, power, time);
this.startE = startE;
this.minSize = minSize;
@ -57,18 +51,8 @@ public class FusionReactorRecipe extends RebornRecipe {
return startE;
}
@Override
public void deserialize(JsonObject jsonObject) {
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);
public int getMinSize() {
return minSize;
}
@Override

View file

@ -27,7 +27,6 @@ package techreborn.api.recipe.recipes;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import reborncore.common.crafting.RebornFluidRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.ingredient.RebornIngredient;
@ -35,17 +34,10 @@ import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.util.Tank;
import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity;
import java.util.List;
public class IndustrialGrinderRecipe extends RebornFluidRecipe {
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) {
public IndustrialGrinderRecipe(RebornRecipeType<IndustrialGrinderRecipe> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, FluidInstance fluid) {
super(type, name, ingredients, outputs, power, time, fluid);
}

View file

@ -27,7 +27,6 @@ package techreborn.api.recipe.recipes;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import reborncore.common.crafting.RebornFluidRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.ingredient.RebornIngredient;
@ -35,17 +34,10 @@ import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.util.Tank;
import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity;
import java.util.List;
public class IndustrialSawmillRecipe extends RebornFluidRecipe {
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) {
public IndustrialSawmillRecipe(RebornRecipeType<?> type, Identifier name, List<RebornIngredient> ingredients, List<ItemStack> outputs, int power, int time, FluidInstance fluid) {
super(type, name, ingredients, outputs, power, time, fluid);
}

View file

@ -28,12 +28,9 @@ import com.google.gson.JsonObject;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.ShapedRecipe;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.world.World;
import reborncore.common.crafting.RebornRecipe;
@ -44,41 +41,13 @@ import java.util.Collections;
import java.util.List;
public class RollingMachineRecipe extends RebornRecipe {
private final ShapedRecipe shapedRecipe;
private final JsonObject shapedRecipeJson;
private ShapedRecipe shapedRecipe;
public RollingMachineRecipe(RebornRecipeType<?> type, Identifier name) {
super(type, name);
}
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);
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);
this.shapedRecipe = shapedRecipe;
this.shapedRecipeJson = shapedRecipeJson;
}
@Override
@ -119,4 +88,8 @@ public class RollingMachineRecipe extends RebornRecipe {
public ShapedRecipe getShapedRecipe() {
return shapedRecipe;
}
public JsonObject getShapedRecipeJson() {
return shapedRecipeJson;
}
}

View file

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

View file

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

View file

@ -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) {
}
}

View file

@ -126,7 +126,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
}
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);
if (!currentRecipeOutput.isEmpty()) {
boolean hasCrafted = false;
@ -159,10 +159,10 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
tickTime = 0;
}
if (!currentRecipeOutput.isEmpty()) {
if (getStored() > getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick)
&& tickTime < Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1)
if (getStored() > getEuPerTick(currentRecipe.getPower())
&& tickTime < Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1)
&& canMake(craftMatrix)) {
useEnergy(getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick));
useEnergy(getEuPerTick(currentRecipe.getPower()));
tickTime++;
} else {
setIsActive(false);
@ -375,10 +375,10 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
}
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 tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1);
return tickTime * scale / Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1);
}
@Override
@ -405,8 +405,8 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
}
public int getProgressScaled(final int scale) {
if (tickTime != 0 && Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1) != 0) {
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1);
if (tickTime != 0 && Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1) != 0) {
return tickTime * scale / Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1);
}
return 0;
}

View file

@ -366,12 +366,6 @@ public class TechRebornConfig {
@Config(config = "machines", category = "rolling_machine", key = "RollingMachineMaxInput", comment = "Rolling Machine Max Input (Energy per tick)")
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")
public static int rollingMachineMaxEnergy = 10000;

View file

@ -29,31 +29,42 @@ import net.minecraft.util.registry.Registry;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
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.serde.BlastFurnaceRecipeSerde;
import techreborn.api.recipe.recipes.serde.FusionReactorRecipeSerde;
import techreborn.api.recipe.recipes.serde.RollingMachineRecipeSerde;
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> ASSEMBLING_MACHINE = RecipeManager.newRecipeType(RebornRecipe::new, 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<RebornRecipe> CENTRIFUGE = RecipeManager.newRecipeType(RebornRecipe::new, 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> COMPRESSOR = RecipeManager.newRecipeType(RebornRecipe::new, 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> EXTRACTOR = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:extractor"));
public static final RebornRecipeType<RebornRecipe> GRINDER = RecipeManager.newRecipeType(RebornRecipe::new, 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> INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(RebornRecipe::new, 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<IndustrialSawmillRecipe> INDUSTRIAL_SAWMILL = RecipeManager.newRecipeType(IndustrialSawmillRecipe::new, new Identifier("techreborn:industrial_sawmill"));
public static final RebornRecipeType<RebornRecipe> RECYCLER = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:recycler"));
public static final RebornRecipeType<RebornRecipe> SCRAPBOX = RecipeManager.newRecipeType(RebornRecipe::new, new Identifier("techreborn:scrapbox"));
public static final RebornRecipeType<RebornRecipe> VACUUM_FREEZER = RecipeManager.newRecipeType(RebornRecipe::new, 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<FusionReactorRecipe> FUSION_REACTOR = RecipeManager.newRecipeType(FusionReactorRecipe::new, 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<RebornRecipe> SOLID_CANNING_MACHINE = RecipeManager.newRecipeType(RebornRecipe::new, 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> ALLOY_SMELTER = RecipeManager.newRecipeType(new Identifier("techreborn:alloy_smelter"));
public static final RebornRecipeType<RebornRecipe> ASSEMBLING_MACHINE = RecipeManager.newRecipeType(new Identifier("techreborn:assembling_machine"));
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(new Identifier("techreborn:centrifuge"));
public static final RebornRecipeType<RebornRecipe> CHEMICAL_REACTOR = RecipeManager.newRecipeType(new Identifier("techreborn:chemical_reactor"));
public static final RebornRecipeType<RebornRecipe> COMPRESSOR = RecipeManager.newRecipeType(new Identifier("techreborn:compressor"));
public static final RebornRecipeType<RebornRecipe> DISTILLATION_TOWER = RecipeManager.newRecipeType(new Identifier("techreborn:distillation_tower"));
public static final RebornRecipeType<RebornRecipe> EXTRACTOR = RecipeManager.newRecipeType(new Identifier("techreborn:extractor"));
public static final RebornRecipeType<RebornRecipe> GRINDER = RecipeManager.newRecipeType(new Identifier("techreborn:grinder"));
public static final RebornRecipeType<RebornRecipe> IMPLOSION_COMPRESSOR = RecipeManager.newRecipeType(new Identifier("techreborn:implosion_compressor"));
public static final RebornRecipeType<RebornRecipe> INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(new Identifier("techreborn:industrial_electrolyzer"));
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(INDUSTRIAL_SAWILL_RECIPE_SERDE, new Identifier("techreborn:industrial_sawmill"));
public static final RebornRecipeType<RebornRecipe> RECYCLER = RecipeManager.newRecipeType(new Identifier("techreborn:recycler"));
public static final RebornRecipeType<RebornRecipe> SCRAPBOX = RecipeManager.newRecipeType(new Identifier("techreborn:scrapbox"));
public static final RebornRecipeType<RebornRecipe> VACUUM_FREEZER = RecipeManager.newRecipeType(new Identifier("techreborn:vacuum_freezer"));
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(FUSION_REACTOR_RECIPE_SERDE, new Identifier("techreborn:fusion_reactor"));
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(new Identifier("techreborn:solid_canning_machine"));
public static final RebornRecipeType<RebornRecipe> WIRE_MILL = RecipeManager.newRecipeType(new Identifier("techreborn:wire_mill"));
public static RebornRecipeType<?> byName(Identifier identifier) {
return (RebornRecipeType<?>) Registry.RECIPE_SERIALIZER.get(identifier);

View file

@ -21,5 +21,7 @@
"item": "minecraft:activator_rail",
"count": 8
}
}
},
"power": 5,
"time": 250
}

View file

@ -15,5 +15,7 @@
"item": "minecraft:bucket",
"count": 2
}
}
},
"power": 5,
"time": 250
}

View file

@ -18,5 +18,7 @@
"item": "techreborn:cupronickel_heating_coil",
"count": 3
}
}
},
"power": 5,
"time": 250
}

View file

@ -21,5 +21,7 @@
"item": "minecraft:detector_rail",
"count": 8
}
}
},
"power": 5,
"time": 250
}

View file

@ -13,5 +13,7 @@
"item": "minecraft:heavy_weighted_pressure_plate",
"count": 2
}
}
},
"power": 5,
"time": 250
}

View file

@ -14,5 +14,7 @@
"item": "minecraft:iron_bars",
"count": 24
}
}
},
"power": 5,
"time": 250
}

View file

@ -15,5 +15,7 @@
"item": "minecraft:iron_door",
"count": 4
}
}
},
"power": 5,
"time": 250
}

View file

@ -13,5 +13,7 @@
"item": "minecraft:light_weighted_pressure_plate",
"count": 2
}
}
},
"power": 5,
"time": 250
}

View file

@ -18,5 +18,7 @@
"item": "techreborn:magnalium_plate",
"count": 3
}
}
},
"power": 5,
"time": 250
}

View file

@ -14,5 +14,7 @@
"item": "minecraft:minecart",
"count": 1
}
}
},
"power": 5,
"time": 250
}

View file

@ -18,5 +18,7 @@
"item": "techreborn:nichrome_heating_coil",
"count": 2
}
}
},
"power": 5,
"time": 250
}

View file

@ -21,5 +21,7 @@
"item": "minecraft:powered_rail",
"count": 8
}
}
},
"power": 5,
"time": 250
}

View file

@ -18,5 +18,7 @@
"item": "minecraft:rail",
"count": 24
}
}
},
"power": 5,
"time": 250
}