|
| 1 | +package me.voper.slimeframe.implementation.items.machines; |
| 2 | + |
| 3 | +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; |
| 4 | +import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; |
| 5 | +import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; |
| 6 | +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; |
| 7 | +import me.voper.slimeframe.implementation.groups.Groups; |
| 8 | +import me.voper.slimeframe.implementation.items.abstracts.AbstractSelectorMachine; |
| 9 | +import me.voper.slimeframe.implementation.items.multiblocks.Foundry; |
| 10 | +import me.voper.slimeframe.utils.MachineUtils; |
| 11 | +import net.md_5.bungee.api.ChatColor; |
| 12 | +import org.bukkit.Material; |
| 13 | +import org.bukkit.inventory.ItemStack; |
| 14 | + |
| 15 | +import javax.annotation.Nonnull; |
| 16 | +import java.util.ArrayList; |
| 17 | +import java.util.List; |
| 18 | + |
| 19 | +public class TerracottaGenerator extends AbstractSelectorMachine implements RecipeDisplayItem { |
| 20 | + |
| 21 | + private static final String BLOCK_KEY = "terracota_selector"; |
| 22 | + private static final List<ItemStack> TERRACOTTA_LIST = List.of( |
| 23 | + MachineUtils.SELECTOR, |
| 24 | + new ItemStack(Material.WHITE_TERRACOTTA), |
| 25 | + new ItemStack(Material.ORANGE_TERRACOTTA), |
| 26 | + new ItemStack(Material.MAGENTA_TERRACOTTA), |
| 27 | + new ItemStack(Material.LIGHT_BLUE_TERRACOTTA), |
| 28 | + new ItemStack(Material.YELLOW_TERRACOTTA), |
| 29 | + new ItemStack(Material.LIME_TERRACOTTA), |
| 30 | + new ItemStack(Material.PINK_TERRACOTTA), |
| 31 | + new ItemStack(Material.GRAY_TERRACOTTA), |
| 32 | + new ItemStack(Material.LIGHT_GRAY_TERRACOTTA), |
| 33 | + new ItemStack(Material.CYAN_TERRACOTTA), |
| 34 | + new ItemStack(Material.PURPLE_TERRACOTTA), |
| 35 | + new ItemStack(Material.BLUE_TERRACOTTA), |
| 36 | + new ItemStack(Material.BROWN_TERRACOTTA), |
| 37 | + new ItemStack(Material.GREEN_TERRACOTTA), |
| 38 | + new ItemStack(Material.RED_TERRACOTTA), |
| 39 | + new ItemStack(Material.BLACK_TERRACOTTA) |
| 40 | + ); |
| 41 | + |
| 42 | + public TerracottaGenerator(SlimefunItemStack item, ItemStack[] recipe) { |
| 43 | + super(Groups.MACHINES, item, Foundry.RECIPE_TYPE, recipe); |
| 44 | + this.outputAmount = 6; |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + protected ItemStack getProgressBar() { |
| 49 | + return new ItemStack(Material.WHITE_TERRACOTTA); |
| 50 | + } |
| 51 | + |
| 52 | + @Override |
| 53 | + public void postRegister() { |
| 54 | + registerRecipe(6, new ItemStack[]{new ItemStack(Material.DIRT, 2), new ItemStack(Material.CLAY, 2)}, new ItemStack[]{new ItemStack(Material.OBSERVER)}); |
| 55 | + } |
| 56 | + |
| 57 | + @Nonnull |
| 58 | + @Override |
| 59 | + public List<ItemStack> selectionList() { |
| 60 | + return TERRACOTTA_LIST; |
| 61 | + } |
| 62 | + |
| 63 | + @Nonnull |
| 64 | + @Override |
| 65 | + public String getBlockKey() { |
| 66 | + return BLOCK_KEY; |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + protected boolean checkCraftConditions(BlockMenu menu) { |
| 71 | + return menu.getItemInSlot(getSelectorSlot()).getType().name().endsWith("_TERRACOTTA"); |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + protected void onCraftConditionsNotMet(BlockMenu menu) { |
| 76 | + MachineUtils.replaceExistingItemViewer(menu, getStatusSlot(), new CustomItemStack(Material.BARRIER, ChatColor.RED + "Select a terracotta to generate!")); |
| 77 | + } |
| 78 | + |
| 79 | + @Nonnull |
| 80 | + @Override |
| 81 | + public List<ItemStack> getDisplayRecipes() { |
| 82 | + final List<ItemStack> displayRecipes = new ArrayList<>(); |
| 83 | + for (ItemStack itemStack: TERRACOTTA_LIST) { |
| 84 | + if (!itemStack.getType().name().endsWith("_TERRACOTTA")) continue; |
| 85 | + displayRecipes.add(recipes.get(0).getInput()[0]); |
| 86 | + ItemStack clone = itemStack.clone(); |
| 87 | + clone.setAmount(outputAmount * production); |
| 88 | + displayRecipes.add(clone); |
| 89 | + displayRecipes.add(recipes.get(0).getInput()[1]); |
| 90 | + displayRecipes.add(null); |
| 91 | + } |
| 92 | + return displayRecipes; |
| 93 | + } |
| 94 | +} |
0 commit comments