End Stone Smelter
This commit is contained in:
parent
257307d93d
commit
a542aac45b
18 changed files with 551 additions and 77 deletions
|
@ -3,14 +3,16 @@ package ru.betterend.recipe;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.collection.DefaultedList;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
|
@ -18,8 +20,8 @@ import ru.betterend.registry.BlockRegistry;
|
|||
public class AlloyingRecipe implements Recipe<Inventory> {
|
||||
|
||||
public final static String GROUP = "alloying";
|
||||
public final static RecipeType<AlloyingRecipe> TYPE = registerType(GROUP);
|
||||
public final static AlloyingRecipeSerializer SERIALIZER = registerSerializer(GROUP, new AlloyingRecipeSerializer());
|
||||
public final static RecipeType<AlloyingRecipe> TYPE = EndRecipeManager.registerType(GROUP);
|
||||
public final static AlloyingRecipeSerializer SERIALIZER = EndRecipeManager.registerSerializer(GROUP, new AlloyingRecipeSerializer());
|
||||
|
||||
protected final RecipeType<?> type;
|
||||
protected final Identifier id;
|
||||
|
@ -104,15 +106,91 @@ public class AlloyingRecipe implements Recipe<Inventory> {
|
|||
return new ItemStack(BlockRegistry.END_STONE_SMELTER);
|
||||
}
|
||||
|
||||
private static <S extends RecipeSerializer<T>, T extends Recipe<?>> S registerSerializer(String id, S serializer) {
|
||||
return Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(BetterEnd.MOD_ID, id), serializer);
|
||||
}
|
||||
|
||||
private static <T extends Recipe<?>> RecipeType<T> registerType(String name) {
|
||||
return Registry.register(Registry.RECIPE_TYPE, new Identifier(BetterEnd.MOD_ID, name), new RecipeType<T>() {
|
||||
public String toString() {
|
||||
return name;
|
||||
public static class Builder {
|
||||
private final static Builder INSTANCE = new Builder();
|
||||
|
||||
public static Builder create(String id) {
|
||||
INSTANCE.id = BetterEnd.getResId(id);
|
||||
INSTANCE.primaryInput = null;
|
||||
INSTANCE.secondaryInput = null;
|
||||
INSTANCE.output = null;
|
||||
INSTANCE.experience = 0.0F;
|
||||
INSTANCE.smeltTime = 350;
|
||||
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private Identifier id;
|
||||
private Ingredient primaryInput;
|
||||
private Ingredient secondaryInput;
|
||||
private ItemStack output;
|
||||
private float experience;
|
||||
private int smeltTime;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
public Builder setPrimaryInput(ItemConvertible... inputs) {
|
||||
this.primaryInput = Ingredient.ofItems(inputs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSecondaryInput(ItemConvertible... inputs) {
|
||||
this.secondaryInput = Ingredient.ofItems(inputs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPrimaryInput(Tag<Item> input) {
|
||||
this.primaryInput = Ingredient.fromTag(input);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSecondaryInput(Tag<Item> input) {
|
||||
this.secondaryInput = Ingredient.fromTag(input);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setInput(ItemConvertible primaryInput, ItemConvertible secondaryInput) {
|
||||
this.setPrimaryInput(primaryInput);
|
||||
this.setSecondaryInput(secondaryInput);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setInput(Tag<Item> primaryInput, Tag<Item> secondaryInput) {
|
||||
this.setPrimaryInput(primaryInput);
|
||||
this.setSecondaryInput(secondaryInput);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setInput(Ingredient primaryInput, Ingredient secondaryInput) {
|
||||
this.primaryInput = primaryInput;
|
||||
this.secondaryInput = secondaryInput;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setOutput(ItemConvertible output, int amount) {
|
||||
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 (primaryInput == null) {
|
||||
throw new IllegalArgumentException("Primary input can't be null!");
|
||||
} else if(secondaryInput == null) {
|
||||
throw new IllegalArgumentException("Secondary input can't be null!");
|
||||
} else if(output == null) {
|
||||
throw new IllegalArgumentException("Output can't be null!");
|
||||
}
|
||||
});
|
||||
EndRecipeManager.addRecipe(AlloyingRecipe.TYPE, new AlloyingRecipe(id, primaryInput, secondaryInput, output, experience, smeltTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue