[Feature] BCLRecipeBuilder

This commit is contained in:
Frank 2022-08-02 11:52:46 +02:00
parent 355a563cb8
commit 80a4ff8319
12 changed files with 308 additions and 280 deletions

View file

@ -4,7 +4,7 @@ import org.betterx.bclib.BCLib;
import org.betterx.bclib.blocks.*;
import org.betterx.bclib.complexmaterials.entry.BlockEntry;
import org.betterx.bclib.complexmaterials.entry.RecipeEntry;
import org.betterx.bclib.recipes.GridRecipe;
import org.betterx.bclib.recipes.BCLRecipeBuilder;
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import org.betterx.worlds.together.tag.v3.CommonItemTags;
import org.betterx.worlds.together.tag.v3.CommonPoiTags;
@ -257,177 +257,177 @@ public class WoodenComplexMaterial extends ComplexMaterial {
Block bark_stripped = getBlock(BLOCK_STRIPPED_BARK);
Block log = getBlock(BLOCK_LOG);
Block bark = getBlock(BLOCK_BARK);
GridRecipe.make(id, planks)
.checkConfig(config)
.setOutputCount(4)
.setList("#")
.addMaterial('#', log, bark, log_stripped, bark_stripped)
.setGroup(receipGroupPrefix + "_planks")
.build();
BCLRecipeBuilder.crafting(id, planks)
.checkConfig(config)
.setOutputCount(4)
.setList("#")
.addMaterial('#', log, bark, log_stripped, bark_stripped)
.setGroup(receipGroupPrefix + "_planks")
.build();
}));
addRecipeEntry(new RecipeEntry("stairs", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_STAIRS))
.checkConfig(config)
.setOutputCount(4)
.setShape("# ", "## ", "###")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_stairs")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_STAIRS))
.checkConfig(config)
.setOutputCount(4)
.setShape("# ", "## ", "###")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_stairs")
.build();
}));
addRecipeEntry(new RecipeEntry("slab", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_SLAB))
.checkConfig(config)
.setOutputCount(6)
.setShape("###")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_slabs")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_SLAB))
.checkConfig(config)
.setOutputCount(6)
.setShape("###")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_slabs")
.build();
}));
addRecipeEntry(new RecipeEntry("fence", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_FENCE))
.checkConfig(config)
.setOutputCount(3)
.setShape("#I#", "#I#")
.addMaterial('#', planks)
.addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_planks_fences")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_FENCE))
.checkConfig(config)
.setOutputCount(3)
.setShape("#I#", "#I#")
.addMaterial('#', planks)
.addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_planks_fences")
.build();
}));
addRecipeEntry(new RecipeEntry("gate", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_GATE))
.checkConfig(config)
.setShape("I#I", "I#I")
.addMaterial('#', planks)
.addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_planks_gates")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_GATE))
.checkConfig(config)
.setShape("I#I", "I#I")
.addMaterial('#', planks)
.addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_planks_gates")
.build();
}));
addRecipeEntry(new RecipeEntry("button", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_BUTTON))
.checkConfig(config)
.setList("#")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_buttons")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BUTTON))
.checkConfig(config)
.setList("#")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_buttons")
.build();
}));
addRecipeEntry(new RecipeEntry("pressure_plate", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_PRESSURE_PLATE))
.checkConfig(config)
.setShape("##")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_plates")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_PRESSURE_PLATE))
.checkConfig(config)
.setShape("##")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_plates")
.build();
}));
addRecipeEntry(new RecipeEntry("trapdoor", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_TRAPDOOR))
.checkConfig(config)
.setOutputCount(2)
.setShape("###", "###")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_trapdoors")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_TRAPDOOR))
.checkConfig(config)
.setOutputCount(2)
.setShape("###", "###")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_trapdoors")
.build();
}));
addRecipeEntry(new RecipeEntry("door", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_DOOR))
.checkConfig(config)
.setOutputCount(3)
.setShape("##", "##", "##")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_doors")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_DOOR))
.checkConfig(config)
.setOutputCount(3)
.setShape("##", "##", "##")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_doors")
.build();
}));
addRecipeEntry(new RecipeEntry("crafting_table", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_CRAFTING_TABLE))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_tables")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_CRAFTING_TABLE))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_tables")
.build();
}));
addRecipeEntry(new RecipeEntry("ladder", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_LADDER))
.checkConfig(config)
.setOutputCount(3)
.setShape("I I", "I#I", "I I")
.addMaterial('#', planks)
.addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_ladders")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_LADDER))
.checkConfig(config)
.setOutputCount(3)
.setShape("I I", "I#I", "I I")
.addMaterial('#', planks)
.addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_ladders")
.build();
}));
addRecipeEntry(new RecipeEntry("sign", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_SIGN))
.checkConfig(config)
.setOutputCount(3)
.setShape("###", "###", " I ")
.addMaterial('#', planks)
.addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_signs")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_SIGN))
.checkConfig(config)
.setOutputCount(3)
.setShape("###", "###", " I ")
.addMaterial('#', planks)
.addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_signs")
.build();
}));
addRecipeEntry(new RecipeEntry("chest", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_CHEST))
.checkConfig(config)
.setShape("###", "# #", "###")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_chests")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_CHEST))
.checkConfig(config)
.setShape("###", "# #", "###")
.addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_chests")
.build();
}));
addRecipeEntry(new RecipeEntry("barrel", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_BARREL))
.checkConfig(config)
.setShape("#S#", "# #", "#S#")
.addMaterial('#', planks)
.addMaterial('S', getBlock(BLOCK_SLAB))
.setGroup(receipGroupPrefix + "_barrels")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BARREL))
.checkConfig(config)
.setShape("#S#", "# #", "#S#")
.addMaterial('#', planks)
.addMaterial('S', getBlock(BLOCK_SLAB))
.setGroup(receipGroupPrefix + "_barrels")
.build();
}));
addRecipeEntry(new RecipeEntry("bookshelf", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_BOOKSHELF))
.checkConfig(config)
.setShape("###", "PPP", "###")
.addMaterial('#', planks)
.addMaterial('P', Items.BOOK)
.setGroup(receipGroupPrefix + "_bookshelves")
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BOOKSHELF))
.checkConfig(config)
.setShape("###", "PPP", "###")
.addMaterial('#', planks)
.addMaterial('P', Items.BOOK)
.setGroup(receipGroupPrefix + "_bookshelves")
.build();
}));
addRecipeEntry(new RecipeEntry("bark", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_BARK))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_LOG))
.setOutputCount(3)
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BARK))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_LOG))
.setOutputCount(3)
.build();
}));
addRecipeEntry(new RecipeEntry("log", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_LOG))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_BARK))
.setOutputCount(3)
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_LOG))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_BARK))
.setOutputCount(3)
.build();
}));
addRecipeEntry(new RecipeEntry("stripped_bark", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_STRIPPED_BARK))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_STRIPPED_LOG))
.setOutputCount(3)
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_STRIPPED_BARK))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_STRIPPED_LOG))
.setOutputCount(3)
.build();
}));
addRecipeEntry(new RecipeEntry("stripped_log", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_STRIPPED_LOG))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_STRIPPED_BARK))
.setOutputCount(3)
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_STRIPPED_LOG))
.checkConfig(config)
.setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_STRIPPED_BARK))
.setOutputCount(3)
.build();
}));
addRecipeEntry(new RecipeEntry("composter", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_COMPOSTER))
.checkConfig(config)
.setShape("# #", "# #", "###")
.addMaterial('#', getBlock(BLOCK_SLAB))
.build();
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_COMPOSTER))
.checkConfig(config)
.setShape("# #", "# #", "###")
.addMaterial('#', getBlock(BLOCK_SLAB))
.build();
}));
}
}

View file

@ -1,6 +1,7 @@
package org.betterx.bclib.items.complex;
import org.betterx.bclib.items.BaseArmorItem;
import org.betterx.bclib.recipes.BCLRecipeBuilder;
import org.betterx.bclib.recipes.GridRecipe;
import org.betterx.bclib.registry.ItemRegistry;
@ -34,9 +35,8 @@ public class EquipmentDescription<I extends Item> {
if (repairItems == null || repairItems.length == 0) return;
final ItemLike ingot = repairItems[0].getItem();
var builder = GridRecipe
.make(id, tool)
.addMaterial('#', ingot);
var builder = BCLRecipeBuilder.crafting(id, tool)
.addMaterial('#', ingot);
if (buildRecipe(tool, stick, builder)) return;
builder

View file

@ -133,27 +133,26 @@ public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCateg
private final static Builder INSTANCE = new Builder();
private static boolean exist;
protected static Builder create(ResourceLocation id, PathConfig config) {
static Builder create(ResourceLocation id, ItemLike output) {
INSTANCE.id = id;
INSTANCE.group = String.format("%s_%s", GROUP, id);
INSTANCE.primaryInput = null;
INSTANCE.secondaryInput = null;
INSTANCE.output = null;
INSTANCE.output = output;
INSTANCE.experience = 0.0F;
INSTANCE.smeltTime = 350;
exist = config.getBoolean("alloying", id.getPath(), true);
INSTANCE.count = 1;
INSTANCE.alright = RecipeHelper.exists(output);
exist = true;
return INSTANCE;
}
protected static Builder create(String modID, String id, PathConfig config) {
return create(new ResourceLocation(modID, id), config);
}
private int count = 1;
private ResourceLocation id;
private Ingredient primaryInput;
private Ingredient secondaryInput;
private ItemStack output;
private ItemLike output;
private String group;
private float experience;
private int smeltTime;
@ -162,11 +161,21 @@ public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCateg
protected Builder() {
}
public Builder checkConfig(PathConfig config) {
exist &= config.getBoolean("alloying", id.getPath(), true);
return this;
}
public Builder setGroup(String group) {
this.group = group;
return this;
}
public Builder setOutputCount(int count) {
this.count = count;
return this;
}
public Builder setPrimaryInput(ItemLike... inputs) {
for (ItemLike item : inputs) {
this.alright &= RecipeHelper.exists(item);
@ -205,13 +214,7 @@ public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCateg
return this;
}
public Builder setOutput(ItemLike output, int amount) {
this.alright &= RecipeHelper.exists(output);
this.output = new ItemStack(output, amount);
return this;
}
public Builder setExpiriense(float amount) {
public Builder setExperience(float amount) {
this.experience = amount;
return this;
}
@ -251,7 +254,15 @@ public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCateg
}
BCLRecipeManager.addRecipe(
TYPE,
new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime)
new AlloyingRecipe(
id,
group,
primaryInput,
secondaryInput,
new ItemStack(output, count),
experience,
smeltTime
)
);
}
}

View file

@ -79,11 +79,11 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
this.damage = damage;
}
public static Builder create(String id) {
static Builder create(String id) {
return create(BCLib.makeID(id));
}
public static Builder create(ResourceLocation id) {
static Builder create(ResourceLocation id) {
Builder.INSTANCE.id = id;
Builder.INSTANCE.input = null;
Builder.INSTANCE.output = null;

View file

@ -0,0 +1,36 @@
package org.betterx.bclib.recipes;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ItemLike;
public class BCLRecipeBuilder {
public static AlloyingRecipe.Builder alloying(ResourceLocation id, ItemLike output) {
return AlloyingRecipe.Builder.create(id, output);
}
public static AnvilRecipe.Builder anvil(ResourceLocation id) {
return AnvilRecipe.create(id);
}
public static BlastFurnaceRecipe blasting(ResourceLocation id, ItemLike output) {
return BlastFurnaceRecipe.make(id, output);
}
public static GridRecipe crafting(ResourceLocation id, ItemLike output) {
return BCLRecipeBuilder.crafting(
id, output);
}
public static FurnaceRecipe smelting(ResourceLocation id, ItemLike output) {
return FurnaceRecipe.make(id, output);
}
public static SmithingTableRecipe smithing(ResourceLocation id, ItemLike output) {
return SmithingTableRecipe.make(id, output);
}
public static StoneCutterRecipe stonecutting(ResourceLocation id, ItemLike output) {
return StoneCutterRecipe.make(id, output);
}
}

View file

@ -12,11 +12,11 @@ public class BlastFurnaceRecipe extends CookingRecipe<BlastFurnaceRecipe, Contai
super(id, RecipeType.BLASTING, output);
}
public static BlastFurnaceRecipe make(String modID, String name, ItemLike output) {
static BlastFurnaceRecipe make(String modID, String name, ItemLike output) {
return make(new ResourceLocation(modID, name), output);
}
public static BlastFurnaceRecipe make(ResourceLocation id, ItemLike output) {
static BlastFurnaceRecipe make(ResourceLocation id, ItemLike output) {
BlastFurnaceRecipe res = new BlastFurnaceRecipe(id, output);
res.createAdvancement(id, false);
return res;

View file

@ -10,72 +10,72 @@ import net.minecraft.world.level.block.Blocks;
public class CraftingRecipes {
public static void init() {
GridRecipe.make(BCLib.MOD_ID, "tag_smith_table", Blocks.SMITHING_TABLE)
.setShape("II", "##", "##")
.addMaterial('#', ItemTags.PLANKS)
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_cauldron", Blocks.CAULDRON)
.setShape("I I", "I I", "III")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_hopper", Blocks.HOPPER)
.setShape("I I", "ICI", " I ")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('C', CommonItemTags.CHEST)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_piston", Blocks.PISTON)
.setShape("WWW", "CIC", "CDC")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('D', Items.REDSTONE)
.addMaterial('C', Items.COBBLESTONE)
.addMaterial('W', ItemTags.PLANKS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_rail", Blocks.RAIL)
.setOutputCount(16)
.setShape("I I", "ISI", "I I")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('S', Items.STICK)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_stonecutter", Blocks.STONECUTTER)
.setShape(" I ", "SSS")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('S', Items.STONE)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_compass", Items.COMPASS)
.setShape(" I ", "IDI", " I ")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('D', Items.REDSTONE)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_bucket", Items.BUCKET)
.setShape("I I", " I ")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_minecart", Items.MINECART)
.setShape("I I", "III")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_shield", Items.SHIELD)
.setShape("WIW", "WWW", " W ")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('W', ItemTags.PLANKS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_smith_table"), Blocks.SMITHING_TABLE)
.setShape("II", "##", "##")
.addMaterial('#', ItemTags.PLANKS)
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_cauldron"), Blocks.CAULDRON)
.setShape("I I", "I I", "III")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_hopper"), Blocks.HOPPER)
.setShape("I I", "ICI", " I ")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('C', CommonItemTags.CHEST)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_piston"), Blocks.PISTON)
.setShape("WWW", "CIC", "CDC")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('D', Items.REDSTONE)
.addMaterial('C', Items.COBBLESTONE)
.addMaterial('W', ItemTags.PLANKS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_rail"), Blocks.RAIL)
.setOutputCount(16)
.setShape("I I", "ISI", "I I")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('S', Items.STICK)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_stonecutter"), Blocks.STONECUTTER)
.setShape(" I ", "SSS")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('S', Items.STONE)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_compass"), Items.COMPASS)
.setShape(" I ", "IDI", " I ")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('D', Items.REDSTONE)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_bucket"), Items.BUCKET)
.setShape("I I", " I ")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_minecart"), Items.MINECART)
.setShape("I I", "III")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_shield"), Items.SHIELD)
.setShape("WIW", "WWW", " W ")
.addMaterial('I', CommonItemTags.IRON_INGOTS)
.addMaterial('W', ItemTags.PLANKS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_shulker_box", Blocks.SHULKER_BOX)
.setShape("S", "C", "S")
.addMaterial('S', Items.SHULKER_SHELL)
.addMaterial('C', CommonItemTags.CHEST)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
BCLRecipeBuilder.crafting(BCLib.makeID("tag_shulker_box"), Blocks.SHULKER_BOX)
.setShape("S", "C", "S")
.addMaterial('S', Items.SHULKER_SHELL)
.addMaterial('C', CommonItemTags.CHEST)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
}
}

View file

@ -3,6 +3,8 @@ package org.betterx.bclib.recipes;
import org.betterx.bclib.config.PathConfig;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.*;
import net.minecraft.world.level.ItemLike;
@ -11,7 +13,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
private static final FurnaceRecipe INSTANCE = new FurnaceRecipe();
private ResourceLocation id;
private ItemLike input;
private Ingredient input;
private ItemLike output;
private boolean exist;
private String group;
@ -22,20 +24,33 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
private FurnaceRecipe() {
}
public static FurnaceRecipe make(String modID, String name, ItemLike input, ItemLike output) {
INSTANCE.id = new ResourceLocation(modID, name);
static FurnaceRecipe make(ResourceLocation id, ItemLike output) {
INSTANCE.id = id;
INSTANCE.group = "";
INSTANCE.input = input;
INSTANCE.input = null;
INSTANCE.output = output;
INSTANCE.count = 1;
INSTANCE.time = 200;
INSTANCE.xp = 0;
INSTANCE.exist = BCLRecipeManager.exists(output) && BCLRecipeManager.exists(input);
INSTANCE.exist = BCLRecipeManager.exists(output);
INSTANCE.createAdvancement(INSTANCE.id, false);
INSTANCE.unlockedBy(input);
return INSTANCE;
}
public FurnaceRecipe setInput(ItemLike input) {
exist &= BCLRecipeManager.exists(input);
this.input = Ingredient.of(input);
unlockedBy(input);
return this;
}
public FurnaceRecipe setInput(TagKey<Item> tag) {
this.input = Ingredient.of(tag);
unlockedBy(tag);
return this;
}
public FurnaceRecipe checkConfig(PathConfig config) {
exist &= config.getBoolean("furnace", id.getPath(), true);
return this;
@ -51,12 +66,12 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
return this;
}
public FurnaceRecipe setXP(float xp) {
public FurnaceRecipe setExperience(float xp) {
this.xp = xp;
return this;
}
public FurnaceRecipe setCookTime(int time) {
public FurnaceRecipe setCookingTime(int time) {
this.time = time;
return this;
}
@ -81,7 +96,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
SmeltingRecipe recipe = new SmeltingRecipe(
new ResourceLocation(id + "_smelting"),
group,
Ingredient.of(input),
input,
new ItemStack(output, count),
xp,
time
@ -93,11 +108,12 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
BlastingRecipe recipe2 = new BlastingRecipe(
new ResourceLocation(id + "_blasting"),
group,
Ingredient.of(input),
input,
new ItemStack(output, count),
xp,
time / 2
);
BCLRecipeManager.addRecipe(RecipeType.BLASTING, recipe2);
}
@ -105,7 +121,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
CampfireCookingRecipe recipe2 = new CampfireCookingRecipe(
new ResourceLocation(id + "_campfire"),
group,
Ingredient.of(input),
input,
new ItemStack(output, count),
xp,
time * 3
@ -118,7 +134,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
SmokingRecipe recipe2 = new SmokingRecipe(
new ResourceLocation(id + "_smoker"),
group,
Ingredient.of(input),
input,
new ItemStack(output, count),
xp,
time / 2

View file

@ -34,11 +34,14 @@ public class GridRecipe extends AbstractAdvancementRecipe {
private GridRecipe() {
}
public static GridRecipe make(String modID, String name, ItemLike output) {
return make(new ResourceLocation(modID, name), output);
}
public static GridRecipe make(ResourceLocation id, ItemLike output) {
/**
* Please use {@link BCLRecipeBuilder#crafting(ResourceLocation, ItemLike)} instead
*
* @param id
* @param output
* @return
*/
static GridRecipe make(ResourceLocation id, ItemLike output) {
INSTANCE.id = id;
INSTANCE.output = output;

View file

@ -1,31 +0,0 @@
package org.betterx.bclib.recipes;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.SmeltingRecipe;
import net.minecraft.world.level.ItemLike;
public class SmelterRecipe extends CookingRecipe<SmelterRecipe, Container, SmeltingRecipe> {
SmelterRecipe(
ResourceLocation id, ItemLike output
) {
super(id, RecipeType.SMELTING, output);
}
public static SmelterRecipe make(String modID, String name, ItemLike output) {
return make(new ResourceLocation(modID, name), output);
}
public static SmelterRecipe make(ResourceLocation id, ItemLike output) {
SmelterRecipe res = new SmelterRecipe(id, output);
res.createAdvancement(id, false);
return res;
}
@Override
protected SmeltingRecipe buildRecipe() {
return new SmeltingRecipe(id, group, input, new ItemStack(output, count), experience, cookingTime);
}
}

View file

@ -19,11 +19,8 @@ public class SmithingTableRecipe extends AbstractSimpleRecipe<SmithingTableRecip
super(id, RecipeType.SMITHING, output);
}
public static SmithingTableRecipe make(String modID, String name, ItemLike output) {
return make(new ResourceLocation(modID, name), output);
}
public static SmithingTableRecipe make(ResourceLocation id, ItemLike output) {
static SmithingTableRecipe make(ResourceLocation id, ItemLike output) {
SmithingTableRecipe res = new SmithingTableRecipe(id, output);
res.createAdvancement(id, false);
return res;

View file

@ -14,11 +14,7 @@ public class StoneCutterRecipe extends AbstractSimpleRecipe<StoneCutterRecipe, C
super(id, RecipeType.STONECUTTING, "stonecutting", output);
}
public static StoneCutterRecipe make(String modID, String name, ItemLike output) {
return make(new ResourceLocation(modID, name), output);
}
public static StoneCutterRecipe make(ResourceLocation id, ItemLike output) {
static StoneCutterRecipe make(ResourceLocation id, ItemLike output) {
StoneCutterRecipe res = new StoneCutterRecipe(id, output);
res.createAdvancement(id, false);
return res;