[Change] Moved Alloying Recipes to BCLib
This commit is contained in:
parent
34d55debce
commit
e45eade668
19 changed files with 72 additions and 471 deletions
|
@ -66,7 +66,7 @@ dependencies {
|
||||||
//needed for trinkets, otherwise BetterEnd would require users to install trinkets
|
//needed for trinkets, otherwise BetterEnd would require users to install trinkets
|
||||||
modApi "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}"
|
modApi "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}"
|
||||||
modCompileOnly "dev.emi:trinkets:${project.trinkets_version}"
|
modCompileOnly "dev.emi:trinkets:${project.trinkets_version}"
|
||||||
modCompileOnly "dev.emi:emi:${emi_version}"
|
modImplementation "dev.emi:emi:${emi_version}"
|
||||||
//modRuntimeOnly "dev.emi:emi:${emi_version}"
|
//modRuntimeOnly "dev.emi:emi:${emi_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.betterx.betterend.blocks;
|
package org.betterx.betterend.blocks;
|
||||||
|
|
||||||
import org.betterx.bclib.blocks.BaseBlockWithEntity;
|
import org.betterx.bclib.blocks.BaseBlockWithEntity;
|
||||||
|
import org.betterx.bclib.interfaces.AlloyingRecipeWorkstation;
|
||||||
import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||||
import org.betterx.betterend.registry.EndBlockEntities;
|
import org.betterx.betterend.registry.EndBlockEntities;
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ import com.google.common.collect.Lists;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class EndStoneSmelter extends BaseBlockWithEntity {
|
public class EndStoneSmelter extends BaseBlockWithEntity implements AlloyingRecipeWorkstation {
|
||||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||||
public static final BooleanProperty LIT = BlockStateProperties.LIT;
|
public static final BooleanProperty LIT = BlockStateProperties.LIT;
|
||||||
public static final String ID = "end_stone_smelter";
|
public static final String ID = "end_stone_smelter";
|
||||||
|
|
|
@ -16,8 +16,4 @@ public class EndAnvilBlock extends LeveledAnvilBlock {
|
||||||
super(color, level);
|
super(color, level);
|
||||||
this.metalMaterial = metalMaterial;
|
this.metalMaterial = metalMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCraftingLevel() {
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package org.betterx.betterend.blocks.entities;
|
package org.betterx.betterend.blocks.entities;
|
||||||
|
|
||||||
|
import org.betterx.bclib.recipes.AlloyingRecipe;
|
||||||
import org.betterx.betterend.BetterEnd;
|
import org.betterx.betterend.BetterEnd;
|
||||||
import org.betterx.betterend.blocks.EndStoneSmelter;
|
import org.betterx.betterend.blocks.EndStoneSmelter;
|
||||||
import org.betterx.betterend.client.gui.EndStoneSmelterMenu;
|
import org.betterx.betterend.client.gui.EndStoneSmelterMenu;
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
|
||||||
import org.betterx.betterend.registry.EndBlockEntities;
|
import org.betterx.betterend.registry.EndBlockEntities;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package org.betterx.betterend.client.gui;
|
package org.betterx.betterend.client.gui;
|
||||||
|
|
||||||
|
import org.betterx.bclib.recipes.AlloyingRecipe;
|
||||||
import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||||
import org.betterx.betterend.client.gui.slot.SmelterFuelSlot;
|
import org.betterx.betterend.client.gui.slot.SmelterFuelSlot;
|
||||||
import org.betterx.betterend.client.gui.slot.SmelterOutputSlot;
|
import org.betterx.betterend.client.gui.slot.SmelterOutputSlot;
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
|
||||||
import org.betterx.betterend.registry.EndMenuTypes;
|
import org.betterx.betterend.registry.EndMenuTypes;
|
||||||
|
|
||||||
import net.minecraft.world.Container;
|
import net.minecraft.world.Container;
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.betterx.betterend.config.Configs;
|
||||||
import org.betterx.betterend.item.EndArmorItem;
|
import org.betterx.betterend.item.EndArmorItem;
|
||||||
import org.betterx.betterend.item.tool.EndHammerItem;
|
import org.betterx.betterend.item.tool.EndHammerItem;
|
||||||
import org.betterx.betterend.item.tool.EndPickaxe;
|
import org.betterx.betterend.item.tool.EndPickaxe;
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
import org.betterx.betterend.recipe.builders.AlloyingRecipeBuilder;
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
import org.betterx.betterend.registry.EndItems;
|
import org.betterx.betterend.registry.EndItems;
|
||||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||||
|
@ -231,11 +231,11 @@ public class MetalMaterial {
|
||||||
.checkConfig(Configs.RECIPE_CONFIG)
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
.setGroup("end_ingot")
|
.setGroup("end_ingot")
|
||||||
.buildWithBlasting();
|
.buildWithBlasting();
|
||||||
AlloyingRecipe.Builder.create(name + "_ingot_alloy")
|
AlloyingRecipeBuilder.create(name + "_ingot_alloy")
|
||||||
.setInput(alloyingOre, alloyingOre)
|
.setInput(alloyingOre, alloyingOre)
|
||||||
.setOutput(ingot, 3)
|
.setOutput(ingot, 3)
|
||||||
.setExpiriense(2.1F)
|
.setExpiriense(2.1F)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basic recipes
|
// Basic recipes
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
package org.betterx.betterend.integration.emi;
|
|
||||||
|
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
import dev.emi.emi.api.recipe.EmiRecipe;
|
|
||||||
import dev.emi.emi.api.recipe.EmiRecipeCategory;
|
|
||||||
import dev.emi.emi.api.render.EmiTexture;
|
|
||||||
import dev.emi.emi.api.stack.EmiIngredient;
|
|
||||||
import dev.emi.emi.api.stack.EmiStack;
|
|
||||||
import dev.emi.emi.api.widget.WidgetHolder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class EMIAlloyingRecipe implements EmiRecipe {
|
|
||||||
private final ResourceLocation id;
|
|
||||||
private final List<EmiIngredient> input;
|
|
||||||
private final List<EmiStack> output;
|
|
||||||
|
|
||||||
public EMIAlloyingRecipe(AlloyingRecipe recipe) {
|
|
||||||
this.id = recipe.getId();
|
|
||||||
this.input = List.of(
|
|
||||||
EmiIngredient.of(recipe.getIngredients().get(0)),
|
|
||||||
EmiIngredient.of(recipe.getIngredients().get(1))
|
|
||||||
);
|
|
||||||
this.output = List.of(EmiStack.of(recipe.getResultItem()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EmiRecipeCategory getCategory() {
|
|
||||||
return EMIPlugin.END_SMELTER_CATEGORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<EmiIngredient> getInputs() {
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<EmiStack> getOutputs() {
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDisplayWidth() {
|
|
||||||
return 76;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDisplayHeight() {
|
|
||||||
return 18;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addWidgets(WidgetHolder widgets) {
|
|
||||||
// Add an arrow texture to indicate processing
|
|
||||||
widgets.addTexture(EmiTexture.EMPTY_ARROW, 46, 1);
|
|
||||||
|
|
||||||
// Adds an input slot on the left
|
|
||||||
widgets.addSlot(input.get(0), 0, 0);
|
|
||||||
widgets.addSlot(input.get(1), 20, 0);
|
|
||||||
|
|
||||||
// Adds an output slot on the right
|
|
||||||
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context
|
|
||||||
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more
|
|
||||||
widgets.addSlot(output.get(0), 58, 0).recipeContext(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +1,10 @@
|
||||||
package org.betterx.betterend.integration.emi;
|
package org.betterx.betterend.integration.emi;
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
|
||||||
import org.betterx.betterend.BetterEnd;
|
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeManager;
|
|
||||||
|
|
||||||
import dev.emi.emi.api.EmiPlugin;
|
|
||||||
import dev.emi.emi.api.EmiRegistry;
|
import dev.emi.emi.api.EmiRegistry;
|
||||||
import dev.emi.emi.api.recipe.EmiRecipeCategory;
|
|
||||||
import dev.emi.emi.api.stack.EmiStack;
|
|
||||||
|
|
||||||
public class EMIPlugin implements EmiPlugin {
|
|
||||||
public static final ResourceLocation MY_SPRITE_SHEET = BetterEnd.makeID(
|
|
||||||
"textures/gui/emi_simplified_textures.png"
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final EmiStack END_SMELTER_WORKSTATION = EmiStack.of(EndBlocks.END_STONE_SMELTER);
|
|
||||||
public static final EmiRecipeCategory END_SMELTER_CATEGORY = new EmiRecipeCategory(
|
|
||||||
BCLib.makeID("end_stone_smelter"),
|
|
||||||
END_SMELTER_WORKSTATION//,
|
|
||||||
//new EmiTexture(MY_SPRITE_SHEET, 0, 0, 16, 16)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
public class EMIPlugin implements dev.emi.emi.api.EmiPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void register(EmiRegistry emiRegistry) {
|
public void register(EmiRegistry emiRegistry) {
|
||||||
emiRegistry.addCategory(END_SMELTER_CATEGORY);
|
|
||||||
|
|
||||||
// Add all the workstations your category uses
|
|
||||||
emiRegistry.addWorkstation(END_SMELTER_CATEGORY, END_SMELTER_WORKSTATION);
|
|
||||||
|
|
||||||
RecipeManager manager = emiRegistry.getRecipeManager();
|
|
||||||
for (AlloyingRecipe recipe : manager.getAllRecipesFor(AlloyingRecipe.TYPE)) {
|
|
||||||
emiRegistry.addRecipe(new EMIAlloyingRecipe(recipe));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.betterx.betterend.integration.jei;
|
package org.betterx.betterend.integration.jei;
|
||||||
|
|
||||||
|
import org.betterx.bclib.recipes.AlloyingRecipe;
|
||||||
import org.betterx.betterend.BetterEnd;
|
import org.betterx.betterend.BetterEnd;
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package org.betterx.betterend.integration.jei;
|
package org.betterx.betterend.integration.jei;
|
||||||
|
|
||||||
|
import org.betterx.bclib.recipes.AlloyingRecipe;
|
||||||
import org.betterx.betterend.BetterEnd;
|
import org.betterx.betterend.BetterEnd;
|
||||||
import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
import org.betterx.ui.layout.values.Rectangle;
|
import org.betterx.ui.layout.values.Rectangle;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.betterx.betterend.integration.jei;
|
package org.betterx.betterend.integration.jei;
|
||||||
|
|
||||||
|
import org.betterx.bclib.recipes.AlloyingRecipe;
|
||||||
import org.betterx.betterend.BetterEnd;
|
import org.betterx.betterend.BetterEnd;
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.betterx.betterend.integration.rei;
|
package org.betterx.betterend.integration.rei;
|
||||||
|
|
||||||
|
import org.betterx.bclib.recipes.AlloyingRecipe;
|
||||||
import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package org.betterx.betterend.integration.rei;
|
package org.betterx.betterend.integration.rei;
|
||||||
|
|
||||||
import org.betterx.bclib.blocks.BaseFurnaceBlock;
|
import org.betterx.bclib.blocks.BaseFurnaceBlock;
|
||||||
|
import org.betterx.bclib.recipes.AlloyingRecipe;
|
||||||
import org.betterx.bclib.recipes.AnvilRecipe;
|
import org.betterx.bclib.recipes.AnvilRecipe;
|
||||||
import org.betterx.betterend.BetterEnd;
|
import org.betterx.betterend.BetterEnd;
|
||||||
import org.betterx.betterend.blocks.basis.EndAnvilBlock;
|
import org.betterx.betterend.blocks.basis.EndAnvilBlock;
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
|
||||||
import org.betterx.betterend.recipe.builders.InfusionRecipe;
|
import org.betterx.betterend.recipe.builders.InfusionRecipe;
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.betterx.betterend.recipe;
|
package org.betterx.betterend.recipe;
|
||||||
|
|
||||||
import org.betterx.betterend.recipe.builders.AlloyingRecipe;
|
import org.betterx.betterend.recipe.builders.AlloyingRecipeBuilder;
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
import org.betterx.betterend.registry.EndItems;
|
import org.betterx.betterend.registry.EndItems;
|
||||||
import org.betterx.betterend.registry.EndTags;
|
import org.betterx.betterend.registry.EndTags;
|
||||||
|
@ -10,44 +10,44 @@ import net.minecraft.world.level.block.Blocks;
|
||||||
|
|
||||||
public class AlloyingRecipes {
|
public class AlloyingRecipes {
|
||||||
public static void register() {
|
public static void register() {
|
||||||
AlloyingRecipe.Builder.create("additional_iron")
|
AlloyingRecipeBuilder.create("additional_iron")
|
||||||
.setInput(EndTags.ALLOYING_IRON, EndTags.ALLOYING_IRON)
|
.setInput(EndTags.ALLOYING_IRON, EndTags.ALLOYING_IRON)
|
||||||
.setOutput(Items.IRON_INGOT, 3)
|
.setOutput(Items.IRON_INGOT, 3)
|
||||||
.setExpiriense(2.1F)
|
.setExpiriense(2.1F)
|
||||||
.build();
|
.build();
|
||||||
AlloyingRecipe.Builder.create("additional_gold")
|
AlloyingRecipeBuilder.create("additional_gold")
|
||||||
.setInput(EndTags.ALLOYING_GOLD, EndTags.ALLOYING_GOLD)
|
.setInput(EndTags.ALLOYING_GOLD, EndTags.ALLOYING_GOLD)
|
||||||
.setOutput(Items.GOLD_INGOT, 3)
|
.setOutput(Items.GOLD_INGOT, 3)
|
||||||
.setExpiriense(3F)
|
.setExpiriense(3F)
|
||||||
.build();
|
.build();
|
||||||
AlloyingRecipe.Builder.create("additional_copper")
|
AlloyingRecipeBuilder.create("additional_copper")
|
||||||
.setInput(EndTags.ALLOYING_COPPER, EndTags.ALLOYING_COPPER)
|
.setInput(EndTags.ALLOYING_COPPER, EndTags.ALLOYING_COPPER)
|
||||||
.setOutput(Items.COPPER_INGOT, 3)
|
.setOutput(Items.COPPER_INGOT, 3)
|
||||||
.setExpiriense(3F)
|
.setExpiriense(3F)
|
||||||
.build();
|
.build();
|
||||||
AlloyingRecipe.Builder.create("additional_netherite")
|
AlloyingRecipeBuilder.create("additional_netherite")
|
||||||
.setInput(Blocks.ANCIENT_DEBRIS, Blocks.ANCIENT_DEBRIS)
|
.setInput(Blocks.ANCIENT_DEBRIS, Blocks.ANCIENT_DEBRIS)
|
||||||
.setOutput(Items.NETHERITE_SCRAP, 3)
|
.setOutput(Items.NETHERITE_SCRAP, 3)
|
||||||
.setExpiriense(6F)
|
.setExpiriense(6F)
|
||||||
.setSmeltTime(1000)
|
.setSmeltTime(1000)
|
||||||
.build();
|
.build();
|
||||||
AlloyingRecipe.Builder.create("terminite_ingot")
|
AlloyingRecipeBuilder.create("terminite_ingot")
|
||||||
.setInput(Items.IRON_INGOT, EndItems.ENDER_DUST)
|
.setInput(Items.IRON_INGOT, EndItems.ENDER_DUST)
|
||||||
.setOutput(EndBlocks.TERMINITE.ingot, 1)
|
.setOutput(EndBlocks.TERMINITE.ingot, 1)
|
||||||
.setExpiriense(2.5F)
|
.setExpiriense(2.5F)
|
||||||
.setSmeltTime(450)
|
.setSmeltTime(450)
|
||||||
.build();
|
.build();
|
||||||
AlloyingRecipe.Builder.create("aeternium_ingot")
|
AlloyingRecipeBuilder.create("aeternium_ingot")
|
||||||
.setInput(EndBlocks.TERMINITE.ingot, Items.NETHERITE_INGOT)
|
.setInput(EndBlocks.TERMINITE.ingot, Items.NETHERITE_INGOT)
|
||||||
.setOutput(EndItems.AETERNIUM_INGOT, 1)
|
.setOutput(EndItems.AETERNIUM_INGOT, 1)
|
||||||
.setExpiriense(4.5F)
|
.setExpiriense(4.5F)
|
||||||
.setSmeltTime(850)
|
.setSmeltTime(850)
|
||||||
.build();
|
.build();
|
||||||
AlloyingRecipe.Builder.create("terminite_ingot_thallasium")
|
AlloyingRecipeBuilder.create("terminite_ingot_thallasium")
|
||||||
.setInput(EndBlocks.THALLASIUM.ingot, EndItems.ENDER_DUST)
|
.setInput(EndBlocks.THALLASIUM.ingot, EndItems.ENDER_DUST)
|
||||||
.setOutput(EndBlocks.TERMINITE.ingot, 1)
|
.setOutput(EndBlocks.TERMINITE.ingot, 1)
|
||||||
.setExpiriense(2.5F)
|
.setExpiriense(2.5F)
|
||||||
.setSmeltTime(450)
|
.setSmeltTime(450)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,301 +0,0 @@
|
||||||
package org.betterx.betterend.recipe.builders;
|
|
||||||
|
|
||||||
import org.betterx.bclib.interfaces.UnknownReceipBookCategory;
|
|
||||||
import org.betterx.bclib.recipes.BCLRecipeManager;
|
|
||||||
import org.betterx.bclib.util.ItemUtil;
|
|
||||||
import org.betterx.bclib.util.RecipeHelper;
|
|
||||||
import org.betterx.betterend.BetterEnd;
|
|
||||||
import org.betterx.betterend.config.Configs;
|
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
|
||||||
|
|
||||||
import net.minecraft.core.NonNullList;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.util.GsonHelper;
|
|
||||||
import net.minecraft.world.Container;
|
|
||||||
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.Recipe;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
|
||||||
import net.minecraft.world.level.ItemLike;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCategory {
|
|
||||||
public final static String GROUP = "alloying";
|
|
||||||
public final static RecipeType<AlloyingRecipe> TYPE = BCLRecipeManager.registerType(BetterEnd.MOD_ID, GROUP);
|
|
||||||
public final static Serializer SERIALIZER = BCLRecipeManager.registerSerializer(
|
|
||||||
BetterEnd.MOD_ID,
|
|
||||||
GROUP,
|
|
||||||
new Serializer()
|
|
||||||
);
|
|
||||||
|
|
||||||
protected final RecipeType<?> type;
|
|
||||||
protected final ResourceLocation id;
|
|
||||||
protected final Ingredient primaryInput;
|
|
||||||
protected final Ingredient secondaryInput;
|
|
||||||
protected final ItemStack output;
|
|
||||||
protected final String group;
|
|
||||||
protected final float experience;
|
|
||||||
protected final int smeltTime;
|
|
||||||
|
|
||||||
public AlloyingRecipe(
|
|
||||||
ResourceLocation id,
|
|
||||||
String group,
|
|
||||||
Ingredient primaryInput,
|
|
||||||
Ingredient secondaryInput,
|
|
||||||
ItemStack output,
|
|
||||||
float experience,
|
|
||||||
int smeltTime
|
|
||||||
) {
|
|
||||||
this.group = group;
|
|
||||||
this.id = id;
|
|
||||||
this.primaryInput = primaryInput;
|
|
||||||
this.secondaryInput = secondaryInput;
|
|
||||||
this.output = output;
|
|
||||||
this.experience = experience;
|
|
||||||
this.smeltTime = smeltTime;
|
|
||||||
this.type = TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getExperience() {
|
|
||||||
return this.experience;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSmeltTime() {
|
|
||||||
return this.smeltTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NonNullList<Ingredient> getIngredients() {
|
|
||||||
NonNullList<Ingredient> defaultedList = NonNullList.create();
|
|
||||||
defaultedList.add(primaryInput);
|
|
||||||
defaultedList.add(secondaryInput);
|
|
||||||
|
|
||||||
return defaultedList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(Container inv, Level world) {
|
|
||||||
return this.primaryInput.test(inv.getItem(0)) && this.secondaryInput.test(inv.getItem(1)) || this.primaryInput.test(
|
|
||||||
inv.getItem(1)) && this.secondaryInput.test(inv.getItem(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack assemble(Container inv) {
|
|
||||||
return this.output.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canCraftInDimensions(int width, int height) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getResultItem() {
|
|
||||||
return this.output;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecipeSerializer<?> getSerializer() {
|
|
||||||
return SERIALIZER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecipeType<?> getType() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public String getGroup() {
|
|
||||||
return this.group;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public ItemStack getToastSymbol() {
|
|
||||||
return new ItemStack(EndBlocks.END_STONE_SMELTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
private final static Builder INSTANCE = new Builder();
|
|
||||||
private static boolean exist;
|
|
||||||
|
|
||||||
public static Builder create(ResourceLocation id) {
|
|
||||||
INSTANCE.id = id;
|
|
||||||
INSTANCE.group = String.format("%s_%s", GROUP, id);
|
|
||||||
INSTANCE.primaryInput = null;
|
|
||||||
INSTANCE.secondaryInput = null;
|
|
||||||
INSTANCE.output = null;
|
|
||||||
INSTANCE.experience = 0.0F;
|
|
||||||
INSTANCE.smeltTime = 350;
|
|
||||||
exist = Configs.RECIPE_CONFIG.getBoolean("alloying", id.getPath(), true);
|
|
||||||
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder create(String id) {
|
|
||||||
return create(BetterEnd.makeID(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResourceLocation id;
|
|
||||||
private Ingredient primaryInput;
|
|
||||||
private Ingredient secondaryInput;
|
|
||||||
private ItemStack output;
|
|
||||||
private String group;
|
|
||||||
private float experience;
|
|
||||||
private int smeltTime;
|
|
||||||
private boolean alright = true;
|
|
||||||
|
|
||||||
private Builder() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setGroup(String group) {
|
|
||||||
this.group = group;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setPrimaryInput(ItemLike... inputs) {
|
|
||||||
for (ItemLike item : inputs) {
|
|
||||||
this.alright &= RecipeHelper.exists(item);
|
|
||||||
}
|
|
||||||
this.primaryInput = Ingredient.of(inputs);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setSecondaryInput(ItemLike... inputs) {
|
|
||||||
for (ItemLike item : inputs) {
|
|
||||||
this.alright &= RecipeHelper.exists(item);
|
|
||||||
}
|
|
||||||
this.secondaryInput = Ingredient.of(inputs);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setPrimaryInput(TagKey<Item> input) {
|
|
||||||
this.primaryInput = Ingredient.of(input);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setSecondaryInput(TagKey<Item> input) {
|
|
||||||
this.secondaryInput = Ingredient.of(input);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setInput(ItemLike primaryInput, ItemLike secondaryInput) {
|
|
||||||
this.setPrimaryInput(primaryInput);
|
|
||||||
this.setSecondaryInput(secondaryInput);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setInput(TagKey<Item> primaryInput, TagKey<Item> secondaryInput) {
|
|
||||||
this.setPrimaryInput(primaryInput);
|
|
||||||
this.setSecondaryInput(secondaryInput);
|
|
||||||
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) {
|
|
||||||
this.experience = amount;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setSmeltTime(int time) {
|
|
||||||
this.smeltTime = time;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void build() {
|
|
||||||
if (exist) {
|
|
||||||
if (primaryInput == null) {
|
|
||||||
BetterEnd.LOGGER.warning(
|
|
||||||
"Primary input for Alloying recipe can't be 'null', recipe {} will be ignored!",
|
|
||||||
id
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (secondaryInput == null) {
|
|
||||||
BetterEnd.LOGGER.warning(
|
|
||||||
"Secondary input for Alloying can't be 'null', recipe {} will be ignored!",
|
|
||||||
id
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (output == null) {
|
|
||||||
BetterEnd.LOGGER.warning("Output for Alloying can't be 'null', recipe {} will be ignored!", id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BCLRecipeManager.getRecipe(TYPE, id) != null) {
|
|
||||||
BetterEnd.LOGGER.warning("Can't add Alloying recipe! Id {} already exists!", id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!alright) {
|
|
||||||
BetterEnd.LOGGER.debug("Can't add Alloying recipe {}! Ingeredient or output not exists.", id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BCLRecipeManager.addRecipe(
|
|
||||||
TYPE,
|
|
||||||
new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Serializer implements RecipeSerializer<AlloyingRecipe> {
|
|
||||||
@Override
|
|
||||||
public AlloyingRecipe fromJson(ResourceLocation id, JsonObject json) {
|
|
||||||
JsonArray ingredients = GsonHelper.getAsJsonArray(json, "ingredients");
|
|
||||||
Ingredient primaryInput = Ingredient.fromJson(ingredients.get(0));
|
|
||||||
Ingredient secondaryInput = Ingredient.fromJson(ingredients.get(1));
|
|
||||||
String group = GsonHelper.getAsString(json, "group", "");
|
|
||||||
JsonObject result = GsonHelper.getAsJsonObject(json, "result");
|
|
||||||
ItemStack output = ItemUtil.fromJsonRecipe(result);
|
|
||||||
if (output == null) {
|
|
||||||
throw new IllegalStateException("Output item does not exists!");
|
|
||||||
}
|
|
||||||
float experience = GsonHelper.getAsFloat(json, "experience", 0.0F);
|
|
||||||
int smeltTime = GsonHelper.getAsInt(json, "smelttime", 350);
|
|
||||||
|
|
||||||
return new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlloyingRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf packetBuffer) {
|
|
||||||
String group = packetBuffer.readUtf(32767);
|
|
||||||
Ingredient primary = Ingredient.fromNetwork(packetBuffer);
|
|
||||||
Ingredient secondary = Ingredient.fromNetwork(packetBuffer);
|
|
||||||
ItemStack output = packetBuffer.readItem();
|
|
||||||
float experience = packetBuffer.readFloat();
|
|
||||||
int smeltTime = packetBuffer.readVarInt();
|
|
||||||
|
|
||||||
return new AlloyingRecipe(id, group, primary, secondary, output, experience, smeltTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toNetwork(FriendlyByteBuf packetBuffer, AlloyingRecipe recipe) {
|
|
||||||
packetBuffer.writeUtf(recipe.group);
|
|
||||||
recipe.primaryInput.toNetwork(packetBuffer);
|
|
||||||
recipe.secondaryInput.toNetwork(packetBuffer);
|
|
||||||
packetBuffer.writeItem(recipe.output);
|
|
||||||
packetBuffer.writeFloat(recipe.experience);
|
|
||||||
packetBuffer.writeVarInt(recipe.smeltTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.betterx.betterend.recipe.builders;
|
||||||
|
|
||||||
|
import org.betterx.bclib.recipes.AlloyingRecipe;
|
||||||
|
import org.betterx.betterend.BetterEnd;
|
||||||
|
import org.betterx.betterend.config.Configs;
|
||||||
|
|
||||||
|
public class AlloyingRecipeBuilder extends AlloyingRecipe.Builder {
|
||||||
|
private AlloyingRecipeBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AlloyingRecipe.Builder create(String id) {
|
||||||
|
return AlloyingRecipe.Builder.create(BetterEnd.MOD_ID, id, Configs.RECIPE_CONFIG);
|
||||||
|
}
|
||||||
|
}
|
|
@ -620,7 +620,5 @@
|
||||||
"item.betterend.thallasium_sword_blade": "Thallasiumschwertklinge",
|
"item.betterend.thallasium_sword_blade": "Thallasiumschwertklinge",
|
||||||
"item.betterend.thallasium_sword_handle": "Thallasiumschwertgriff",
|
"item.betterend.thallasium_sword_handle": "Thallasiumschwertgriff",
|
||||||
"block.betterend.aeternium_anvil": "Ätheramboss",
|
"block.betterend.aeternium_anvil": "Ätheramboss",
|
||||||
"emi.ctegory.bclib.end_stone_smelter": "Endsteinschmelzofen",
|
|
||||||
"tag.c.barrel": "Fässer",
|
|
||||||
"tag.betterend.alloying_iron": "Eisenlegierung"
|
"tag.betterend.alloying_iron": "Eisenlegierung"
|
||||||
}
|
}
|
||||||
|
|
|
@ -819,7 +819,5 @@
|
||||||
"block.betterend.pallidium_thin": "Pallidium (Thin Cover)",
|
"block.betterend.pallidium_thin": "Pallidium (Thin Cover)",
|
||||||
"block.betterend.pallidium_tiny": "Pallidium (Tiny Cover)",
|
"block.betterend.pallidium_tiny": "Pallidium (Tiny Cover)",
|
||||||
"block.betterend.flammalix": "Flammalix",
|
"block.betterend.flammalix": "Flammalix",
|
||||||
"emi.ctegory.bclib.end_stone_smelter": "End Stone Smelter",
|
|
||||||
"tag.c.barrel": "Barrels",
|
|
||||||
"tag.betterend.alloying_iron": "Iron Alloys"
|
"tag.betterend.alloying_iron": "Iron Alloys"
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,7 @@
|
||||||
"fabric": ">=0.56.0",
|
"fabric": ">=0.56.0",
|
||||||
"minecraft": [
|
"minecraft": [
|
||||||
"1.19",
|
"1.19",
|
||||||
"1.19.1",
|
"1.19.1"
|
||||||
"1.19.1-rc.3"
|
|
||||||
],
|
],
|
||||||
"bclib": "2.0.x"
|
"bclib": "2.0.x"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue