-
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathCompost.java
More file actions
81 lines (67 loc) · 3.06 KB
/
Compost.java
File metadata and controls
81 lines (67 loc) · 3.06 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
71
72
73
74
75
76
77
78
79
80
81
package com.blamejared.compat.actuallyaddition;
import com.blamejared.ModTweaker;
import com.blamejared.mtlib.helpers.InputHelper;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.blamejared.mtlib.utils.BaseListRemoval;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
import net.minecraft.block.Block;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.Collections;
import java.util.List;
@ZenClass("mods.actuallyadditions.Compost")
@ModOnly("actuallyadditions")
@ZenRegister
public class Compost {
@SuppressWarnings("deprecation")
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack outputDisplay, IIngredient input, IItemStack inputDisplay) {
if(!InputHelper.isABlock(outputDisplay) || !InputHelper.isABlock(inputDisplay)) {
CraftTweakerAPI.logError("outputDisplay or InputDisplay is not a block!");
return;
}
ModTweaker.LATE_ADDITIONS.add(new Add(Collections.singletonList(new CompostRecipe(CraftTweakerMC.getIngredient(input), Block.getBlockFromItem(InputHelper.toStack(inputDisplay).getItem()).getStateFromMeta(inputDisplay.getMetadata()), InputHelper.toStack(output), Block.getBlockFromItem(InputHelper.toStack(outputDisplay).getItem()).getStateFromMeta(outputDisplay.getMetadata())))));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
ModTweaker.LATE_REMOVALS.add(new Remove(output));
}
private static class Add extends BaseListAddition<CompostRecipe> {
protected Add(List<CompostRecipe> recipes) {
super("Compost", ActuallyAdditionsAPI.COMPOST_RECIPES, recipes);
}
@Override
public String getRecipeInfo(CompostRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
private static class Remove extends BaseListRemoval<CompostRecipe> {
private IItemStack output;
protected Remove(IItemStack output) {
super("Compost", ActuallyAdditionsAPI.COMPOST_RECIPES);
this.output = output;
}
@Override
public void apply() {
for(CompostRecipe recipe : ActuallyAdditionsAPI.COMPOST_RECIPES) {
System.out.println(output);
if(output.matches(InputHelper.toIItemStack(recipe.getOutput()))) {
recipes.add(recipe);
}
}
super.apply();
}
@Override
public String getRecipeInfo(CompostRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}