Recipe instance
This commit is contained in:
parent
98b714827a
commit
911fa8ee6d
9 changed files with 33 additions and 28 deletions
|
@ -4,17 +4,16 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
|
||||
public class CraftingRecipes {
|
||||
public static void register() {
|
||||
if (blockExists(BlockRegistry.ENDER_BLOCK)) {
|
||||
new RecipeBuilder("be_ender_pearl_to_block", BlockRegistry.ENDER_BLOCK)
|
||||
RecipeBuilder.make("be_ender_pearl_to_block", BlockRegistry.ENDER_BLOCK)
|
||||
.setShape(new String[] { "OO", "OO" })
|
||||
.addMaterial('O', Items.ENDER_PEARL)
|
||||
.build();
|
||||
new RecipeBuilder("be_ender_block_to_pearl", Items.ENDER_PEARL)
|
||||
RecipeBuilder.make("be_ender_block_to_pearl", Items.ENDER_PEARL)
|
||||
.addMaterial('#', BlockRegistry.ENDER_BLOCK)
|
||||
.setOutputCount(4)
|
||||
.setList("#")
|
||||
|
@ -22,12 +21,12 @@ public class CraftingRecipes {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean itemExists(Item item)
|
||||
protected static boolean itemExists(Item item)
|
||||
{
|
||||
return Registry.ITEM.getId(item) != Registry.ITEM.getDefaultId();
|
||||
}
|
||||
|
||||
private static boolean blockExists(Block block)
|
||||
protected static boolean blockExists(Block block)
|
||||
{
|
||||
return Registry.BLOCK.getId(block) != Registry.BLOCK.getDefaultId();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package ru.betterend.recipe;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -19,24 +18,32 @@ import net.minecraft.util.collection.DefaultedList;
|
|||
import ru.betterend.BetterEnd;
|
||||
|
||||
public class RecipeBuilder {
|
||||
private final String name;
|
||||
private final Item output;
|
||||
private static final RecipeBuilder INSTANCE = new RecipeBuilder();
|
||||
|
||||
private String group = "";
|
||||
private RecipeType<?> type = RecipeType.CRAFTING;
|
||||
private boolean shaped = true;
|
||||
private String[] shape = new String[] {"#"};
|
||||
private String name;
|
||||
private ItemConvertible output;
|
||||
|
||||
private String group;
|
||||
private RecipeType<?> type;
|
||||
private boolean shaped;
|
||||
private String[] shape;
|
||||
private Map<Character, Ingredient> materialKeys = Maps.newHashMap();
|
||||
private int count = 1;
|
||||
private int count;
|
||||
|
||||
public RecipeBuilder(String name, Item output) {
|
||||
this.name = name;
|
||||
this.output = output;
|
||||
}
|
||||
private RecipeBuilder() {}
|
||||
|
||||
public RecipeBuilder(String name, Block output) {
|
||||
this.name = name;
|
||||
this.output = output.asItem();
|
||||
public static RecipeBuilder make(String name, ItemConvertible output) {
|
||||
INSTANCE.name = name;
|
||||
INSTANCE.output = output;
|
||||
|
||||
INSTANCE.group = "";
|
||||
INSTANCE.type = RecipeType.CRAFTING;
|
||||
INSTANCE.shaped = true;
|
||||
INSTANCE.shape = new String[] {"#"};
|
||||
INSTANCE.materialKeys.clear();
|
||||
INSTANCE.count = 1;
|
||||
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public RecipeBuilder setGroup(String group) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue