blob: f5b379dc4313c9e3af73cca5d40a0c85fabcc10c (
plain)
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
|
package de.hysky.skyblocker.skyblock.itemlist;
import io.github.moulberry.repo.data.NEUCraftingRecipe;
import io.github.moulberry.repo.data.NEUIngredient;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class SkyblockCraftingRecipe {
private static final Logger LOGGER = LoggerFactory.getLogger(SkyblockCraftingRecipe.class);
private final String craftText;
private final List<ItemStack> grid = new ArrayList<>(9);
private ItemStack result;
public SkyblockCraftingRecipe(String craftText) {
this.craftText = craftText;
}
public static SkyblockCraftingRecipe fromNEURecipe(NEUCraftingRecipe neuCraftingRecipe) {
SkyblockCraftingRecipe recipe = new SkyblockCraftingRecipe(neuCraftingRecipe.getExtraText() != null ? neuCraftingRecipe.getExtraText() : "");
for (NEUIngredient input : neuCraftingRecipe.getInputs()) {
recipe.grid.add(getItemStack(input));
}
recipe.result = getItemStack(neuCraftingRecipe.getOutput());
return recipe;
}
private static ItemStack getItemStack(NEUIngredient input) {
if (input != NEUIngredient.SENTINEL_EMPTY) {
ItemStack stack = ItemRepository.getItemStack(input.getItemId());
if (stack != null) {
return stack.copyWithCount((int) input.getAmount());
} else {
LOGGER.warn("[Skyblocker Recipe] Unable to find item {}", input.getItemId());
}
}
return Items.AIR.getDefaultStack();
}
public List<ItemStack> getGrid() {
return grid;
}
public ItemStack getResult() {
return result;
}
public String getCraftText() {
return craftText;
}
}
|