Smithing recipe builder + REI tool damage diplay
This commit is contained in:
parent
2f6014d441
commit
c1b7c83569
8 changed files with 116 additions and 20 deletions
|
@ -4,8 +4,11 @@ import com.google.gson.JsonObject;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolItem;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
@ -13,11 +16,13 @@ import net.minecraft.recipe.Ingredient;
|
|||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.registry.ItemTagRegistry;
|
||||
|
||||
|
@ -82,6 +87,10 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
|||
int level = ((ToolItem) hammer.getItem()).getMaterial().getMiningLevel();
|
||||
return level >= this.level && this.input.test(craftingInventory.getStack(1));
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedList<Ingredient> getPreviewInputs() {
|
||||
|
@ -114,6 +123,68 @@ public class AnvilSmithingRecipe implements Recipe<Inventory> {
|
|||
public boolean isIgnoredInRecipeBook() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final static Builder INSTANCE = new Builder();
|
||||
|
||||
public static Builder create(String id) {
|
||||
INSTANCE.id = BetterEnd.makeID(id);
|
||||
INSTANCE.input = null;
|
||||
INSTANCE.output = null;
|
||||
INSTANCE.level = 1;
|
||||
INSTANCE.damage = 1;
|
||||
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private Identifier id;
|
||||
private Ingredient input;
|
||||
private ItemStack output;
|
||||
private int level = 1;
|
||||
private int damage = 1;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
public Builder setInput(ItemConvertible... inputItem) {
|
||||
this.setInput(Ingredient.ofItems(inputItem));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setInput(Tag<Item> inputTag) {
|
||||
this.setInput(Ingredient.fromTag(inputTag));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setInput(Ingredient ingredient) {
|
||||
this.input = ingredient;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setOutput(ItemConvertible output, int amount) {
|
||||
this.output = new ItemStack(output, amount);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setLevel(int level) {
|
||||
this.level = level;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void build() {
|
||||
if (input == null) {
|
||||
throw new IllegalArgumentException("Input can't be null!");
|
||||
} else if(output == null) {
|
||||
throw new IllegalArgumentException("Output can't be null!");
|
||||
}
|
||||
|
||||
EndRecipeManager.addRecipe(TYPE, new AnvilSmithingRecipe(id, input, output, level, damage));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Serializer implements RecipeSerializer<AnvilSmithingRecipe> {
|
||||
@Override
|
||||
|
|
|
@ -2,10 +2,8 @@ package ru.betterend.recipe;
|
|||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.registry.ItemRegistry;
|
||||
|
||||
|
@ -71,8 +69,9 @@ public class CraftingRecipes {
|
|||
RecipeBuilder.make("creeping_moss_dye", Items.CYAN_DYE).setList("#").addMaterial('#', BlockRegistry.CREEPING_MOSS).build();
|
||||
RecipeBuilder.make("umbrella_moss_dye", Items.YELLOW_DYE).setList("#").addMaterial('#', BlockRegistry.UMBRELLA_MOSS).build();
|
||||
RecipeBuilder.make("umbrella_moss_tall_dye", Items.YELLOW_DYE).setList("#").addMaterial('#', BlockRegistry.UMBRELLA_MOSS_TALL).build();
|
||||
|
||||
EndRecipeManager.addRecipe(AnvilSmithingRecipe.TYPE, new AnvilSmithingRecipe(BetterEnd.makeID("ender_pearl_to_dust"), Ingredient.ofItems(Items.ENDER_PEARL), new ItemStack(ItemRegistry.ENDER_DUST), 4, 1));
|
||||
|
||||
AlloyingRecipes.register();
|
||||
SmithingRecipes.register();
|
||||
}
|
||||
|
||||
private static void registerHelmet(String name, Item material, Item result) {
|
||||
|
@ -145,9 +144,9 @@ public class CraftingRecipes {
|
|||
|
||||
private static void registerHammer(String name, Item material, Item result) {
|
||||
RecipeBuilder.make(name + "_hammer", result)
|
||||
.setShape(new String[] { "I I", "I#I", " # " })
|
||||
.addMaterial('I', material)
|
||||
.addMaterial('#', Items.STICK)
|
||||
.build();
|
||||
.setShape(new String[] { "I I", "I#I", " # " })
|
||||
.addMaterial('I', material)
|
||||
.addMaterial('#', Items.STICK)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
15
src/main/java/ru/betterend/recipe/SmithingRecipes.java
Normal file
15
src/main/java/ru/betterend/recipe/SmithingRecipes.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package ru.betterend.recipe;
|
||||
|
||||
import net.minecraft.item.Items;
|
||||
import ru.betterend.registry.ItemRegistry;
|
||||
|
||||
public class SmithingRecipes {
|
||||
public static void register() {
|
||||
AnvilSmithingRecipe.Builder.create("ender_pearl_to_dust")
|
||||
.setInput(Items.ENDER_PEARL)
|
||||
.setOutput(ItemRegistry.ENDER_DUST, 1)
|
||||
.setLevel(4)
|
||||
.setDamage(5)
|
||||
.build();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue