Smithing Table recipe migration

This commit is contained in:
paulevsGitch 2021-06-17 20:40:31 +03:00
parent a72e8e27ec
commit 7d76f80d94
3 changed files with 117 additions and 200 deletions

View file

@ -30,6 +30,7 @@ import ru.bclib.items.tool.BaseShovelItem;
import ru.bclib.items.tool.BaseSwordItem;
import ru.bclib.recipes.FurnaceRecipe;
import ru.bclib.recipes.GridRecipe;
import ru.bclib.recipes.SmithingTableRecipe;
import ru.bclib.util.TagHelper;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.BulbVineLanternBlock;
@ -42,7 +43,6 @@ import ru.betterend.item.EndArmorItem;
import ru.betterend.item.tool.EndHammerItem;
import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.recipe.builders.AnvilRecipe;
import ru.betterend.recipe.builders.SmithingTableRecipe;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import ru.betterend.registry.EndTags;
@ -195,13 +195,13 @@ public class MetalMaterial {
AnvilRecipe.Builder.create(name + "_forged_plate").setInput(ingot).setOutput(forgedPlate).setAnvilLevel(level).setToolLevel(level).setDamage(level).build();
// Tools from parts
SmithingTableRecipe.create(name + "_hammer").setResult(hammer).setBase(block).setAddition(Items.STICK).build();
SmithingTableRecipe.create(name + "_axe").setResult(axe).setBase(axeHead).setAddition(Items.STICK).build();
SmithingTableRecipe.create(name + "_pickaxe").setResult(pickaxe).setBase(pickaxeHead).setAddition(Items.STICK).build();
SmithingTableRecipe.create(name + "_hoe").setResult(hoe).setBase(hoeHead).setAddition(Items.STICK).build();
SmithingTableRecipe.create(name + "_sword_handle").setResult(swordHandle).setBase(ingot).setAddition(Items.STICK).build();
SmithingTableRecipe.create(name + "_sword").setResult(sword).setBase(swordBlade).setAddition(swordHandle).build();
SmithingTableRecipe.create(name + "_shovel").setResult(shovel).setBase(shovelHead).setAddition(Items.STICK).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_hammer").checkConfig(Configs.RECIPE_CONFIG).setResult(hammer).setBase(block).setAddition(Items.STICK).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_axe").checkConfig(Configs.RECIPE_CONFIG).setResult(axe).setBase(axeHead).setAddition(Items.STICK).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_pickaxe").checkConfig(Configs.RECIPE_CONFIG).setResult(pickaxe).setBase(pickaxeHead).setAddition(Items.STICK).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_hoe").checkConfig(Configs.RECIPE_CONFIG).setResult(hoe).setBase(hoeHead).setAddition(Items.STICK).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_sword_handle").checkConfig(Configs.RECIPE_CONFIG).setResult(swordHandle).setBase(ingot).setAddition(Items.STICK).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_sword").checkConfig(Configs.RECIPE_CONFIG).setResult(sword).setBase(swordBlade).setAddition(swordHandle).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_shovel").checkConfig(Configs.RECIPE_CONFIG).setResult(shovel).setBase(shovelHead).setAddition(Items.STICK).build();
// Armor crafting
GridRecipe.make(BetterEnd.MOD_ID, name + "_helmet", helmet).checkConfig(Configs.RECIPE_CONFIG).setShape("###", "# #").addMaterial('#', forgedPlate).setGroup("end_metal_helmets").build();

View file

@ -1,92 +1,109 @@
package ru.betterend.recipe;
import net.minecraft.world.item.Items;
import ru.betterend.recipe.builders.SmithingTableRecipe;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
public class SmithingRecipes {
public static void register() {
SmithingTableRecipe.create("aeternium_sword_handle")
.setResult(EndItems.AETERNIUM_SWORD_HANDLE)
.setBase(EndBlocks.TERMINITE.ingot)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create("aeternium_sword")
.setResult(EndItems.AETERNIUM_SWORD)
.setBase(EndItems.AETERNIUM_SWORD_BLADE)
.setAddition(EndItems.AETERNIUM_SWORD_HANDLE)
.build();
SmithingTableRecipe.create("aeternium_pickaxe")
.setResult(EndItems.AETERNIUM_PICKAXE)
.setBase(EndItems.AETERNIUM_PICKAXE_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create("aeternium_axe")
.setResult(EndItems.AETERNIUM_AXE)
.setBase(EndItems.AETERNIUM_AXE_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create("aeternium_shovel")
.setResult(EndItems.AETERNIUM_SHOVEL)
.setBase(EndItems.AETERNIUM_SHOVEL_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create("aeternium_hoe")
.setResult(EndItems.AETERNIUM_HOE)
.setBase(EndItems.AETERNIUM_HOE_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create("aeternium_hammer")
.setResult(EndItems.AETERNIUM_HAMMER)
.setBase(EndItems.AETERNIUM_HAMMER_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create("netherite_hammer")
.setResult(EndItems.NETHERITE_HAMMER)
.setBase(EndItems.DIAMOND_HAMMER)
.setAddition(Items.NETHERITE_INGOT)
.build();
SmithingTableRecipe.create("aeternium_helmet")
.setResult(EndItems.AETERNIUM_HELMET)
.setBase(EndBlocks.TERMINITE.helmet)
.setAddition(EndItems.AETERNIUM_FORGED_PLATE)
.build();
SmithingTableRecipe.create("aeternium_chestplate")
.setResult(EndItems.AETERNIUM_CHESTPLATE)
.setBase(EndBlocks.TERMINITE.chestplate)
.setAddition(EndItems.AETERNIUM_FORGED_PLATE)
.build();
SmithingTableRecipe.create("aeternium_leggings")
.setResult(EndItems.AETERNIUM_LEGGINGS)
.setBase(EndBlocks.TERMINITE.leggings)
.setAddition(EndItems.AETERNIUM_FORGED_PLATE)
.build();
SmithingTableRecipe.create("aeternium_boots")
.setResult(EndItems.AETERNIUM_BOOTS)
.setBase(EndBlocks.TERMINITE.boots)
.setAddition(EndItems.AETERNIUM_FORGED_PLATE)
.build();
SmithingTableRecipe.create("thallasium_anvil_updrade")
.setResult(EndBlocks.TERMINITE.anvilBlock)
.setBase(EndBlocks.THALLASIUM.anvilBlock)
.setAddition(EndBlocks.TERMINITE.block)
.build();
SmithingTableRecipe.create("terminite_anvil_updrade")
.setResult(EndBlocks.AETERNIUM_ANVIL)
.setBase(EndBlocks.TERMINITE.anvilBlock)
.setAddition(EndItems.AETERNIUM_INGOT)
.build();
SmithingTableRecipe.create("armored_elytra")
.setResult(EndItems.ARMORED_ELYTRA)
.setBase(Items.ELYTRA)
.setAddition(EndItems.AETERNIUM_INGOT)
.build();
}
}
package ru.betterend.recipe;
import net.minecraft.world.item.Items;
import ru.bclib.recipes.SmithingTableRecipe;
import ru.betterend.BetterEnd;
import ru.betterend.config.Configs;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
public class SmithingRecipes {
public static void register() {
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_sword_handle")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_SWORD_HANDLE)
.setBase(EndBlocks.TERMINITE.ingot)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_sword")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_SWORD)
.setBase(EndItems.AETERNIUM_SWORD_BLADE)
.setAddition(EndItems.AETERNIUM_SWORD_HANDLE)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_pickaxe")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_PICKAXE)
.setBase(EndItems.AETERNIUM_PICKAXE_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_axe")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_AXE)
.setBase(EndItems.AETERNIUM_AXE_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_shovel")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_SHOVEL)
.setBase(EndItems.AETERNIUM_SHOVEL_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_hoe")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_HOE)
.setBase(EndItems.AETERNIUM_HOE_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_hammer")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_HAMMER)
.setBase(EndItems.AETERNIUM_HAMMER_HEAD)
.setAddition(EndItems.LEATHER_WRAPPED_STICK)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "netherite_hammer")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.NETHERITE_HAMMER)
.setBase(EndItems.DIAMOND_HAMMER)
.setAddition(Items.NETHERITE_INGOT)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_helmet")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_HELMET)
.setBase(EndBlocks.TERMINITE.helmet)
.setAddition(EndItems.AETERNIUM_FORGED_PLATE)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_chestplate")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_CHESTPLATE)
.setBase(EndBlocks.TERMINITE.chestplate)
.setAddition(EndItems.AETERNIUM_FORGED_PLATE)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_leggings")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_LEGGINGS)
.setBase(EndBlocks.TERMINITE.leggings)
.setAddition(EndItems.AETERNIUM_FORGED_PLATE)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "aeternium_boots")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.AETERNIUM_BOOTS)
.setBase(EndBlocks.TERMINITE.boots)
.setAddition(EndItems.AETERNIUM_FORGED_PLATE)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "thallasium_anvil_updrade")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndBlocks.TERMINITE.anvilBlock)
.setBase(EndBlocks.THALLASIUM.anvilBlock)
.setAddition(EndBlocks.TERMINITE.block)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "terminite_anvil_updrade")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndBlocks.AETERNIUM_ANVIL)
.setBase(EndBlocks.TERMINITE.anvilBlock)
.setAddition(EndItems.AETERNIUM_INGOT)
.build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, "armored_elytra")
.checkConfig(Configs.RECIPE_CONFIG)
.setResult(EndItems.ARMORED_ELYTRA)
.setBase(Items.ELYTRA)
.setAddition(EndItems.AETERNIUM_INGOT)
.build();
}
}

View file

@ -1,100 +0,0 @@
package ru.betterend.recipe.builders;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.UpgradeRecipe;
import net.minecraft.world.level.ItemLike;
import ru.betterend.BetterEnd;
import ru.betterend.config.Configs;
import ru.betterend.recipe.EndRecipeManager;
import ru.betterend.util.RecipeHelper;
public class SmithingTableRecipe {
private final static SmithingTableRecipe BUILDER = new SmithingTableRecipe();
private final static RecipeType<UpgradeRecipe> TYPE = RecipeType.SMITHING;
public static SmithingTableRecipe create(String name) {
return create(BetterEnd.makeID(name));
}
public static SmithingTableRecipe create(ResourceLocation id) {
BUILDER.id = id;
BUILDER.base = null;
BUILDER.addition = null;
BUILDER.result = null;
BUILDER.alright = true;
return BUILDER;
}
private ResourceLocation id;
private Ingredient base;
private Ingredient addition;
private ItemStack result;
private boolean alright;
private SmithingTableRecipe() {}
public SmithingTableRecipe setResult(ItemLike item) {
return this.setResult(item, 1);
}
public SmithingTableRecipe setResult(ItemLike item, int count) {
this.alright &= RecipeHelper.exists(item);
this.result = new ItemStack(item, count);
return this;
}
public SmithingTableRecipe setBase(ItemLike... items) {
this.alright &= RecipeHelper.exists(items);
this.base = Ingredient.of(items);
return this;
}
public SmithingTableRecipe setBase(Tag<Item> tag) {
this.base = (Ingredient.of(tag));
return this;
}
public SmithingTableRecipe setAddition(ItemLike... items) {
this.alright &= RecipeHelper.exists(items);
this.addition = Ingredient.of(items);
return this;
}
public SmithingTableRecipe setAddition(Tag<Item> tag) {
this.addition = (Ingredient.of(tag));
return this;
}
public void build() {
if (Configs.RECIPE_CONFIG.getBoolean("smithing", id.getPath(), true)) {
if (base == null) {
BetterEnd.LOGGER.warning("Base input for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
return;
}
if (addition == null) {
BetterEnd.LOGGER.warning("Addition input for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
return;
}
if(result == null) {
BetterEnd.LOGGER.warning("Result for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
return;
}
if (EndRecipeManager.getRecipe(TYPE, id) != null) {
BetterEnd.LOGGER.warning("Can't add Smithing recipe! Id {} already exists!", id);
return;
}
if (!alright) {
BetterEnd.LOGGER.debug("Can't add Smithing recipe {}! Ingeredients or output not exists.", id);
return;
}
EndRecipeManager.addRecipe(TYPE, new UpgradeRecipe(id, base, addition, result));
}
}
}