-
-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathBlockRecipeBuilder.java
More file actions
70 lines (57 loc) · 2.47 KB
/
Copy pathBlockRecipeBuilder.java
File metadata and controls
70 lines (57 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.blamejared.compat.betterwithmods.base.blockrecipes;
import betterwithmods.common.registry.block.managers.CraftingManagerBlock;
import betterwithmods.common.registry.block.recipe.BlockDropIngredient;
import betterwithmods.common.registry.block.recipe.BlockIngredient;
import betterwithmods.common.registry.block.recipe.BlockRecipe;
import com.blamejared.ModTweaker;
import com.blamejared.compat.betterwithmods.base.RemoveAll;
import com.blamejared.mtlib.helpers.InputHelper;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.List;
import java.util.function.Supplier;
public abstract class BlockRecipeBuilder<T extends BlockRecipe> {
protected BlockIngredient input;
protected List<ItemStack> outputs;
private Supplier<CraftingManagerBlock<T>> registry;
protected String name;
public BlockRecipeBuilder(Supplier<CraftingManagerBlock<T>> registry, String name) {
this.registry = registry;
this.name = name;
}
protected void addRecipe(T recipe) {
ModTweaker.LATE_ADDITIONS.add(new BlockRecipeAdd<>(name, registry.get(), recipe));
}
@ZenMethod
public abstract void build();
public void removeRecipe(IItemStack[] output) {
ModTweaker.LATE_REMOVALS.add(new BlockRecipeRemove<>(name, registry.get(), output));
}
public void removeRecipe(IItemStack input) {
ModTweaker.LATE_REMOVALS.add(new BlockRecipeRemoveInput<>(name, registry.get(), input));
}
public void _buildRecipe(IIngredient input, IItemStack[] outputs) {
this.input = new BlockIngredient(CraftTweakerMC.getIngredient(input));
this.outputs = InputHelper.toNonNullList(CraftTweakerMC.getItemStacks(outputs));
}
@ZenMethod
public BlockRecipeBuilder<? extends BlockRecipe> setInputBlockDrop(IItemStack input) {
this.input = new BlockDropIngredient(CraftTweakerMC.getItemStack(input));
return this;
}
@ZenMethod
public BlockRecipeBuilder<? extends BlockRecipe> setInputBlockDrop(IItemStack[] inputs) {
this.input = new BlockDropIngredient(CraftTweakerMC.getItemStacks(inputs));
return this;
}
@ZenMethod
public void removeAll() {
ModTweaker.LATE_REMOVALS.add(new RemoveAll<>(name, registry.get().getRecipes()));
}
public String getName() {
return name;
}
}