From 7758114eba6ff07ca1ceb7b415705e21a3303a10 Mon Sep 17 00:00:00 2001 From: Intybyte Date: Thu, 16 May 2024 15:32:08 +0200 Subject: [PATCH 1/3] ElectricJuicer Suggestion #2560 discord --- .../implementation/SlimefunItems.java | 1 + .../electric/machines/ElectricJuicer.java | 28 +++++++++++++++++ .../implementation/setup/PostSetup.java | 30 +++++++++++++++++++ .../setup/SlimefunItemSetup.java | 8 +++++ 4 files changed, 67 insertions(+) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricJuicer.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 8695759316..7a290cf618 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -586,6 +586,7 @@ private SlimefunItems() {} public static final SlimefunItemStack ORE_WASHER = new SlimefunItemStack("ORE_WASHER", Material.CAULDRON, "&6Ore Washer", "", "&aWashes Sifted Ore to filter Ores", "&aand gives you small Stone Chunks"); public static final SlimefunItemStack TABLE_SAW = new SlimefunItemStack("TABLE_SAW", Material.STONECUTTER, "&6Table Saw", "", "&aAllows you to get 8 planks from 1 Log", "&a(Works with all log types)"); public static final SlimefunItemStack JUICER = new SlimefunItemStack("JUICER", Material.GLASS_BOTTLE, "&aJuicer", "", "&aAllows you to create delicious Juice"); + public static final SlimefunItemStack ELECTRIC_JUICER = new SlimefunItemStack("ELECTRIC_JUICER", Material.TINTED_GLASS, "&aElectric Juicer", "", "&aAllows you to create delicious Juice", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(10)); public static final SlimefunItemStack AUTOMATED_PANNING_MACHINE = new SlimefunItemStack("AUTOMATED_PANNING_MACHINE", Material.BOWL, "&eAutomated Panning Machine", "", "&fA MultiBlock Version of the Gold Pan", "&fand Nether Gold Pan combined in one machine."); public static final SlimefunItemStack INDUSTRIAL_MINER = new SlimefunItemStack("INDUSTRIAL_MINER", Material.GOLDEN_PICKAXE, "&bIndustrial Miner", "", "&fThis Multiblock will mine any Ores", "&fin a 7x7 area underneath it.", "&fPlace coal or similar in its chest", "&fto fuel this machine."); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricJuicer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricJuicer.java new file mode 100644 index 0000000000..f602918635 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricJuicer.java @@ -0,0 +1,28 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; + +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import javax.annotation.Nonnull; + +public class ElectricJuicer extends AContainer implements RecipeDisplayItem { + public ElectricJuicer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(itemGroup, item, recipeType, recipe); + } + + @Override + public ItemStack getProgressBar() { + return new ItemStack(Material.DIAMOND_SHOVEL); + } + + @Nonnull + @Override + public String getMachineIdentifier() { + return "ELECTRIC_JUICER"; + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java index ce8694bd31..d984b6db20 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java @@ -16,6 +16,7 @@ import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Juicer; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -82,6 +83,7 @@ public static void loadItems() { loadOreGrinderRecipes(); loadSmelteryRecipes(); + loadJuicer(); CommandSender sender = Bukkit.getConsoleSender(); @@ -206,6 +208,34 @@ private static void loadSmelteryRecipes() { } } + private static void loadJuicer() { + List juicerRecipes = new ArrayList<>(); + + Juicer juicer = (Juicer) SlimefunItems.JUICER.getItem(); + if (juicer == null) { + return; + } + + ItemStack[] input = null; + + for (ItemStack[] recipe : juicer.getRecipes()) { + + if (input == null) { + input = recipe; + continue; + } + + if (input[0] != null && recipe[0] != null) { + juicerRecipes.add(new ItemStack[] { input[0], recipe[0] }); + } + + input = null; + } + + Stream stream = juicerRecipes.stream(); + stream.forEach(recipe -> registerMachineRecipe("ELECTRIC_JUICER", 2, new ItemStack[] { recipe[0] }, new ItemStack[] { recipe[1] })); + } + private static void addSmelteryRecipe(ItemStack[] input, ItemStack[] output, MakeshiftSmeltery makeshiftSmeltery) { List ingredients = new ArrayList<>(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 9ade30e843..c89b9e3c15 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricJuicer; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -2321,6 +2322,13 @@ public int getEnergyConsumption() { new SlimefunItemStack(SlimefunItems.ELEVATOR_PLATE, 2)) .register(plugin); + new ElectricJuicer(itemGroups.electricity, SlimefunItems.ELECTRIC_JUICER, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[]{ null, new ItemStack(Material.GLASS), null, SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.NETHER_BRICK_FENCE), SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.NETHER_BRICKS), SlimefunItems.SMALL_CAPACITOR, new ItemStack(Material.NETHER_BRICKS)}) + .setCapacity(128) + .setEnergyConsumption(5) + .setProcessingSpeed(1) + .register(plugin); + new FoodFabricator(itemGroups.electricity, SlimefunItems.FOOD_FABRICATOR, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.BILLON_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.BILLON_INGOT, SlimefunItems.TIN_CAN, SlimefunItems.SMALL_CAPACITOR, SlimefunItems.TIN_CAN, null, SlimefunItems.ELECTRIC_MOTOR, null}) .setCapacity(256) From 8e7ed89464c19cd65c83842a7ecefda9bc149e9b Mon Sep 17 00:00:00 2001 From: Intybyte Date: Fri, 17 May 2024 19:39:51 +0200 Subject: [PATCH 2/3] Item change for 1.16 support --- .../thebusybiscuit/slimefun4/implementation/SlimefunItems.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 7a290cf618..27404eec4e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -586,7 +586,7 @@ private SlimefunItems() {} public static final SlimefunItemStack ORE_WASHER = new SlimefunItemStack("ORE_WASHER", Material.CAULDRON, "&6Ore Washer", "", "&aWashes Sifted Ore to filter Ores", "&aand gives you small Stone Chunks"); public static final SlimefunItemStack TABLE_SAW = new SlimefunItemStack("TABLE_SAW", Material.STONECUTTER, "&6Table Saw", "", "&aAllows you to get 8 planks from 1 Log", "&a(Works with all log types)"); public static final SlimefunItemStack JUICER = new SlimefunItemStack("JUICER", Material.GLASS_BOTTLE, "&aJuicer", "", "&aAllows you to create delicious Juice"); - public static final SlimefunItemStack ELECTRIC_JUICER = new SlimefunItemStack("ELECTRIC_JUICER", Material.TINTED_GLASS, "&aElectric Juicer", "", "&aAllows you to create delicious Juice", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(10)); + public static final SlimefunItemStack ELECTRIC_JUICER = new SlimefunItemStack("ELECTRIC_JUICER", Material.BLACK_STAINED_GLASS, "&aElectric Juicer", "", "&aAllows you to create delicious Juice", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(10)); public static final SlimefunItemStack AUTOMATED_PANNING_MACHINE = new SlimefunItemStack("AUTOMATED_PANNING_MACHINE", Material.BOWL, "&eAutomated Panning Machine", "", "&fA MultiBlock Version of the Gold Pan", "&fand Nether Gold Pan combined in one machine."); public static final SlimefunItemStack INDUSTRIAL_MINER = new SlimefunItemStack("INDUSTRIAL_MINER", Material.GOLDEN_PICKAXE, "&bIndustrial Miner", "", "&fThis Multiblock will mine any Ores", "&fin a 7x7 area underneath it.", "&fPlace coal or similar in its chest", "&fto fuel this machine."); From 5bcd79da495b2445b0f843867bc126d68d267e99 Mon Sep 17 00:00:00 2001 From: Intybyte Date: Sat, 31 Aug 2024 09:34:52 +0200 Subject: [PATCH 3/3] Add documentation --- .../items/electric/machines/ElectricJuicer.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricJuicer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricJuicer.java index f602918635..495d1ad230 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricJuicer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricJuicer.java @@ -4,12 +4,20 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Juicer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import javax.annotation.Nonnull; +/** + * The {@link ElectricJuicer} is an electric machine based on the {@link Juicer}. + * + * @author Vaan1310 + * + * @see Juicer + */ public class ElectricJuicer extends AContainer implements RecipeDisplayItem { public ElectricJuicer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, item, recipeType, recipe);