From 70c96e0aa8c8f81f3eb6fcf3580fc858ce052a61 Mon Sep 17 00:00:00 2001 From: Intybyte Date: Fri, 25 Oct 2024 13:19:18 +0200 Subject: [PATCH] More fixed, most notably ChestMenuUtils NOTE TO FUTURE SELF: Use ForwardingObject over lombok's @Delegate --- .../machines/HeatedPressureChamber.java | 16 +++++----- .../slimefun4/utils/ChestMenuUtils.java | 32 +++++++++---------- .../abstractItems/AContainer.java | 13 ++++++++ 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java index 97505f6dd8..a373974026 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java @@ -85,14 +85,14 @@ private Comparator compareSlots(DirtyChestMenu menu) { @Override protected void registerDefaultRecipes() { - registerRecipe(45, new ItemStack[] { SlimefunItems.OIL_BUCKET }, new ItemStack[] { new CustomItemStack(SlimefunItems.PLASTIC_SHEET, 8) }); - registerRecipe(30, new ItemStack[] { SlimefunItems.GOLD_24K, SlimefunItems.URANIUM }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT }); - registerRecipe(30, new ItemStack[] { SlimefunItems.BLISTERING_INGOT, SlimefunItems.CARBONADO }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_2 }); - registerRecipe(60, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_2, new ItemStack(Material.NETHER_STAR) }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_3 }); - registerRecipe(90, new ItemStack[] { SlimefunItems.PLUTONIUM, SlimefunItems.URANIUM }, new ItemStack[] { SlimefunItems.BOOSTED_URANIUM }); - registerRecipe(60, new ItemStack[] { SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM }, new ItemStack[] { new CustomItemStack(SlimefunItems.ENRICHED_NETHER_ICE, 4) }); - registerRecipe(45, new ItemStack[] { SlimefunItems.ENRICHED_NETHER_ICE }, new ItemStack[] { new CustomItemStack(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8) }); - registerRecipe(8, new ItemStack[] { SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT }, new ItemStack[] { SlimefunItems.MAGNESIUM_SALT }); + registerRecipe(45, new ItemStack[] { SlimefunItems.OIL_BUCKET.getDelegate() }, new ItemStack[] { new CustomItemStack(SlimefunItems.PLASTIC_SHEET.getDelegate(), 8) }); + registerRecipe(30, new SlimefunItemStack[] { SlimefunItems.GOLD_24K, SlimefunItems.URANIUM }, new SlimefunItemStack[] { SlimefunItems.BLISTERING_INGOT }); + registerRecipe(30, new SlimefunItemStack[] { SlimefunItems.BLISTERING_INGOT, SlimefunItems.CARBONADO }, new SlimefunItemStack[] { SlimefunItems.BLISTERING_INGOT_2 }); + registerRecipe(60, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_2.getDelegate(), new ItemStack(Material.NETHER_STAR) }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_3.getDelegate() }); + registerRecipe(90, new SlimefunItemStack[] { SlimefunItems.PLUTONIUM, SlimefunItems.URANIUM }, new SlimefunItemStack[] { SlimefunItems.BOOSTED_URANIUM }); + registerRecipe(60, new ItemStack[] { SlimefunItems.NETHER_ICE.getDelegate(), SlimefunItems.PLUTONIUM.getDelegate() }, new ItemStack[] { new CustomItemStack(SlimefunItems.ENRICHED_NETHER_ICE.getDelegate(), 4) }); + registerRecipe(45, new ItemStack[] { SlimefunItems.ENRICHED_NETHER_ICE.getDelegate() }, new ItemStack[] { new CustomItemStack(SlimefunItems.NETHER_ICE_COOLANT_CELL.getDelegate(), 8) }); + registerRecipe(8, new SlimefunItemStack[] { SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT }, new SlimefunItemStack[] { SlimefunItems.MAGNESIUM_SALT }); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java index 928233eb5d..cc02fdb3ef 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java @@ -28,22 +28,22 @@ public final class ChestMenuUtils { private ChestMenuUtils() {} - private static final ItemStack UI_BACKGROUND = new SlimefunItemStack("_UI_BACKGROUND", Material.GRAY_STAINED_GLASS_PANE, " "); - private static final ItemStack INPUT_SLOT = new SlimefunItemStack("_UI_INPUT_SLOT", Material.CYAN_STAINED_GLASS_PANE, " "); - private static final ItemStack OUTPUT_SLOT = new SlimefunItemStack("_UI_OUTPUT_SLOT", Material.ORANGE_STAINED_GLASS_PANE, " "); - - private static final ItemStack NO_PERMISSION = new SlimefunItemStack("_UI_NO_PERMISSION", Material.BARRIER, "No Permission"); - private static final ItemStack NOT_RESEARCHED = new SlimefunItemStack("_UI_NOT_RESEARCHED", Material.BARRIER, "Not researched"); - - private static final ItemStack BACK_BUTTON = new SlimefunItemStack("_UI_BACK", Material.ENCHANTED_BOOK, "&7\u21E6 Back", meta -> meta.addItemFlags(ItemFlag.HIDE_ENCHANTS)); - private static final ItemStack MENU_BUTTON = new SlimefunItemStack("_UI_MENU", Material.COMPARATOR, "&eSettings / Info", "", "&7\u21E8 Click to see more"); - private static final ItemStack SEARCH_BUTTON = new SlimefunItemStack("_UI_SEARCH", Material.NAME_TAG, "&bSearch"); - private static final ItemStack WIKI_BUTTON = new SlimefunItemStack("_UI_WIKI", Material.KNOWLEDGE_BOOK, "&3Slimefun Wiki"); - - private static final ItemStack PREV_BUTTON_ACTIVE = new SlimefunItemStack("_UI_PREVIOUS_ACTIVE", Material.LIME_STAINED_GLASS_PANE, "&r\u21E6 Previous Page"); - private static final ItemStack NEXT_BUTTON_ACTIVE = new SlimefunItemStack("_UI_NEXT_ACTIVE", Material.LIME_STAINED_GLASS_PANE, "&rNext Page \u21E8"); - private static final ItemStack PREV_BUTTON_INACTIVE = new SlimefunItemStack("_UI_PREVIOUS_INACTIVE", Material.BLACK_STAINED_GLASS_PANE, "&8\u21E6 Previous Page"); - private static final ItemStack NEXT_BUTTON_INACTIVE = new SlimefunItemStack("_UI_NEXT_INACTIVE", Material.BLACK_STAINED_GLASS_PANE, "&8Next Page \u21E8"); + private static final ItemStack UI_BACKGROUND = new SlimefunItemStack("_UI_BACKGROUND", Material.GRAY_STAINED_GLASS_PANE, " ").getDelegate(); + private static final ItemStack INPUT_SLOT = new SlimefunItemStack("_UI_INPUT_SLOT", Material.CYAN_STAINED_GLASS_PANE, " ").getDelegate(); + private static final ItemStack OUTPUT_SLOT = new SlimefunItemStack("_UI_OUTPUT_SLOT", Material.ORANGE_STAINED_GLASS_PANE, " ").getDelegate(); + + private static final ItemStack NO_PERMISSION = new SlimefunItemStack("_UI_NO_PERMISSION", Material.BARRIER, "No Permission").getDelegate(); + private static final ItemStack NOT_RESEARCHED = new SlimefunItemStack("_UI_NOT_RESEARCHED", Material.BARRIER, "Not researched").getDelegate(); + + private static final ItemStack BACK_BUTTON = new SlimefunItemStack("_UI_BACK", Material.ENCHANTED_BOOK, "&7\u21E6 Back", meta -> meta.addItemFlags(ItemFlag.HIDE_ENCHANTS)).getDelegate(); + private static final ItemStack MENU_BUTTON = new SlimefunItemStack("_UI_MENU", Material.COMPARATOR, "&eSettings / Info", "", "&7\u21E8 Click to see more").getDelegate(); + private static final ItemStack SEARCH_BUTTON = new SlimefunItemStack("_UI_SEARCH", Material.NAME_TAG, "&bSearch").getDelegate(); + private static final ItemStack WIKI_BUTTON = new SlimefunItemStack("_UI_WIKI", Material.KNOWLEDGE_BOOK, "&3Slimefun Wiki").getDelegate(); + + private static final ItemStack PREV_BUTTON_ACTIVE = new SlimefunItemStack("_UI_PREVIOUS_ACTIVE", Material.LIME_STAINED_GLASS_PANE, "&r\u21E6 Previous Page").getDelegate(); + private static final ItemStack NEXT_BUTTON_ACTIVE = new SlimefunItemStack("_UI_NEXT_ACTIVE", Material.LIME_STAINED_GLASS_PANE, "&rNext Page \u21E8").getDelegate(); + private static final ItemStack PREV_BUTTON_INACTIVE = new SlimefunItemStack("_UI_PREVIOUS_INACTIVE", Material.BLACK_STAINED_GLASS_PANE, "&8\u21E6 Previous Page").getDelegate(); + private static final ItemStack NEXT_BUTTON_INACTIVE = new SlimefunItemStack("_UI_NEXT_INACTIVE", Material.BLACK_STAINED_GLASS_PANE, "&8Next Page \u21E8").getDelegate(); private static final ChestMenu.AdvancedMenuClickHandler OUTPUT_HANDLER = new ChestMenu.AdvancedMenuClickHandler() { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index 1a59d8a9e1..fd544c0df4 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -1,6 +1,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -321,6 +322,18 @@ public void registerRecipe(int seconds, SlimefunItemStack input, SlimefunItemSta registerRecipe(seconds, input.getDelegate(), output.getDelegate()); } + public void registerRecipe(int seconds, SlimefunItemStack[] input, SlimefunItemStack[] output) { + var inputAsItemStack = Arrays.stream(input) + .map(SlimefunItemStack::getDelegate) + .toArray(ItemStack[]::new); + + var outputAsItemStack = Arrays.stream(output) + .map(SlimefunItemStack::getDelegate) + .toArray(ItemStack[]::new); + + registerRecipe(seconds, inputAsItemStack, outputAsItemStack); + } + @Override public void preRegister() { addItemHandler(new BlockTicker() {