Recipe instance
This commit is contained in:
parent
98b714827a
commit
911fa8ee6d
9 changed files with 33 additions and 28 deletions
|
@ -29,19 +29,19 @@ public class BetterEnd implements ModInitializer {
|
|||
CraftingRecipes.register();
|
||||
|
||||
// TEST //
|
||||
new RecipeBuilder("test_block", Blocks.ANVIL)
|
||||
RecipeBuilder.make("test_block", Blocks.ANVIL)
|
||||
.setShape(new String[] {"I#", "#I"})
|
||||
.addMaterial('I', Items.STRING)
|
||||
.addMaterial('#', Items.APPLE)
|
||||
.build();
|
||||
|
||||
new RecipeBuilder("test_block_shaped", Blocks.STONE)
|
||||
RecipeBuilder.make("test_block_shaped", Blocks.STONE)
|
||||
.setShape(new String[] {"I#", "#I"})
|
||||
.addMaterial('I', Items.STRING)
|
||||
.addMaterial('#', ItemTags.LOGS)
|
||||
.build();
|
||||
|
||||
new RecipeBuilder("test_item_shapeless", Items.SUGAR)
|
||||
RecipeBuilder.make("test_item_shapeless", Items.SUGAR)
|
||||
.setList("I#Y")
|
||||
.addMaterial('I', Items.STRING)
|
||||
.addMaterial('#', ItemTags.LOGS)
|
||||
|
|
|
@ -3,7 +3,6 @@ package ru.betterend.blocks;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
|
@ -18,7 +17,6 @@ import net.minecraft.loot.context.LootContext;
|
|||
import net.minecraft.loot.context.LootContextParameters;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class BlockOre extends OreBlock {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
|
|
|
@ -12,7 +12,9 @@ import org.spongepowered.asm.mixin.Shadow;
|
|||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeManager;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.item.BlockItem;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.AeterniumBlock;
|
||||
import ru.betterend.blocks.BlockEndstoneDust;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue