From aee8794558e726741a77283f47cc8267340c8b23 Mon Sep 17 00:00:00 2001 From: Intybyte Date: Wed, 25 Sep 2024 22:19:50 +0200 Subject: [PATCH] Apply StackResolver --- .../api/events/PlayerRightClickEvent.java | 5 +- .../api/items/SlimefunItemStack.java | 7 +- .../slimefun4/api/recipes/RecipeType.java | 3 +- .../core/guide/options/GuideModeOption.java | 3 +- .../networks/cargo/ItemStackAndInteger.java | 3 +- .../localization/SlimefunLocalization.java | 3 +- .../guide/SurvivalSlimefunGuide.java | 5 +- .../items/androids/FarmerAndroid.java | 15 +- .../items/androids/FishermanAndroid.java | 25 +- .../items/androids/MinerAndroid.java | 3 +- .../items/androids/ProgrammableAndroid.java | 21 +- .../items/androids/WoodcutterAndroid.java | 5 +- .../autocrafters/AbstractAutoCrafter.java | 5 +- .../items/autocrafters/VanillaRecipe.java | 5 +- .../items/blocks/Composter.java | 21 +- .../implementation/items/blocks/Crucible.java | 49 +- .../electric/generators/BioGenerator.java | 97 +-- .../electric/generators/CoalGenerator.java | 33 +- .../generators/CombustionGenerator.java | 3 +- .../electric/generators/LavaGenerator.java | 5 +- .../generators/MagnesiumGenerator.java | 3 +- .../items/electric/machines/AutoAnvil.java | 3 +- .../items/electric/machines/AutoBrewer.java | 35 +- .../items/electric/machines/AutoDrier.java | 57 +- .../items/electric/machines/CarbonPress.java | 9 +- .../electric/machines/ChargingBench.java | 3 +- .../electric/machines/ElectricDustWasher.java | 7 +- .../electric/machines/ElectricFurnace.java | 5 +- .../electric/machines/ElectricGoldPan.java | 3 +- .../machines/ElectricIngotFactory.java | 3 +- .../machines/ElectricIngotPulverizer.java | 7 +- .../electric/machines/ElectricOreGrinder.java | 2 +- .../electric/machines/ElectricPress.java | 65 +- .../electric/machines/ElectricSmeltery.java | 3 +- .../machines/ElectrifiedCrucible.java | 27 +- .../items/electric/machines/FluidPump.java | 14 +- .../electric/machines/FoodComposter.java | 3 +- .../electric/machines/FoodFabricator.java | 25 +- .../items/electric/machines/Freezer.java | 23 +- .../machines/HeatedPressureChamber.java | 5 +- .../items/electric/machines/Refinery.java | 3 +- .../machines/enchanting/AutoDisenchanter.java | 5 +- .../machines/enchanting/AutoEnchanter.java | 5 +- .../machines/enchanting/BookBinder.java | 5 +- .../machines/entities/AutoBreeder.java | 3 +- .../machines/entities/IronGolemAssembler.java | 5 +- .../machines/entities/ProduceCollector.java | 13 +- .../machines/entities/WitherAssembler.java | 5 +- .../electric/reactors/NetherStarReactor.java | 7 +- .../implementation/items/food/Juice.java | 5 +- .../implementation/items/geo/GEOMiner.java | 3 +- .../implementation/items/geo/OilPump.java | 5 +- .../items/magical/runes/EnchantmentRune.java | 3 +- .../items/misc/OrganicFood.java | 3 +- .../items/multiblocks/ArmorForge.java | 3 +- .../multiblocks/AutomatedPanningMachine.java | 3 +- .../items/multiblocks/Compressor.java | 15 +- .../multiblocks/EnhancedCraftingTable.java | 3 +- .../items/multiblocks/GrindStone.java | 75 +-- .../items/multiblocks/Juicer.java | 3 +- .../items/multiblocks/MagicWorkbench.java | 3 +- .../items/multiblocks/MakeshiftSmeltery.java | 3 +- .../items/multiblocks/OreCrusher.java | 77 +-- .../items/multiblocks/OreWasher.java | 11 +- .../items/multiblocks/PressureChamber.java | 3 +- .../items/multiblocks/Smeltery.java | 5 +- .../items/multiblocks/TableSaw.java | 17 +- .../miner/AdvancedIndustrialMiner.java | 3 +- .../multiblocks/miner/IndustrialMiner.java | 19 +- .../items/multiblocks/miner/MiningTask.java | 3 +- .../multiblocks/miner/OreDictionary16.java | 23 +- .../multiblocks/miner/OreDictionary17.java | 17 +- .../items/tools/ClimbingPick.java | 3 +- .../implementation/items/tools/GoldPan.java | 13 +- .../items/tools/NetherGoldPan.java | 13 +- .../items/tools/PickaxeOfContainment.java | 3 +- .../items/tools/PickaxeOfVeinMining.java | 3 +- .../items/weapons/SwordOfBeheading.java | 13 +- .../listeners/BlockPhysicsListener.java | 3 +- .../listeners/ButcherAndroidListener.java | 7 +- .../listeners/EnhancedFurnaceListener.java | 3 +- .../listeners/TalismanListener.java | 3 +- .../setup/SlimefunItemSetup.java | 577 +++++++++--------- .../tasks/AsyncRecipeChoiceTask.java | 3 +- .../slimefun4/utils/SlimefunUtils.java | 3 +- .../abstractItems/AGenerator.java | 3 +- 86 files changed, 854 insertions(+), 770 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java index 30c9c927af..68f742be49 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java @@ -4,6 +4,7 @@ import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.block.Block; @@ -92,13 +93,13 @@ public PlayerInteractEvent getInteractEvent() { /** * This method returns the {@link ItemStack} that was held in the hand of the {@link Player}. * It will never return null, should there be no {@link ItemStack} then it will return - * {@code new ItemStack(Material.AIR)}. + * {@code StackResolver.of(Material.AIR)}. * * @return The {@link ItemStack} that the {@link Player} right clicked with */ @Nonnull public ItemStack getItem() { - return itemStack.orElse(new ItemStack(Material.AIR)); + return itemStack.orElse(StackResolver.of(Material.AIR)); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java index 8ae4a86baa..511ef70992 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java @@ -11,6 +11,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -78,7 +79,7 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nonnull C } public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Consumer consumer) { - this(id, new ItemStack(type), consumer); + this(id, StackResolver.of(type), consumer); } public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, @Nonnull Consumer consumer) { @@ -109,7 +110,7 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nullable } public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, String... lore) { - this(id, new ItemStack(type), name, lore); + this(id, StackResolver.of(type), name, lore); } public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Color color, @Nullable String name, String... lore) { @@ -284,7 +285,7 @@ public void lock() { private static @Nonnull ItemStack getSkull(@Nonnull String id, @Nonnull String texture) { if (Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { - return new ItemStack(Material.PLAYER_HEAD); + return StackResolver.of(Material.PLAYER_HEAD); } PlayerSkin skin = PlayerSkin.fromBase64(getTexture(id, texture)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java index e22c947b67..f4bd723198 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java @@ -13,6 +13,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.ChatColor; import org.bukkit.Keyed; import org.bukkit.Material; @@ -113,7 +114,7 @@ public RecipeType(NamespacedKey key, ItemStack item) { } public RecipeType(MinecraftRecipe recipe) { - this.item = new ItemStack(recipe.getMachine()); + this.item = StackResolver.of(recipe.getMachine()); this.machine = ""; this.key = NamespacedKey.minecraft(recipe.getRecipeClass().getSimpleName().toLowerCase(Locale.ROOT).replace("recipe", "")); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java index f86694211d..615fac3ad4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java @@ -7,6 +7,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -47,7 +48,7 @@ public Optional getDisplayItem(Player p, ItemStack guide) { if (current.isPresent()) { SlimefunGuideMode selectedMode = current.get(); - ItemStack item = new ItemStack(Material.AIR); + ItemStack item = StackResolver.of(Material.AIR); if (selectedMode == SlimefunGuideMode.SURVIVAL_MODE) { item.setType(Material.CHEST); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java index d149efdc79..367673b9ad 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java @@ -2,6 +2,7 @@ import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.inventory.ItemStack; @@ -42,7 +43,7 @@ public void add(int amount) { private void initializeItem() { if (this.item instanceof ItemStackWrapper) { - ItemStack copy = new ItemStack(item.getType(), item.getAmount()); + ItemStack copy = StackResolver.of(item.getType(), item.getAmount()); if (this.item.hasItemMeta()) { copy.setItemMeta(this.item.getItemMeta()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java index 893e3baf21..0e05b4034e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java @@ -11,6 +11,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Keyed; @@ -315,7 +316,7 @@ protected void loadEmbeddedLanguages() { if (item == null) { // Fixes #3088 - return new ItemStack(Material.AIR); + return StackResolver.of(Material.AIR); } Language language = getLanguage(p); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index 83e43be65f..e3d15c1e35 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -11,6 +11,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -484,7 +485,7 @@ private void showRecipeChoices(T recipe, ItemStack[] recipeIt RecipeChoice[] choices = Slimefun.getMinecraftRecipeService().getRecipeShape(recipe); if (choices.length == 1 && choices[0] instanceof MaterialChoice materialChoice) { - recipeItems[4] = new ItemStack(materialChoice.getChoices().get(0)); + recipeItems[4] = StackResolver.of(materialChoice.getChoices().get(0)); if (materialChoice.getChoices().size() > 1) { task.add(recipeSlots[4], materialChoice); @@ -492,7 +493,7 @@ private void showRecipeChoices(T recipe, ItemStack[] recipeIt } else { for (int i = 0; i < choices.length; i++) { if (choices[i] instanceof MaterialChoice materialChoice) { - recipeItems[i] = new ItemStack(materialChoice.getChoices().get(0)); + recipeItems[i] = StackResolver.of(materialChoice.getChoices().get(0)); if (materialChoice.getChoices().size() > 1) { task.add(recipeSlots[i], materialChoice); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java index cd8b72c723..e3352f088b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java @@ -5,6 +5,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -69,13 +70,13 @@ private ItemStack getDropFromCrop(Material crop) { Random random = ThreadLocalRandom.current(); return switch (crop) { - case WHEAT -> new ItemStack(Material.WHEAT, random.nextInt(2) + 1); - case POTATOES -> new ItemStack(Material.POTATO, random.nextInt(3) + 1); - case CARROTS -> new ItemStack(Material.CARROT, random.nextInt(3) + 1); - case BEETROOTS -> new ItemStack(Material.BEETROOT, random.nextInt(3) + 1); - case COCOA -> new ItemStack(Material.COCOA_BEANS, random.nextInt(3) + 1); - case NETHER_WART -> new ItemStack(Material.NETHER_WART, random.nextInt(3) + 1); - case SWEET_BERRY_BUSH -> new ItemStack(Material.SWEET_BERRIES, random.nextInt(3) + 1); + case WHEAT -> StackResolver.of(Material.WHEAT, random.nextInt(2) + 1); + case POTATOES -> StackResolver.of(Material.POTATO, random.nextInt(3) + 1); + case CARROTS -> StackResolver.of(Material.CARROT, random.nextInt(3) + 1); + case BEETROOTS -> StackResolver.of(Material.BEETROOT, random.nextInt(3) + 1); + case COCOA -> StackResolver.of(Material.COCOA_BEANS, random.nextInt(3) + 1); + case NETHER_WART -> StackResolver.of(Material.NETHER_WART, random.nextInt(3) + 1); + case SWEET_BERRY_BUSH -> StackResolver.of(Material.SWEET_BERRIES, random.nextInt(3) + 1); default -> null; }; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java index a6ce80e2fe..06d7c088df 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java @@ -4,6 +4,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.block.Block; @@ -28,23 +29,23 @@ public FishermanAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, R // Fish for (Material fish : Tag.ITEMS_FISHES.getValues()) { - fishingLoot.add(new ItemStack(fish), 25); + fishingLoot.add(StackResolver.of(fish), 25); } // Junk - fishingLoot.add(new ItemStack(Material.BONE), 10); - fishingLoot.add(new ItemStack(Material.STRING), 10); - fishingLoot.add(new ItemStack(Material.INK_SAC), 8); - fishingLoot.add(new ItemStack(Material.KELP), 6); - fishingLoot.add(new ItemStack(Material.STICK), 5); - fishingLoot.add(new ItemStack(Material.ROTTEN_FLESH), 3); - fishingLoot.add(new ItemStack(Material.LEATHER), 2); - fishingLoot.add(new ItemStack(Material.BAMBOO), 3); + fishingLoot.add(StackResolver.of(Material.BONE), 10); + fishingLoot.add(StackResolver.of(Material.STRING), 10); + fishingLoot.add(StackResolver.of(Material.INK_SAC), 8); + fishingLoot.add(StackResolver.of(Material.KELP), 6); + fishingLoot.add(StackResolver.of(Material.STICK), 5); + fishingLoot.add(StackResolver.of(Material.ROTTEN_FLESH), 3); + fishingLoot.add(StackResolver.of(Material.LEATHER), 2); + fishingLoot.add(StackResolver.of(Material.BAMBOO), 3); // "loot" - fishingLoot.add(new ItemStack(Material.SADDLE), 1); - fishingLoot.add(new ItemStack(Material.NAME_TAG), 1); - fishingLoot.add(new ItemStack(Material.NAUTILUS_SHELL), 1); + fishingLoot.add(StackResolver.of(Material.SADDLE), 1); + fishingLoot.add(StackResolver.of(Material.NAME_TAG), 1); + fishingLoot.add(StackResolver.of(Material.NAUTILUS_SHELL), 1); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java index 8d041bafb5..f704dd73c4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -52,7 +53,7 @@ public class MinerAndroid extends ProgrammableAndroid { // Determines the drops a miner android will get - private final ItemStack effectivePickaxe = new ItemStack(Material.DIAMOND_PICKAXE); + private final ItemStack effectivePickaxe = StackResolver.of(Material.DIAMOND_PICKAXE); private final ItemSetting firesEvent = new ItemSetting<>(this, "trigger-event-for-generators", false); private final ItemSetting applyOptimizations = new ItemSetting<>(this, "reduced-block-updates", true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index 8db9826bc7..2543737b45 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -10,6 +10,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -595,27 +596,27 @@ public void setScript(@Nonnull Location l, @Nonnull String script) { private void registerDefaultFuelTypes() { switch (getFuelSource()) { case SOLID -> { - registerFuelType(new MachineFuel(80, new ItemStack(Material.COAL_BLOCK))); - registerFuelType(new MachineFuel(45, new ItemStack(Material.BLAZE_ROD))); - registerFuelType(new MachineFuel(70, new ItemStack(Material.DRIED_KELP_BLOCK))); + registerFuelType(new MachineFuel(80, StackResolver.of(Material.COAL_BLOCK))); + registerFuelType(new MachineFuel(45, StackResolver.of(Material.BLAZE_ROD))); + registerFuelType(new MachineFuel(70, StackResolver.of(Material.DRIED_KELP_BLOCK))); // Coal, Charcoal & Bamboo - registerFuelType(new MachineFuel(8, new ItemStack(Material.COAL))); - registerFuelType(new MachineFuel(8, new ItemStack(Material.CHARCOAL))); - registerFuelType(new MachineFuel(1, new ItemStack(Material.BAMBOO))); + registerFuelType(new MachineFuel(8, StackResolver.of(Material.COAL))); + registerFuelType(new MachineFuel(8, StackResolver.of(Material.CHARCOAL))); + registerFuelType(new MachineFuel(1, StackResolver.of(Material.BAMBOO))); // Logs for (Material mat : Tag.LOGS.getValues()) { - registerFuelType(new MachineFuel(2, new ItemStack(mat))); + registerFuelType(new MachineFuel(2, StackResolver.of(mat))); } // Wooden Planks for (Material mat : Tag.PLANKS.getValues()) { - registerFuelType(new MachineFuel(1, new ItemStack(mat))); + registerFuelType(new MachineFuel(1, StackResolver.of(mat))); } } case LIQUID -> { - registerFuelType(new MachineFuel(100, new ItemStack(Material.LAVA_BUCKET))); + registerFuelType(new MachineFuel(100, StackResolver.of(Material.LAVA_BUCKET))); registerFuelType(new MachineFuel(200, SlimefunItems.OIL_BUCKET)); registerFuelType(new MachineFuel(500, SlimefunItems.FUEL_BUCKET)); } @@ -828,7 +829,7 @@ private void consumeFuel(Block b, BlockMenu menu) { menu.consumeItem(43); if (getFuelSource() == AndroidFuelSource.LIQUID) { - menu.pushItem(new ItemStack(Material.BUCKET), getOutputSlots()); + menu.pushItem(StackResolver.of(Material.BUCKET), getOutputSlots()); } int fuelLevel = fuel.getTicks(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java index 0133cb3b25..ffb78c9fd0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java @@ -7,6 +7,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -71,7 +72,7 @@ protected boolean chopTree(Block b, BlockMenu menu, BlockFace face) { @ParametersAreNonnullByDefault private void breakLog(Block log, Block android, BlockMenu menu, BlockFace face) { - ItemStack drop = new ItemStack(log.getType()); + ItemStack drop = StackResolver.of(log.getType()); // We try to push the log into the android's inventory, but nothing happens if it does not fit menu.pushItem(drop, getOutputSlots()); @@ -179,7 +180,7 @@ private void replant(@Nonnull Block block) { block.setType(saplingType); } else { // Simply drop the sapling if the soil does not fit - block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(saplingType)); + block.getWorld().dropItemNaturally(block.getLocation(), StackResolver.of(saplingType)); block.setType(Material.AIR); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java index b75d3c6643..a91361f0e8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java @@ -10,6 +10,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.Material; @@ -474,10 +475,10 @@ private ItemStack getLeftoverItem(@Nonnull ItemStack item) { return switch (type) { case WATER_BUCKET, LAVA_BUCKET, - MILK_BUCKET -> new ItemStack(Material.BUCKET); + MILK_BUCKET -> StackResolver.of(Material.BUCKET); case DRAGON_BREATH, POTION, - HONEY_BOTTLE -> new ItemStack(Material.GLASS_BOTTLE); + HONEY_BOTTLE -> StackResolver.of(Material.GLASS_BOTTLE); default -> null; }; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java index 0654c4e366..36ff530da2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java @@ -7,6 +7,7 @@ import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.Keyed; import org.bukkit.inventory.ItemStack; @@ -82,7 +83,7 @@ public void show(@Nonnull ChestMenu menu, @Nonnull AsyncRecipeChoiceTask task) { ItemStack[] items = new ItemStack[9]; if (choices.length == 1 && choices[0] instanceof MaterialChoice materialChoice) { - items[4] = new ItemStack(materialChoice.getChoices().get(0)); + items[4] = StackResolver.of(materialChoice.getChoices().get(0)); if (materialChoice.getChoices().size() > 1) { task.add(slots[4], materialChoice); @@ -90,7 +91,7 @@ public void show(@Nonnull ChestMenu menu, @Nonnull AsyncRecipeChoiceTask task) { } else { for (int i = 0; i < choices.length; i++) { if (choices[i] instanceof MaterialChoice materialChoice) { - items[i] = new ItemStack(materialChoice.getChoices().get(0)); + items[i] = StackResolver.of(materialChoice.getChoices().get(0)); if (materialChoice.getChoices().size() > 1) { task.add(slots[i], materialChoice); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java index ee0e546090..cd80ea7e69 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java @@ -7,6 +7,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; @@ -49,23 +50,23 @@ private List getMachineRecipes() { List items = new LinkedList<>(); for (Material leave : Tag.LEAVES.getValues()) { - items.add(new ItemStack(leave, 8)); - items.add(new ItemStack(Material.DIRT)); + items.add(StackResolver.of(leave, 8)); + items.add(StackResolver.of(Material.DIRT)); } for (Material sapling : Tag.SAPLINGS.getValues()) { - items.add(new ItemStack(sapling, 8)); - items.add(new ItemStack(Material.DIRT)); + items.add(StackResolver.of(sapling, 8)); + items.add(StackResolver.of(Material.DIRT)); } - items.add(new ItemStack(Material.STONE, 4)); - items.add(new ItemStack(Material.NETHERRACK)); + items.add(StackResolver.of(Material.STONE, 4)); + items.add(StackResolver.of(Material.NETHERRACK)); - items.add(new ItemStack(Material.SAND, 2)); - items.add(new ItemStack(Material.SOUL_SAND)); + items.add(StackResolver.of(Material.SAND, 2)); + items.add(StackResolver.of(Material.SOUL_SAND)); - items.add(new ItemStack(Material.WHEAT, 4)); - items.add(new ItemStack(Material.NETHER_WART)); + items.add(StackResolver.of(Material.WHEAT, 4)); + items.add(StackResolver.of(Material.NETHER_WART)); return items; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java index f11e7a35ad..f409eb1589 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java @@ -7,6 +7,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.World.Environment; @@ -65,46 +66,46 @@ public List getDisplayRecipes() { private List getMachineRecipes() { List items = new LinkedList<>(); - items.add(new ItemStack(Material.COBBLESTONE, 16)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.COBBLESTONE, 16)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.NETHERRACK, 16)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.NETHERRACK, 16)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.STONE, 12)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.STONE, 12)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.OBSIDIAN, 1)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.OBSIDIAN, 1)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.TERRACOTTA, 12)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.TERRACOTTA, 12)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); for (Material leave : Tag.LEAVES.getValues()) { - items.add(new ItemStack(leave, 16)); - items.add(new ItemStack(Material.WATER_BUCKET)); + items.add(StackResolver.of(leave, 16)); + items.add(StackResolver.of(Material.WATER_BUCKET)); } for (Material sapling : SlimefunTag.TERRACOTTA.getValues()) { - items.add(new ItemStack(sapling, 12)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(sapling, 12)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); } - items.add(new ItemStack(Material.BLACKSTONE, 8)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.BLACKSTONE, 8)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.BASALT, 12)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.BASALT, 12)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - items.add(new ItemStack(Material.COBBLED_DEEPSLATE, 12)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.COBBLED_DEEPSLATE, 12)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.DEEPSLATE, 10)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.DEEPSLATE, 10)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.TUFF, 8)); - items.add(new ItemStack(Material.LAVA_BUCKET)); + items.add(StackResolver.of(Material.TUFF, 8)); + items.add(StackResolver.of(Material.LAVA_BUCKET)); } return items; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java index cbbf092f6e..fa042b043b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; @@ -25,83 +26,83 @@ public BioGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci @Override protected void registerDefaultFuelTypes() { - registerFuel(new MachineFuel(2, new ItemStack(Material.ROTTEN_FLESH))); - registerFuel(new MachineFuel(2, new ItemStack(Material.SPIDER_EYE))); - registerFuel(new MachineFuel(2, new ItemStack(Material.BONE))); - registerFuel(new MachineFuel(2, new ItemStack(Material.STRING))); - registerFuel(new MachineFuel(3, new ItemStack(Material.APPLE))); - registerFuel(new MachineFuel(3, new ItemStack(Material.MELON_SLICE))); - registerFuel(new MachineFuel(27, new ItemStack(Material.MELON))); - registerFuel(new MachineFuel(3, new ItemStack(Material.PUMPKIN))); - registerFuel(new MachineFuel(3, new ItemStack(Material.PUMPKIN_SEEDS))); - registerFuel(new MachineFuel(3, new ItemStack(Material.MELON_SEEDS))); - registerFuel(new MachineFuel(3, new ItemStack(Material.WHEAT))); - registerFuel(new MachineFuel(3, new ItemStack(Material.WHEAT_SEEDS))); - registerFuel(new MachineFuel(3, new ItemStack(Material.CARROT))); - registerFuel(new MachineFuel(3, new ItemStack(Material.POTATO))); - registerFuel(new MachineFuel(3, new ItemStack(Material.SUGAR_CANE))); - registerFuel(new MachineFuel(3, new ItemStack(Material.NETHER_WART))); - registerFuel(new MachineFuel(2, new ItemStack(Material.RED_MUSHROOM))); - registerFuel(new MachineFuel(2, new ItemStack(Material.BROWN_MUSHROOM))); - registerFuel(new MachineFuel(2, new ItemStack(Material.VINE))); - registerFuel(new MachineFuel(2, new ItemStack(Material.CACTUS))); - registerFuel(new MachineFuel(2, new ItemStack(Material.LILY_PAD))); - registerFuel(new MachineFuel(8, new ItemStack(Material.CHORUS_FRUIT))); - registerFuel(new MachineFuel(1, new ItemStack(Material.KELP))); - registerFuel(new MachineFuel(2, new ItemStack(Material.DRIED_KELP))); - registerFuel(new MachineFuel(20, new ItemStack(Material.DRIED_KELP_BLOCK))); - registerFuel(new MachineFuel(1, new ItemStack(Material.SEAGRASS))); - registerFuel(new MachineFuel(2, new ItemStack(Material.SEA_PICKLE))); - registerFuel(new MachineFuel(1, new ItemStack(Material.BAMBOO))); - registerFuel(new MachineFuel(2, new ItemStack(Material.SWEET_BERRIES))); - registerFuel(new MachineFuel(2, new ItemStack(Material.COCOA_BEANS))); - registerFuel(new MachineFuel(3, new ItemStack(Material.BEETROOT))); - registerFuel(new MachineFuel(3, new ItemStack(Material.BEETROOT_SEEDS))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.ROTTEN_FLESH))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.SPIDER_EYE))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.BONE))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.STRING))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.APPLE))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.MELON_SLICE))); + registerFuel(new MachineFuel(27, StackResolver.of(Material.MELON))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.PUMPKIN))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.PUMPKIN_SEEDS))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.MELON_SEEDS))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.WHEAT))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.WHEAT_SEEDS))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.CARROT))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.POTATO))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.SUGAR_CANE))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.NETHER_WART))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.RED_MUSHROOM))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.BROWN_MUSHROOM))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.VINE))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.CACTUS))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.LILY_PAD))); + registerFuel(new MachineFuel(8, StackResolver.of(Material.CHORUS_FRUIT))); + registerFuel(new MachineFuel(1, StackResolver.of(Material.KELP))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.DRIED_KELP))); + registerFuel(new MachineFuel(20, StackResolver.of(Material.DRIED_KELP_BLOCK))); + registerFuel(new MachineFuel(1, StackResolver.of(Material.SEAGRASS))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.SEA_PICKLE))); + registerFuel(new MachineFuel(1, StackResolver.of(Material.BAMBOO))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.SWEET_BERRIES))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.COCOA_BEANS))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.BEETROOT))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.BEETROOT_SEEDS))); // Small Flowers (formally just dandelions and poppies). for (Material m : Tag.SMALL_FLOWERS.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(m))); + registerFuel(new MachineFuel(1, StackResolver.of(m))); } - registerFuel(new MachineFuel(4, new ItemStack(Material.HONEYCOMB))); - registerFuel(new MachineFuel(40, new ItemStack(Material.HONEYCOMB_BLOCK))); + registerFuel(new MachineFuel(4, StackResolver.of(Material.HONEYCOMB))); + registerFuel(new MachineFuel(40, StackResolver.of(Material.HONEYCOMB_BLOCK))); - registerFuel(new MachineFuel(4, new ItemStack(Material.SHROOMLIGHT))); - registerFuel(new MachineFuel(2, new ItemStack(Material.CRIMSON_FUNGUS))); - registerFuel(new MachineFuel(2, new ItemStack(Material.WARPED_FUNGUS))); + registerFuel(new MachineFuel(4, StackResolver.of(Material.SHROOMLIGHT))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.CRIMSON_FUNGUS))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.WARPED_FUNGUS))); registerFuel(new MachineFuel(16, SlimefunItems.STRANGE_NETHER_GOO)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - registerFuel(new MachineFuel(2, new ItemStack(Material.GLOW_BERRIES))); - registerFuel(new MachineFuel(3, new ItemStack(Material.SMALL_DRIPLEAF))); - registerFuel(new MachineFuel(3, new ItemStack(Material.BIG_DRIPLEAF))); - registerFuel(new MachineFuel(2, new ItemStack(Material.GLOW_LICHEN))); - registerFuel(new MachineFuel(20, new ItemStack(Material.SPORE_BLOSSOM))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.GLOW_BERRIES))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.SMALL_DRIPLEAF))); + registerFuel(new MachineFuel(3, StackResolver.of(Material.BIG_DRIPLEAF))); + registerFuel(new MachineFuel(2, StackResolver.of(Material.GLOW_LICHEN))); + registerFuel(new MachineFuel(20, StackResolver.of(Material.SPORE_BLOSSOM))); } // Leaves for (Material m : Tag.LEAVES.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(m))); + registerFuel(new MachineFuel(1, StackResolver.of(m))); } // Saplings for (Material m : Tag.SAPLINGS.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(m))); + registerFuel(new MachineFuel(1, StackResolver.of(m))); } // Corals for (Material m : Tag.CORALS.getValues()) { - registerFuel(new MachineFuel(2, new ItemStack(m))); + registerFuel(new MachineFuel(2, StackResolver.of(m))); } for (Material m : Tag.CORAL_BLOCKS.getValues()) { - registerFuel(new MachineFuel(2, new ItemStack(m))); + registerFuel(new MachineFuel(2, StackResolver.of(m))); } } @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_HOE); + return StackResolver.of(Material.GOLDEN_HOE); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java index cb2a488441..9a60572695 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java @@ -3,6 +3,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; @@ -23,69 +24,69 @@ public CoalGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec @Override protected void registerDefaultFuelTypes() { - registerFuel(new MachineFuel(80, new ItemStack(Material.COAL_BLOCK))); - registerFuel(new MachineFuel(12, new ItemStack(Material.BLAZE_ROD))); - registerFuel(new MachineFuel(20, new ItemStack(Material.DRIED_KELP_BLOCK))); + registerFuel(new MachineFuel(80, StackResolver.of(Material.COAL_BLOCK))); + registerFuel(new MachineFuel(12, StackResolver.of(Material.BLAZE_ROD))); + registerFuel(new MachineFuel(20, StackResolver.of(Material.DRIED_KELP_BLOCK))); // Boats for (Material mat : Tag.ITEMS_BOATS.getValues()) { - registerFuel(new MachineFuel(5, new ItemStack(mat))); + registerFuel(new MachineFuel(5, StackResolver.of(mat))); } // Coal & Charcoal - registerFuel(new MachineFuel(8, new ItemStack(Material.COAL))); - registerFuel(new MachineFuel(8, new ItemStack(Material.CHARCOAL))); + registerFuel(new MachineFuel(8, StackResolver.of(Material.COAL))); + registerFuel(new MachineFuel(8, StackResolver.of(Material.CHARCOAL))); // Logs for (Material mat : Tag.LOGS.getValues()) { - registerFuel(new MachineFuel(4, new ItemStack(mat))); + registerFuel(new MachineFuel(4, StackResolver.of(mat))); } // Wooden Planks for (Material mat : Tag.PLANKS.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(mat))); + registerFuel(new MachineFuel(1, StackResolver.of(mat))); } // Wooden Slabs for (Material mat : Tag.WOODEN_SLABS.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(mat))); + registerFuel(new MachineFuel(1, StackResolver.of(mat))); } // Wooden Buttons for (Material mat : Tag.WOODEN_BUTTONS.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(mat))); + registerFuel(new MachineFuel(1, StackResolver.of(mat))); } // Wooden Fences for (Material mat : Tag.WOODEN_FENCES.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(mat))); + registerFuel(new MachineFuel(1, StackResolver.of(mat))); } // wooden Trapdoors for (Material mat : Tag.WOODEN_TRAPDOORS.getValues()) { - registerFuel(new MachineFuel(3, new ItemStack(mat))); + registerFuel(new MachineFuel(3, StackResolver.of(mat))); } // Wooden Pressure Plates for (Material mat : Tag.WOODEN_PRESSURE_PLATES.getValues()) { - registerFuel(new MachineFuel(2, new ItemStack(mat))); + registerFuel(new MachineFuel(2, StackResolver.of(mat))); } // Wooden Doors for (Material mat : Tag.WOODEN_DOORS.getValues()) { - registerFuel(new MachineFuel(2, new ItemStack(mat))); + registerFuel(new MachineFuel(2, StackResolver.of(mat))); } // Signs for (Material mat : Tag.STANDING_SIGNS.getValues()) { - registerFuel(new MachineFuel(2, new ItemStack(mat))); + registerFuel(new MachineFuel(2, StackResolver.of(mat))); } } @Nonnull @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java index 6d9bc6993b..5836533a69 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -28,7 +29,7 @@ protected void registerDefaultFuelTypes() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java index 59100fbeb1..2e16c1f211 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -21,12 +22,12 @@ public LavaGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec @Override protected void registerDefaultFuelTypes() { - registerFuel(new MachineFuel(40, new ItemStack(Material.LAVA_BUCKET))); + registerFuel(new MachineFuel(40, StackResolver.of(Material.LAVA_BUCKET))); } @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java index 110b7fff05..b59f44cdbc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -27,7 +28,7 @@ protected void registerDefaultFuelTypes() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java index 16329948bf..2673392479 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; @@ -34,7 +35,7 @@ public AutoAnvil(ItemGroup itemGroup, int repairFactor, SlimefunItemStack item, @Override public ItemStack getProgressBar() { - return new ItemStack(Material.IRON_PICKAXE); + return StackResolver.of(Material.IRON_PICKAXE); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java index 962bc2d32f..187269eed8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java @@ -8,6 +8,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; @@ -112,36 +113,36 @@ public AutoBrewer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe if (type == PotionType.WATER) { if (input == Material.FERMENTED_SPIDER_EYE) { potion.setBasePotionType(PotionType.WEAKNESS); - return new ItemStack(potionType); + return StackResolver.of(potionType); } else if (input == Material.NETHER_WART) { potion.setBasePotionType(PotionType.AWKWARD); - return new ItemStack(potionType); + return StackResolver.of(potionType); } else if (potionType == Material.POTION && input == Material.GUNPOWDER) { - return new ItemStack(Material.SPLASH_POTION); + return StackResolver.of(Material.SPLASH_POTION); } else if (potionType == Material.SPLASH_POTION && input == Material.DRAGON_BREATH) { - return new ItemStack(Material.LINGERING_POTION); + return StackResolver.of(Material.LINGERING_POTION); } } else if (input == Material.FERMENTED_SPIDER_EYE) { PotionType fermented = fermentations.get(type); if (fermented != null) { potion.setBasePotionType(fermented); - return new ItemStack(potionType); + return StackResolver.of(potionType); } } else if (input == Material.REDSTONE && type.isExtendable() && !type.isUpgradeable()) { // Fixes #3390 - Potions can only be either extended or upgraded. Not both. potion.setBasePotionType(type); - return new ItemStack(potionType); + return StackResolver.of(potionType); } else if (input == Material.GLOWSTONE_DUST && type.isUpgradeable() && !type.isExtendable()) { // Fixes #3390 - Potions can only be either extended or upgraded. Not both. potion.setBasePotionType(type); - return new ItemStack(potionType); + return StackResolver.of(potionType); } else if (type == PotionType.AWKWARD) { PotionType potionRecipe = potionRecipes.get(input); if (potionRecipe != null) { potion.setBasePotionType(potionRecipe); - return new ItemStack(potionType); + return StackResolver.of(potionType); } } @@ -156,36 +157,36 @@ private ItemStack brewPreBasePotionType(Material input, Material potionType, Pot if (type == PotionType.WATER) { if (input == Material.FERMENTED_SPIDER_EYE) { potion.setBasePotionData(new PotionData(PotionType.WEAKNESS, false, false)); - return new ItemStack(potionType); + return StackResolver.of(potionType); } else if (input == Material.NETHER_WART) { potion.setBasePotionData(new PotionData(PotionType.AWKWARD, false, false)); - return new ItemStack(potionType); + return StackResolver.of(potionType); } else if (potionType == Material.POTION && input == Material.GUNPOWDER) { - return new ItemStack(Material.SPLASH_POTION); + return StackResolver.of(Material.SPLASH_POTION); } else if (potionType == Material.SPLASH_POTION && input == Material.DRAGON_BREATH) { - return new ItemStack(Material.LINGERING_POTION); + return StackResolver.of(Material.LINGERING_POTION); } } else if (input == Material.FERMENTED_SPIDER_EYE) { PotionType fermented = fermentations.get(type); if (fermented != null) { potion.setBasePotionData(new PotionData(fermented, data.isExtended(), data.isUpgraded())); - return new ItemStack(potionType); + return StackResolver.of(potionType); } } else if (input == Material.REDSTONE && type.isExtendable() && !data.isUpgraded()) { // Fixes #3390 - Potions can only be either extended or upgraded. Not both. potion.setBasePotionData(new PotionData(type, true, false)); - return new ItemStack(potionType); + return StackResolver.of(potionType); } else if (input == Material.GLOWSTONE_DUST && type.isUpgradeable() && !data.isExtended()) { // Fixes #3390 - Potions can only be either extended or upgraded. Not both. potion.setBasePotionData(new PotionData(type, false, true)); - return new ItemStack(potionType); + return StackResolver.of(potionType); } else if (type == PotionType.AWKWARD) { PotionType potionRecipe = potionRecipes.get(input); if (potionRecipe != null) { potion.setBasePotionData(new PotionData(potionRecipe, false, false)); - return new ItemStack(potionType); + return StackResolver.of(potionType); } } return null; @@ -205,7 +206,7 @@ private boolean isPotion(@Nonnull Material mat) { @Override public @Nonnull ItemStack getProgressBar() { - return new ItemStack(Material.FISHING_ROD); + return StackResolver.of(Material.FISHING_ROD); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java index 0be46da7f9..61d64280c0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java @@ -7,6 +7,7 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; @@ -40,61 +41,61 @@ public AutoDrier(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeT @Override protected void registerDefaultRecipes() { recipeList = new ArrayList<>(); - recipeList.add(new ItemStack(Material.ROTTEN_FLESH)); - recipeList.add(new ItemStack(Material.LEATHER)); + recipeList.add(StackResolver.of(Material.ROTTEN_FLESH)); + recipeList.add(StackResolver.of(Material.LEATHER)); - recipeList.add(new ItemStack(Material.WET_SPONGE)); - recipeList.add(new ItemStack(Material.SPONGE)); + recipeList.add(StackResolver.of(Material.WET_SPONGE)); + recipeList.add(StackResolver.of(Material.SPONGE)); - recipeList.add(new ItemStack(Material.KELP)); - recipeList.add(new ItemStack(Material.DRIED_KELP)); + recipeList.add(StackResolver.of(Material.KELP)); + recipeList.add(StackResolver.of(Material.DRIED_KELP)); - recipeList.add(new ItemStack(Material.POTION)); - recipeList.add(new ItemStack(Material.GLASS_BOTTLE)); + recipeList.add(StackResolver.of(Material.POTION)); + recipeList.add(StackResolver.of(Material.GLASS_BOTTLE)); - recipeList.add(new ItemStack(Material.SPLASH_POTION)); - recipeList.add(new ItemStack(Material.GLASS_BOTTLE)); + recipeList.add(StackResolver.of(Material.SPLASH_POTION)); + recipeList.add(StackResolver.of(Material.GLASS_BOTTLE)); - recipeList.add(new ItemStack(Material.LINGERING_POTION)); - recipeList.add(new ItemStack(Material.GLASS_BOTTLE)); + recipeList.add(StackResolver.of(Material.LINGERING_POTION)); + recipeList.add(StackResolver.of(Material.GLASS_BOTTLE)); - recipeList.add(new ItemStack(Material.WATER_BUCKET)); - recipeList.add(new ItemStack(Material.BUCKET)); + recipeList.add(StackResolver.of(Material.WATER_BUCKET)); + recipeList.add(StackResolver.of(Material.BUCKET)); - recipeList.add(new ItemStack(Material.COOKED_BEEF)); + recipeList.add(StackResolver.of(Material.COOKED_BEEF)); recipeList.add(SlimefunItems.BEEF_JERKY); - recipeList.add(new ItemStack(Material.COOKED_PORKCHOP)); + recipeList.add(StackResolver.of(Material.COOKED_PORKCHOP)); recipeList.add(SlimefunItems.PORK_JERKY); - recipeList.add(new ItemStack(Material.COOKED_CHICKEN)); + recipeList.add(StackResolver.of(Material.COOKED_CHICKEN)); recipeList.add(SlimefunItems.CHICKEN_JERKY); - recipeList.add(new ItemStack(Material.COOKED_MUTTON)); + recipeList.add(StackResolver.of(Material.COOKED_MUTTON)); recipeList.add(SlimefunItems.MUTTON_JERKY); - recipeList.add(new ItemStack(Material.COOKED_RABBIT)); + recipeList.add(StackResolver.of(Material.COOKED_RABBIT)); recipeList.add(SlimefunItems.RABBIT_JERKY); - recipeList.add(new ItemStack(Material.COOKED_COD)); + recipeList.add(StackResolver.of(Material.COOKED_COD)); recipeList.add(SlimefunItems.FISH_JERKY); - recipeList.add(new ItemStack(Material.COOKED_SALMON)); + recipeList.add(StackResolver.of(Material.COOKED_SALMON)); recipeList.add(SlimefunItems.FISH_JERKY); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_19)) { - recipeList.add(new ItemStack(Material.MUD)); - recipeList.add(new ItemStack(Material.CLAY)); + recipeList.add(StackResolver.of(Material.MUD)); + recipeList.add(StackResolver.of(Material.CLAY)); } for (Material sapling : Tag.SAPLINGS.getValues()) { - recipeList.add(new ItemStack(sapling)); - recipeList.add(new ItemStack(Material.STICK, 2)); + recipeList.add(StackResolver.of(sapling)); + recipeList.add(StackResolver.of(Material.STICK, 2)); } for (Material leaves : Tag.LEAVES.getValues()) { - recipeList.add(new ItemStack(leaves)); - recipeList.add(new ItemStack(Material.STICK)); + recipeList.add(StackResolver.of(leaves)); + recipeList.add(StackResolver.of(Material.STICK)); } // Now convert them to machine recipes @@ -105,7 +106,7 @@ protected void registerDefaultRecipes() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java index 4772b718d4..cc75cee8ee 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -23,9 +24,9 @@ public CarbonPress(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recip @Override protected void registerDefaultRecipes() { - registerRecipe(15, new ItemStack[] { new ItemStack(Material.CHARCOAL, 4) }, new ItemStack[] { new ItemStack(Material.COAL) }); - registerRecipe(20, new ItemStack[] { new ItemStack(Material.COAL, 8) }, new ItemStack[] { SlimefunItems.CARBON }); - registerRecipe(180, new ItemStack[] { new ItemStack(Material.COAL_BLOCK, 8) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.CARBON, 9) }); + registerRecipe(15, new ItemStack[] { StackResolver.of(Material.CHARCOAL, 4) }, new ItemStack[] { StackResolver.of(Material.COAL) }); + registerRecipe(20, new ItemStack[] { StackResolver.of(Material.COAL, 8) }, new ItemStack[] { SlimefunItems.CARBON }); + registerRecipe(180, new ItemStack[] { StackResolver.of(Material.COAL_BLOCK, 8) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.CARBON, 9) }); registerRecipe(30, new ItemStack[] { new CustomItemStack(SlimefunItems.CARBON, 4) }, new ItemStack[] { SlimefunItems.COMPRESSED_CARBON }); registerRecipe(60, new ItemStack[] { SlimefunItems.CARBON_CHUNK, SlimefunItems.SYNTHETIC_DIAMOND }, new ItemStack[] { SlimefunItems.RAW_CARBONADO }); registerRecipe(60, new ItemStack[] { SlimefunItems.CARBON_CHUNK }, new ItemStack[] { SlimefunItems.SYNTHETIC_DIAMOND }); @@ -39,7 +40,7 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.DIAMOND_PICKAXE); + return StackResolver.of(Material.DIAMOND_PICKAXE); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java index b535e44b40..1586ee4e3b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; @@ -30,7 +31,7 @@ public ChargingBench(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_PICKAXE); + return StackResolver.of(Material.GOLDEN_PICKAXE); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java index ad56c3d8a9..e94fc77f1d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java @@ -3,6 +3,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -40,7 +41,7 @@ public ElectricDustWasher(ItemGroup itemGroup, SlimefunItemStack item, RecipeTyp @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_SHOVEL); + return StackResolver.of(Material.GOLDEN_SHOVEL); } @Override @@ -61,8 +62,8 @@ protected MachineRecipe findNextRecipe(BlockMenu menu) { } } else if (SlimefunUtils.isItemSimilar(input, SlimefunItems.PULVERIZED_ORE, true)) { recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { SlimefunItems.PULVERIZED_ORE }, new ItemStack[] { SlimefunItems.PURE_ORE_CLUSTER }); - } else if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SAND), true)) { - recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { new ItemStack(Material.SAND) }, new ItemStack[] { SlimefunItems.SALT }); + } else if (SlimefunUtils.isItemSimilar(input, StackResolver.of(Material.SAND), true)) { + recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { StackResolver.of(Material.SAND) }, new ItemStack[] { SlimefunItems.SALT }); } if (recipe != null && menu.fits(recipe.getOutput()[0], getOutputSlots())) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java index c77e660dfb..99e14ca45b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.block.Furnace; import org.bukkit.inventory.FurnaceRecipe; @@ -39,7 +40,7 @@ public void registerDefaultRecipes() { if (choice instanceof MaterialChoice materialChoice) { for (Material input : materialChoice.getChoices()) { - registerRecipe(4, new ItemStack[] { new ItemStack(input) }, new ItemStack[] { recipe.getResult() }); + registerRecipe(4, new ItemStack[] { StackResolver.of(input) }, new ItemStack[] { recipe.getResult() }); } } } @@ -53,7 +54,7 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java index a454482f8e..6a6371c5b4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -81,7 +82,7 @@ public boolean isOutputLimitOverridden() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.DIAMOND_SHOVEL); + return StackResolver.of(Material.DIAMOND_SHOVEL); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotFactory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotFactory.java index 287383f517..f8de99b798 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotFactory.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotFactory.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -23,7 +24,7 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java index 28c2638822..64de2be995 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -35,7 +36,7 @@ public ElectricIngotPulverizer(ItemGroup itemGroup, SlimefunItemStack item, Reci @Override public ItemStack getProgressBar() { - return new ItemStack(Material.IRON_PICKAXE); + return StackResolver.of(Material.IRON_PICKAXE); } @Override @@ -54,10 +55,10 @@ public List getDisplayRecipes() { protected void registerDefaultRecipes() { // this is an extra recipe on top of PostSetup.loadSmelteryRecipes() for converting // Vanilla Gold Ingot to Slimefun gold dust and Vanilla Copper Ingot into Slimefun copper dust - registerRecipe(3, new ItemStack(Material.GOLD_INGOT), SlimefunItems.GOLD_DUST); + registerRecipe(3, StackResolver.of(Material.GOLD_INGOT), SlimefunItems.GOLD_DUST); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - registerRecipe(3, new ItemStack(Material.COPPER_INGOT), SlimefunItems.COPPER_DUST); + registerRecipe(3, StackResolver.of(Material.COPPER_INGOT), SlimefunItems.COPPER_DUST); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java index 19a6425eea..0fd30e29ac 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java @@ -27,7 +27,7 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.IRON_PICKAXE); + return StackResolver.of(Material.IRON_PICKAXE); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java index b5cb6f2f4d..a70299fd44 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -32,58 +33,58 @@ public ElectricPress(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec @Override protected void registerDefaultRecipes() { - addRecipe(4, new SlimefunItemStack(SlimefunItems.STONE_CHUNK, 3), new ItemStack(Material.COBBLESTONE)); - addRecipe(4, new ItemStack(Material.FLINT, 6), new ItemStack(Material.COBBLESTONE)); - addRecipe(5, new ItemStack(Material.GLASS), new ItemStack(Material.GLASS_PANE, 3)); - addRecipe(4, new ItemStack(Material.SNOWBALL, 4), new ItemStack(Material.SNOW_BLOCK)); - addRecipe(4, new ItemStack(Material.MAGMA_CREAM, 4), new ItemStack(Material.MAGMA_BLOCK)); - addRecipe(4, new ItemStack(Material.SLIME_BALL, 9), new ItemStack(Material.SLIME_BLOCK)); - - addRecipe(3, new ItemStack(Material.DRIED_KELP, 9), new ItemStack(Material.DRIED_KELP_BLOCK)); - addRecipe(3, new ItemStack(Material.BONE_MEAL, 9), new ItemStack(Material.BONE_BLOCK)); - addRecipe(3, new ItemStack(Material.CLAY_BALL, 4), new ItemStack(Material.CLAY)); - addRecipe(3, new ItemStack(Material.BRICK, 4), new ItemStack(Material.BRICKS)); + addRecipe(4, new SlimefunItemStack(SlimefunItems.STONE_CHUNK, 3), StackResolver.of(Material.COBBLESTONE)); + addRecipe(4, StackResolver.of(Material.FLINT, 6), StackResolver.of(Material.COBBLESTONE)); + addRecipe(5, StackResolver.of(Material.GLASS), StackResolver.of(Material.GLASS_PANE, 3)); + addRecipe(4, StackResolver.of(Material.SNOWBALL, 4), StackResolver.of(Material.SNOW_BLOCK)); + addRecipe(4, StackResolver.of(Material.MAGMA_CREAM, 4), StackResolver.of(Material.MAGMA_BLOCK)); + addRecipe(4, StackResolver.of(Material.SLIME_BALL, 9), StackResolver.of(Material.SLIME_BLOCK)); + + addRecipe(3, StackResolver.of(Material.DRIED_KELP, 9), StackResolver.of(Material.DRIED_KELP_BLOCK)); + addRecipe(3, StackResolver.of(Material.BONE_MEAL, 9), StackResolver.of(Material.BONE_BLOCK)); + addRecipe(3, StackResolver.of(Material.CLAY_BALL, 4), StackResolver.of(Material.CLAY)); + addRecipe(3, StackResolver.of(Material.BRICK, 4), StackResolver.of(Material.BRICKS)); addRecipe(6, SlimefunItems.COPPER_INGOT, new CustomItemStack(SlimefunItems.COPPER_WIRE, 3)); addRecipe(16, new SlimefunItemStack(SlimefunItems.STEEL_INGOT, 8), SlimefunItems.STEEL_PLATE); addRecipe(18, new SlimefunItemStack(SlimefunItems.REINFORCED_ALLOY_INGOT, 8), SlimefunItems.REINFORCED_PLATE); - addRecipe(8, new ItemStack(Material.NETHER_WART), new CustomItemStack(SlimefunItems.MAGIC_LUMP_1, 2)); + addRecipe(8, StackResolver.of(Material.NETHER_WART), new CustomItemStack(SlimefunItems.MAGIC_LUMP_1, 2)); addRecipe(10, new SlimefunItemStack(SlimefunItems.MAGIC_LUMP_1, 4), SlimefunItems.MAGIC_LUMP_2); addRecipe(12, new SlimefunItemStack(SlimefunItems.MAGIC_LUMP_2, 4), SlimefunItems.MAGIC_LUMP_3); - addRecipe(10, new ItemStack(Material.ENDER_EYE), new CustomItemStack(SlimefunItems.ENDER_LUMP_1, 2)); + addRecipe(10, StackResolver.of(Material.ENDER_EYE), new CustomItemStack(SlimefunItems.ENDER_LUMP_1, 2)); addRecipe(12, new SlimefunItemStack(SlimefunItems.ENDER_LUMP_1, 4), SlimefunItems.ENDER_LUMP_2); addRecipe(14, new SlimefunItemStack(SlimefunItems.ENDER_LUMP_2, 4), SlimefunItems.ENDER_LUMP_3); addRecipe(18, new SlimefunItemStack(SlimefunItems.TINY_URANIUM, 9), SlimefunItems.SMALL_URANIUM); addRecipe(24, new SlimefunItemStack(SlimefunItems.SMALL_URANIUM, 4), SlimefunItems.URANIUM); - addRecipe(4, new ItemStack(Material.QUARTZ, 4), new ItemStack(Material.QUARTZ_BLOCK)); - addRecipe(4, new ItemStack(Material.IRON_NUGGET, 9), new ItemStack(Material.IRON_INGOT)); - addRecipe(4, new ItemStack(Material.GOLD_NUGGET, 9), new ItemStack(Material.GOLD_INGOT)); - addRecipe(4, new ItemStack(Material.COAL, 9), new ItemStack(Material.COAL_BLOCK)); - addRecipe(4, new ItemStack(Material.SAND, 4), new ItemStack(Material.SANDSTONE)); - addRecipe(4, new ItemStack(Material.RED_SAND, 4), new ItemStack(Material.RED_SANDSTONE)); + addRecipe(4, StackResolver.of(Material.QUARTZ, 4), StackResolver.of(Material.QUARTZ_BLOCK)); + addRecipe(4, StackResolver.of(Material.IRON_NUGGET, 9), StackResolver.of(Material.IRON_INGOT)); + addRecipe(4, StackResolver.of(Material.GOLD_NUGGET, 9), StackResolver.of(Material.GOLD_INGOT)); + addRecipe(4, StackResolver.of(Material.COAL, 9), StackResolver.of(Material.COAL_BLOCK)); + addRecipe(4, StackResolver.of(Material.SAND, 4), StackResolver.of(Material.SANDSTONE)); + addRecipe(4, StackResolver.of(Material.RED_SAND, 4), StackResolver.of(Material.RED_SANDSTONE)); - addRecipe(5, new ItemStack(Material.IRON_INGOT, 9), new ItemStack(Material.IRON_BLOCK)); - addRecipe(5, new ItemStack(Material.GOLD_INGOT, 9), new ItemStack(Material.GOLD_BLOCK)); + addRecipe(5, StackResolver.of(Material.IRON_INGOT, 9), StackResolver.of(Material.IRON_BLOCK)); + addRecipe(5, StackResolver.of(Material.GOLD_INGOT, 9), StackResolver.of(Material.GOLD_BLOCK)); - addRecipe(6, new ItemStack(Material.REDSTONE, 9), new ItemStack(Material.REDSTONE_BLOCK)); - addRecipe(6, new ItemStack(Material.LAPIS_LAZULI, 9), new ItemStack(Material.LAPIS_BLOCK)); + addRecipe(6, StackResolver.of(Material.REDSTONE, 9), StackResolver.of(Material.REDSTONE_BLOCK)); + addRecipe(6, StackResolver.of(Material.LAPIS_LAZULI, 9), StackResolver.of(Material.LAPIS_BLOCK)); - addRecipe(8, new ItemStack(Material.EMERALD, 9), new ItemStack(Material.EMERALD_BLOCK)); - addRecipe(8, new ItemStack(Material.DIAMOND, 9), new ItemStack(Material.DIAMOND_BLOCK)); + addRecipe(8, StackResolver.of(Material.EMERALD, 9), StackResolver.of(Material.EMERALD_BLOCK)); + addRecipe(8, StackResolver.of(Material.DIAMOND, 9), StackResolver.of(Material.DIAMOND_BLOCK)); - addRecipe(16, new ItemStack(Material.NETHERITE_INGOT, 9), new ItemStack(Material.NETHERITE_BLOCK)); + addRecipe(16, StackResolver.of(Material.NETHERITE_INGOT, 9), StackResolver.of(Material.NETHERITE_BLOCK)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - addRecipe(4, new ItemStack(Material.AMETHYST_SHARD, 4), new ItemStack(Material.AMETHYST_BLOCK)); + addRecipe(4, StackResolver.of(Material.AMETHYST_SHARD, 4), StackResolver.of(Material.AMETHYST_BLOCK)); - addRecipe(5, new ItemStack(Material.COPPER_INGOT, 9), new ItemStack(Material.COPPER_BLOCK)); - addRecipe(5, new ItemStack(Material.RAW_IRON, 9), new ItemStack(Material.RAW_IRON_BLOCK)); - addRecipe(5, new ItemStack(Material.RAW_GOLD, 9), new ItemStack(Material.RAW_GOLD_BLOCK)); - addRecipe(5, new ItemStack(Material.RAW_COPPER, 9), new ItemStack(Material.RAW_COPPER_BLOCK)); + addRecipe(5, StackResolver.of(Material.COPPER_INGOT, 9), StackResolver.of(Material.COPPER_BLOCK)); + addRecipe(5, StackResolver.of(Material.RAW_IRON, 9), StackResolver.of(Material.RAW_IRON_BLOCK)); + addRecipe(5, StackResolver.of(Material.RAW_GOLD, 9), StackResolver.of(Material.RAW_GOLD_BLOCK)); + addRecipe(5, StackResolver.of(Material.RAW_COPPER, 9), StackResolver.of(Material.RAW_COPPER_BLOCK)); } } @@ -94,7 +95,7 @@ private void addRecipe(int seconds, ItemStack input, ItemStack output) { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.IRON_HOE); + return StackResolver.of(Material.IRON_HOE); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java index 2218339998..7a6eca4dfc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java @@ -8,6 +8,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -129,7 +130,7 @@ protected void constructMenu(BlockMenuPreset preset) { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java index ff5a33474b..fdaeea0beb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; @@ -21,27 +22,27 @@ public ElectrifiedCrucible(ItemGroup itemGroup, SlimefunItemStack item, RecipeTy @Override protected void registerDefaultRecipes() { - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.COBBLESTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.NETHERRACK, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.STONE, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.TERRACOTTA, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.OBSIDIAN) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.COBBLESTONE, 16) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); + registerRecipe(8, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.NETHERRACK, 16) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); + registerRecipe(8, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.STONE, 12) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); + registerRecipe(8, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.TERRACOTTA, 12) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.OBSIDIAN) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); for (Material terracotta : SlimefunTag.TERRACOTTA.getValues()) { - registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(terracotta, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(8, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(terracotta, 12) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); } for (Material leaves : Tag.LEAVES.getValues()) { - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(leaves, 16) }, new ItemStack[] { new ItemStack(Material.WATER_BUCKET) }); + registerRecipe(10, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(leaves, 16) }, new ItemStack[] { StackResolver.of(Material.WATER_BUCKET) }); } - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BLACKSTONE, 8) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.BLACKSTONE, 8) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.BASALT, 12) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.COBBLED_DEEPSLATE, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.DEEPSLATE, 10) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.TUFF, 8) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.COBBLED_DEEPSLATE, 12) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.DEEPSLATE, 10) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.TUFF, 8) }, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }); } } @@ -52,7 +53,7 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java index 729fd2ff51..2eb4b91ddc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java @@ -57,8 +57,8 @@ public class FluidPump extends SimpleSlimefunItem implements Invent private final int[] inputBorder = { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 }; private final int[] outputBorder = { 14, 15, 16, 17, 23, 26, 32, 33, 34, 35 }; - private final ItemStack emptyBucket = ItemStackWrapper.wrap(new ItemStack(Material.BUCKET)); - private final ItemStack emptyBottle = ItemStackWrapper.wrap(new ItemStack(Material.GLASS_BOTTLE)); + private final ItemStack emptyBucket = ItemStackWrapper.wrap(StackResolver.of(Material.BUCKET)); + private final ItemStack emptyBottle = ItemStackWrapper.wrap(StackResolver.of(Material.GLASS_BOTTLE)); @ParametersAreNonnullByDefault public FluidPump(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -202,7 +202,7 @@ private Block findNextFluid(@Nonnull Block fluid) { switch (fluid.getType()) { case WATER: case BUBBLE_COLUMN: - ItemStack waterBottle = new ItemStack(Material.POTION); + ItemStack waterBottle = StackResolver.of(Material.POTION); PotionMeta meta = (PotionMeta) waterBottle.getItemMeta(); if (Slimefun.getMinecraftVersion().isBefore(20, 2)) { meta.setBasePotionData(new PotionData(PotionType.WATER)); @@ -212,18 +212,18 @@ private Block findNextFluid(@Nonnull Block fluid) { waterBottle.setItemMeta(meta); return waterBottle; default: - return new ItemStack(Material.GLASS_BOTTLE); + return StackResolver.of(Material.GLASS_BOTTLE); } } private @Nonnull ItemStack getFilledBucket(@Nonnull Block fluid) { return switch (fluid.getType()) { - case LAVA -> new ItemStack(Material.LAVA_BUCKET); + case LAVA -> StackResolver.of(Material.LAVA_BUCKET); case WATER, - BUBBLE_COLUMN -> new ItemStack(Material.WATER_BUCKET); + BUBBLE_COLUMN -> StackResolver.of(Material.WATER_BUCKET); default -> // Fallback for any new liquids - new ItemStack(Material.BUCKET); + StackResolver.of(Material.BUCKET); }; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java index 04f70d5490..b6d4857889 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -40,7 +41,7 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_HOE); + return StackResolver.of(Material.GOLDEN_HOE); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java index a22efe9f1a..53dc1ded3a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -19,17 +20,17 @@ public FoodFabricator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType re @Override protected void registerDefaultRecipes() { - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.WHEAT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.WHEAT_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.CARROT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.CARROT_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.POTATO) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.POTATO_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.WHEAT_SEEDS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SEEDS_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.BEETROOT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.BEETROOT_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.MELON_SLICE) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.MELON_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.APPLE) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.APPLE_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.DRIED_KELP) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.KELP_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.COCOA_BEANS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.COCOA_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.SWEET_BERRIES) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SWEET_BERRIES_ORGANIC_FOOD, OrganicFood.OUTPUT) }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.SEAGRASS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SEAGRASS_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.WHEAT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.WHEAT_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.CARROT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.CARROT_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.POTATO) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.POTATO_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.WHEAT_SEEDS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SEEDS_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.BEETROOT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.BEETROOT_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.MELON_SLICE) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.MELON_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.APPLE) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.APPLE_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.DRIED_KELP) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.KELP_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.COCOA_BEANS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.COCOA_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.SWEET_BERRIES) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SWEET_BERRIES_ORGANIC_FOOD, OrganicFood.OUTPUT) }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(Material.SEAGRASS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SEAGRASS_ORGANIC_FOOD, OrganicFood.OUTPUT) }); } @Override @@ -39,7 +40,7 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_HOE); + return StackResolver.of(Material.GOLDEN_HOE); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Freezer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Freezer.java index c2ad401d80..d20e7c0253 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Freezer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Freezer.java @@ -5,6 +5,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -39,19 +40,19 @@ public Freezer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTyp protected void registerDefaultRecipes() { // This if statement makes the transformation follow Minecraft logic if (useVanillaRatios.getValue()) { - registerRecipe(4, new ItemStack[] { new ItemStack(Material.ICE, 9) }, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }); - registerRecipe(6, new ItemStack[] { new ItemStack(Material.PACKED_ICE, 9) }, new ItemStack[] { new ItemStack(Material.BLUE_ICE) }); + registerRecipe(4, new ItemStack[] { StackResolver.of(Material.ICE, 9) }, new ItemStack[] { StackResolver.of(Material.PACKED_ICE) }); + registerRecipe(6, new ItemStack[] { StackResolver.of(Material.PACKED_ICE, 9) }, new ItemStack[] { StackResolver.of(Material.BLUE_ICE) }); } else { - registerRecipe(4, new ItemStack[] { new ItemStack(Material.ICE) }, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }); - registerRecipe(6, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }, new ItemStack[] { new ItemStack(Material.BLUE_ICE) }); + registerRecipe(4, new ItemStack[] { StackResolver.of(Material.ICE) }, new ItemStack[] { StackResolver.of(Material.PACKED_ICE) }); + registerRecipe(6, new ItemStack[] { StackResolver.of(Material.PACKED_ICE) }, new ItemStack[] { StackResolver.of(Material.BLUE_ICE) }); } - registerRecipe(2, new ItemStack[] { new ItemStack(Material.WATER_BUCKET) }, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.ICE) }); - registerRecipe(8, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.OBSIDIAN) }); - registerRecipe(8, new ItemStack[] { new ItemStack(Material.BLUE_ICE) }, new ItemStack[] { SlimefunItems.REACTOR_COOLANT_CELL }); - registerRecipe(6, new ItemStack[] { new ItemStack(Material.SNOW_BLOCK, 2) }, new ItemStack[] { new ItemStack(Material.ICE) }); - registerRecipe(6, new ItemStack[] { new ItemStack(Material.MAGMA_CREAM) }, new ItemStack[] { new ItemStack(Material.SLIME_BALL) }); - registerRecipe(6, new ItemStack[] { new ItemStack(Material.MAGMA_BLOCK, 2) }, new ItemStack[] { new ItemStack(Material.SLIME_BLOCK) }); + registerRecipe(2, new ItemStack[] { StackResolver.of(Material.WATER_BUCKET) }, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.ICE) }); + registerRecipe(8, new ItemStack[] { StackResolver.of(Material.LAVA_BUCKET) }, new ItemStack[] { StackResolver.of(Material.BUCKET), StackResolver.of(Material.OBSIDIAN) }); + registerRecipe(8, new ItemStack[] { StackResolver.of(Material.BLUE_ICE) }, new ItemStack[] { SlimefunItems.REACTOR_COOLANT_CELL }); + registerRecipe(6, new ItemStack[] { StackResolver.of(Material.SNOW_BLOCK, 2) }, new ItemStack[] { StackResolver.of(Material.ICE) }); + registerRecipe(6, new ItemStack[] { StackResolver.of(Material.MAGMA_CREAM) }, new ItemStack[] { StackResolver.of(Material.SLIME_BALL) }); + registerRecipe(6, new ItemStack[] { StackResolver.of(Material.MAGMA_BLOCK, 2) }, new ItemStack[] { StackResolver.of(Material.SLIME_BLOCK) }); } @Override @@ -68,7 +69,7 @@ public List getDisplayRecipes() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_PICKAXE); + return StackResolver.of(Material.GOLDEN_PICKAXE); } @Override 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..770658e46f 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 @@ -7,6 +7,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -88,7 +89,7 @@ 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(60, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_2, StackResolver.of(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) }); @@ -97,7 +98,7 @@ protected void registerDefaultRecipes() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Refinery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Refinery.java index 98cc035072..e16e1a02f6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Refinery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Refinery.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -24,7 +25,7 @@ protected void registerDefaultRecipes() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.FLINT_AND_STEEL); + return StackResolver.of(Material.FLINT_AND_STEEL); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java index 61f38c5b75..81d02fbdc1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java @@ -7,6 +7,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -53,7 +54,7 @@ public AutoDisenchanter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType @Override public ItemStack getProgressBar() { - return new ItemStack(Material.DIAMOND_CHESTPLATE); + return StackResolver.of(Material.DIAMOND_CHESTPLATE); } @Override @@ -106,7 +107,7 @@ protected MachineRecipe findNextRecipe(BlockMenu menu) { ItemStack disenchantedItem = item.clone(); disenchantedItem.setAmount(1); - ItemStack enchantedBook = new ItemStack(Material.ENCHANTED_BOOK); + ItemStack enchantedBook = StackResolver.of(Material.ENCHANTED_BOOK); transferEnchantments(disenchantedItem, enchantedBook, enchantments); MachineRecipe recipe = new MachineRecipe(90 * enchantments.size() / this.getSpeed(), new ItemStack[] { book, item }, new ItemStack[] { disenchantedItem, enchantedBook }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoEnchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoEnchanter.java index db11586454..24e33258ce 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoEnchanter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoEnchanter.java @@ -6,6 +6,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -51,7 +52,7 @@ public AutoEnchanter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_CHESTPLATE); + return StackResolver.of(Material.GOLDEN_CHESTPLATE); } @Override @@ -138,7 +139,7 @@ protected MachineRecipe enchant(BlockMenu menu, ItemStack target, ItemStack ench enchantedItem.setAmount(1); enchantedItem.addUnsafeEnchantments(enchantments); - MachineRecipe recipe = new MachineRecipe(75 * enchantments.size() / getSpeed(), new ItemStack[] { target, enchantedBook }, new ItemStack[] { enchantedItem, new ItemStack(Material.BOOK) }); + MachineRecipe recipe = new MachineRecipe(75 * enchantments.size() / getSpeed(), new ItemStack[] { target, enchantedBook }, new ItemStack[] { enchantedItem, StackResolver.of(Material.BOOK) }); if (!InvUtils.fitAll(menu.toInventory(), recipe.getOutput(), getOutputSlots())) { return null; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/BookBinder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/BookBinder.java index 4ac521faa2..3d70bdc746 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/BookBinder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/BookBinder.java @@ -7,6 +7,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; @@ -61,7 +62,7 @@ protected MachineRecipe findNextRecipe(BlockMenu menu) { return null; } - ItemStack book = new ItemStack(Material.ENCHANTED_BOOK); + ItemStack book = StackResolver.of(Material.ENCHANTED_BOOK); EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) book.getItemMeta(); @@ -121,7 +122,7 @@ private boolean hasIllegalEnchants(@Nullable Map enchantme @Override public ItemStack getProgressBar() { - return new ItemStack(Material.IRON_CHESTPLATE); + return StackResolver.of(Material.IRON_CHESTPLATE); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java index e62fd7951d..eb143ad28f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java @@ -3,6 +3,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.block.Block; @@ -65,7 +66,7 @@ public void onBlockBreak(Block b) { protected void constructMenu(BlockMenuPreset preset) { for (int i : border) { - preset.addItem(i, new CustomItemStack(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false); + preset.addItem(i, new CustomItemStack(StackResolver.of(Material.CYAN_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java index c38602e441..8a23ae0a62 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.SoundCategory; @@ -45,7 +46,7 @@ public int getEnergyConsumption() { @Override public ItemStack getHead() { - return new ItemStack(Material.CARVED_PUMPKIN); + return StackResolver.of(Material.CARVED_PUMPKIN); } @Override @@ -55,7 +56,7 @@ public Material getHeadBorder() { @Override public ItemStack getBody() { - return new ItemStack(Material.IRON_BLOCK, 4); + return StackResolver.of(Material.IRON_BLOCK, 4); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java index 24ecf5d86d..59ff1a2409 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java @@ -10,6 +10,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.block.Block; @@ -63,7 +64,7 @@ public ProduceCollector(ItemGroup itemGroup, SlimefunItemStack item, RecipeType @Override protected void registerDefaultRecipes() { // Milk from adult cows and goats - addProduce(new AnimalProduce(new ItemStack(Material.BUCKET), new ItemStack(Material.MILK_BUCKET), n -> { + addProduce(new AnimalProduce(StackResolver.of(Material.BUCKET), StackResolver.of(Material.MILK_BUCKET), n -> { MinecraftVersion version = Slimefun.getMinecraftVersion(); if (n instanceof Cow || (version.isAtLeast(MinecraftVersion.MINECRAFT_1_17) && n instanceof Goat)) { @@ -74,7 +75,7 @@ protected void registerDefaultRecipes() { })); // Mushroom Stew from Mooshrooms - addProduce(new AnimalProduce(new ItemStack(Material.BOWL), new ItemStack(Material.MUSHROOM_STEW), n -> { + addProduce(new AnimalProduce(StackResolver.of(Material.BOWL), StackResolver.of(Material.MUSHROOM_STEW), n -> { if (n instanceof MushroomCow mushroomCow) { return mushroomCow.isAdult(); } else { @@ -117,15 +118,15 @@ public boolean isSynchronized() { List displayRecipes = new ArrayList<>(); displayRecipes.add(new CustomItemStack(Material.BUCKET, null, "&fRequires &bCow &fnearby")); - displayRecipes.add(new ItemStack(Material.MILK_BUCKET)); + displayRecipes.add(StackResolver.of(Material.MILK_BUCKET)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { displayRecipes.add(new CustomItemStack(Material.BUCKET, null, "&fRequires &bGoat &fnearby")); - displayRecipes.add(new ItemStack(Material.MILK_BUCKET)); + displayRecipes.add(StackResolver.of(Material.MILK_BUCKET)); } displayRecipes.add(new CustomItemStack(Material.BOWL, null, "&fRequires &bMooshroom &fnearby")); - displayRecipes.add(new ItemStack(Material.MUSHROOM_STEW)); + displayRecipes.add(StackResolver.of(Material.MUSHROOM_STEW)); return displayRecipes; } @@ -172,7 +173,7 @@ private boolean isValidAnimal(Entity n, Predicate predicate) { @Override public @Nonnull ItemStack getProgressBar() { - return new ItemStack(Material.SHEARS); + return StackResolver.of(Material.SHEARS); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java index cc2c336672..a0b85d9f0d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Wither; @@ -43,7 +44,7 @@ public int getEnergyConsumption() { @Override public ItemStack getHead() { - return new ItemStack(Material.WITHER_SKELETON_SKULL, 3); + return StackResolver.of(Material.WITHER_SKELETON_SKULL, 3); } @Override @@ -53,7 +54,7 @@ public Material getHeadBorder() { @Override public ItemStack getBody() { - return new ItemStack(Material.SOUL_SAND, 4); + return StackResolver.of(Material.SOUL_SAND, 4); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java index 47f671ac83..d9f3c8d227 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java @@ -3,6 +3,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; @@ -37,7 +38,7 @@ protected NetherStarReactor(ItemGroup itemGroup, SlimefunItemStack item, RecipeT @Override protected void registerDefaultFuelTypes() { - registerFuel(new MachineFuel(1800, new ItemStack(Material.NETHER_STAR))); + registerFuel(new MachineFuel(1800, StackResolver.of(Material.NETHER_STAR))); } @Override @@ -58,12 +59,12 @@ public ItemStack getCoolant() { @Override public ItemStack getFuelIcon() { - return new ItemStack(Material.NETHER_STAR); + return StackResolver.of(Material.NETHER_STAR); } @Override public ItemStack getProgressBar() { - return new ItemStack(Material.NETHER_STAR); + return StackResolver.of(Material.NETHER_STAR); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java index f8b61543e1..bc09732b97 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java @@ -6,6 +6,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -88,13 +89,13 @@ private void removeGlassBottle(Player p, ItemStack item) { if (p.getInventory().getItemInMainHand().getAmount() == 1) { p.getEquipment().getItemInMainHand().setAmount(0); } else { - p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1)); + p.getInventory().removeItem(StackResolver.of(Material.GLASS_BOTTLE, 1)); } } else if (SlimefunUtils.isItemSimilar(item, p.getInventory().getItemInOffHand(), true)) { if (p.getInventory().getItemInOffHand().getAmount() == 1) { p.getEquipment().getItemInOffHand().setAmount(0); } else { - p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1)); + p.getInventory().removeItem(StackResolver.of(Material.GLASS_BOTTLE, 1)); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java index d21815533b..5b275170cc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java @@ -7,6 +7,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -67,7 +68,7 @@ public class GEOMiner extends SlimefunItem implements RecipeDisplayItem, EnergyN public GEOMiner(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, item, recipeType, recipe); - processor.setProgressBar(new ItemStack(Material.DIAMOND_PICKAXE)); + processor.setProgressBar(StackResolver.of(Material.DIAMOND_PICKAXE)); createPreset(this, getItemName(), this::constructMenu); addItemHandler(onBlockPlace(), onBlockBreak()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java index 4422117526..32b578abe0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java @@ -6,6 +6,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.block.Block; @@ -32,7 +33,7 @@ public class OilPump extends AContainer implements RecipeDisplayItem { private final GEOResource oil; - private final ItemStack emptyBucket = new ItemStack(Material.BUCKET); + private final ItemStack emptyBucket = StackResolver.of(Material.BUCKET); @ParametersAreNonnullByDefault public OilPump(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -84,7 +85,7 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.DIAMOND_SHOVEL); + return StackResolver.of(Material.DIAMOND_SHOVEL); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java index 33e54e7544..4cb7f8cb3c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java @@ -12,6 +12,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.SoundCategory; @@ -59,7 +60,7 @@ public EnchantmentRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r continue; } - if (enchantment.canEnchantItem(new ItemStack(mat))) { + if (enchantment.canEnchantItem(StackResolver.of(mat))) { enchantments.add(enchantment); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFood.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFood.java index ac46b6e356..af4adbe9b3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFood.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFood.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -28,6 +29,6 @@ public class OrganicFood extends SlimefunItem { @ParametersAreNonnullByDefault public OrganicFood(ItemGroup itemGroup, SlimefunItemStack item, Material ingredient) { - super(itemGroup, item, RecipeType.FOOD_FABRICATOR, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(ingredient), null, null, null, null, null, null, null }, new SlimefunItemStack(item, OUTPUT)); + super(itemGroup, item, RecipeType.FOOD_FABRICATOR, new ItemStack[] { SlimefunItems.TIN_CAN, StackResolver.of(ingredient), null, null, null, null, null, null, null }, new SlimefunItemStack(item, OUTPUT)); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java index 4ee70ac722..25bf79bc41 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java @@ -4,6 +4,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -29,7 +30,7 @@ public class ArmorForge extends AbstractCraftingTable { @ParametersAreNonnullByDefault public ArmorForge(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.ANVIL), null, null, new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, StackResolver.of(Material.ANVIL), null, null, new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java index ca2d0c7124..b6fb3de321 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java @@ -7,6 +7,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.GameMode; @@ -48,7 +49,7 @@ public class AutomatedPanningMachine extends MultiBlockMachine { @ParametersAreNonnullByDefault public AutomatedPanningMachine(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_TRAPDOOR), null, null, new ItemStack(Material.CAULDRON), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, StackResolver.of(Material.OAK_TRAPDOOR), null, null, StackResolver.of(Material.CAULDRON), null }, BlockFace.SELF); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java index f0b48882e6..49eb6581f3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -32,22 +33,22 @@ public class Compressor extends MultiBlockMachine { @ParametersAreNonnullByDefault public Compressor(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON) }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, StackResolver.of(Material.NETHER_BRICK_FENCE), null, StackResolver.of(Material.PISTON), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), StackResolver.of(Material.PISTON) }, BlockFace.SELF); } @Override protected void registerDefaultRecipes(List recipes) { recipes.add(new SlimefunItemStack(SlimefunItems.STONE_CHUNK, 4)); - recipes.add(new ItemStack(Material.COBBLESTONE)); + recipes.add(StackResolver.of(Material.COBBLESTONE)); - recipes.add(new ItemStack(Material.FLINT, 8)); - recipes.add(new ItemStack(Material.COBBLESTONE)); + recipes.add(StackResolver.of(Material.FLINT, 8)); + recipes.add(StackResolver.of(Material.COBBLESTONE)); - recipes.add(new ItemStack(Material.COAL_BLOCK, 8)); + recipes.add(StackResolver.of(Material.COAL_BLOCK, 8)); recipes.add(new SlimefunItemStack(SlimefunItems.CARBON, 9)); - recipes.add(new ItemStack(Material.CHARCOAL, 4)); - recipes.add(new ItemStack(Material.COAL)); + recipes.add(StackResolver.of(Material.CHARCOAL, 4)); + recipes.add(StackResolver.of(Material.COAL)); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java index 4486197b62..79de4ad694 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java @@ -4,6 +4,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -30,7 +31,7 @@ public class EnhancedCraftingTable extends AbstractCraftingTable { @ParametersAreNonnullByDefault public EnhancedCraftingTable(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.CRAFTING_TABLE), null, null, new ItemStack(Material.DISPENSER), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, StackResolver.of(Material.CRAFTING_TABLE), null, null, StackResolver.of(Material.DISPENSER), null }, BlockFace.SELF); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java index f149093042..8be237b89a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -33,65 +34,65 @@ public class GrindStone extends MultiBlockMachine { @ParametersAreNonnullByDefault public GrindStone(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, StackResolver.of(Material.OAK_FENCE), null, null, new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); } @Override protected void registerDefaultRecipes(@Nonnull List recipes) { - recipes.add(new ItemStack(Material.BLAZE_ROD)); - recipes.add(new ItemStack(Material.BLAZE_POWDER, 4)); + recipes.add(StackResolver.of(Material.BLAZE_ROD)); + recipes.add(StackResolver.of(Material.BLAZE_POWDER, 4)); - recipes.add(new ItemStack(Material.BONE)); - recipes.add(new ItemStack(Material.BONE_MEAL, 4)); + recipes.add(StackResolver.of(Material.BONE)); + recipes.add(StackResolver.of(Material.BONE_MEAL, 4)); - recipes.add(new ItemStack(Material.BONE_BLOCK)); - recipes.add(new ItemStack(Material.BONE_MEAL, 9)); + recipes.add(StackResolver.of(Material.BONE_BLOCK)); + recipes.add(StackResolver.of(Material.BONE_MEAL, 9)); - recipes.add(new ItemStack(Material.COBBLESTONE)); - recipes.add(new ItemStack(Material.GRAVEL)); + recipes.add(StackResolver.of(Material.COBBLESTONE)); + recipes.add(StackResolver.of(Material.GRAVEL)); - recipes.add(new ItemStack(Material.ANDESITE)); - recipes.add(new ItemStack(Material.GRAVEL)); + recipes.add(StackResolver.of(Material.ANDESITE)); + recipes.add(StackResolver.of(Material.GRAVEL)); - recipes.add(new ItemStack(Material.BLACKSTONE)); - recipes.add(new ItemStack(Material.GRAVEL)); + recipes.add(StackResolver.of(Material.BLACKSTONE)); + recipes.add(StackResolver.of(Material.GRAVEL)); - recipes.add(new ItemStack(Material.DIORITE)); - recipes.add(new ItemStack(Material.GRAVEL)); + recipes.add(StackResolver.of(Material.DIORITE)); + recipes.add(StackResolver.of(Material.GRAVEL)); - recipes.add(new ItemStack(Material.GRANITE)); - recipes.add(new ItemStack(Material.GRAVEL)); + recipes.add(StackResolver.of(Material.GRANITE)); + recipes.add(StackResolver.of(Material.GRAVEL)); - recipes.add(new ItemStack(Material.DIRT)); + recipes.add(StackResolver.of(Material.DIRT)); recipes.add(SlimefunItems.STONE_CHUNK); - recipes.add(new ItemStack(Material.SANDSTONE)); - recipes.add(new ItemStack(Material.SAND, 4)); + recipes.add(StackResolver.of(Material.SANDSTONE)); + recipes.add(StackResolver.of(Material.SAND, 4)); - recipes.add(new ItemStack(Material.RED_SANDSTONE)); - recipes.add(new ItemStack(Material.RED_SAND, 4)); + recipes.add(StackResolver.of(Material.RED_SANDSTONE)); + recipes.add(StackResolver.of(Material.RED_SAND, 4)); - recipes.add(new ItemStack(Material.PRISMARINE_BRICKS)); - recipes.add(new ItemStack(Material.PRISMARINE, 2)); + recipes.add(StackResolver.of(Material.PRISMARINE_BRICKS)); + recipes.add(StackResolver.of(Material.PRISMARINE, 2)); - recipes.add(new ItemStack(Material.PRISMARINE)); - recipes.add(new ItemStack(Material.PRISMARINE_SHARD, 4)); + recipes.add(StackResolver.of(Material.PRISMARINE)); + recipes.add(StackResolver.of(Material.PRISMARINE_SHARD, 4)); - recipes.add(new ItemStack(Material.NETHER_WART_BLOCK)); - recipes.add(new ItemStack(Material.NETHER_WART, 9)); + recipes.add(StackResolver.of(Material.NETHER_WART_BLOCK)); + recipes.add(StackResolver.of(Material.NETHER_WART, 9)); - recipes.add(new ItemStack(Material.QUARTZ_BLOCK)); - recipes.add(new ItemStack(Material.QUARTZ, 4)); + recipes.add(StackResolver.of(Material.QUARTZ_BLOCK)); + recipes.add(StackResolver.of(Material.QUARTZ, 4)); - recipes.add(new ItemStack(Material.BASALT, 2)); - recipes.add(new ItemStack(Material.BLACKSTONE)); + recipes.add(StackResolver.of(Material.BASALT, 2)); + recipes.add(StackResolver.of(Material.BLACKSTONE)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - recipes.add(new ItemStack(Material.AMETHYST_BLOCK)); - recipes.add(new ItemStack(Material.AMETHYST_SHARD, 4)); + recipes.add(StackResolver.of(Material.AMETHYST_BLOCK)); + recipes.add(StackResolver.of(Material.AMETHYST_SHARD, 4)); - recipes.add(new ItemStack(Material.COBBLED_DEEPSLATE)); - recipes.add(new ItemStack(Material.GRAVEL)); + recipes.add(StackResolver.of(Material.COBBLED_DEEPSLATE)); + recipes.add(StackResolver.of(Material.GRAVEL)); } recipes.add(SlimefunItems.MAGIC_LUMP_2); @@ -106,7 +107,7 @@ protected void registerDefaultRecipes(@Nonnull List recipes) { recipes.add(SlimefunItems.ENDER_LUMP_3); recipes.add(new SlimefunItemStack(SlimefunItems.ENDER_LUMP_2, 4)); - recipes.add(new ItemStack(Material.DIAMOND)); + recipes.add(StackResolver.of(Material.DIAMOND)); recipes.add(new SlimefunItemStack(SlimefunItems.CARBON, 4)); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java index a81c731434..3c54d85bba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -43,7 +44,7 @@ public class Juicer extends MultiBlockMachine { @ParametersAreNonnullByDefault public Juicer(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, StackResolver.of(Material.GLASS), null, null, StackResolver.of(Material.NETHER_BRICK_FENCE), null, null, new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java index 25ce8cdcc8..185e0c1e14 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java @@ -4,6 +4,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -31,7 +32,7 @@ public class MagicWorkbench extends AbstractCraftingTable { @ParametersAreNonnullByDefault public MagicWorkbench(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, null, null, new ItemStack(Material.BOOKSHELF), new ItemStack(Material.CRAFTING_TABLE), new ItemStack(Material.DISPENSER) }, BlockFace.UP); + super(itemGroup, item, new ItemStack[] { null, null, null, null, null, null, StackResolver.of(Material.BOOKSHELF), StackResolver.of(Material.CRAFTING_TABLE), StackResolver.of(Material.DISPENSER) }, BlockFace.UP); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java index a46b27f2d8..12a64dde42 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java @@ -5,6 +5,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -30,7 +31,7 @@ public class MakeshiftSmeltery extends AbstractSmeltery { @ParametersAreNonnullByDefault public MakeshiftSmeltery(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); + super(itemGroup, item, new ItemStack[] { null, StackResolver.of(Material.OAK_FENCE), null, StackResolver.of(Material.BRICKS), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), StackResolver.of(Material.BRICKS), null, StackResolver.of(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java index ea5141f099..6d304e6c9b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java @@ -7,6 +7,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -45,18 +46,18 @@ public class OreCrusher extends MultiBlockMachine { @ParametersAreNonnullByDefault public OreCrusher(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, StackResolver.of(Material.NETHER_BRICK_FENCE), null, StackResolver.of(Material.IRON_BARS), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), StackResolver.of(Material.IRON_BARS) }, BlockFace.SELF); addItemSetting(doubleOres); } @Override protected void registerDefaultRecipes(List recipes) { - recipes.add(new ItemStack(Material.BLACKSTONE, 8)); - recipes.add(new ItemStack(Material.RED_SAND, 1)); + recipes.add(StackResolver.of(Material.BLACKSTONE, 8)); + recipes.add(StackResolver.of(Material.RED_SAND, 1)); - recipes.add(new ItemStack(Material.COBBLESTONE, 8)); - recipes.add(new ItemStack(Material.SAND, 1)); + recipes.add(StackResolver.of(Material.COBBLESTONE, 8)); + recipes.add(StackResolver.of(Material.SAND, 1)); recipes.add(SlimefunItems.GOLD_4K); recipes.add(SlimefunItems.GOLD_DUST); @@ -91,21 +92,21 @@ protected void registerDefaultRecipes(List recipes) { recipes.add(SlimefunItems.GOLD_24K); recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 6)); - recipes.add(new ItemStack(Material.GRAVEL)); - recipes.add(new ItemStack(Material.SAND)); + recipes.add(StackResolver.of(Material.GRAVEL)); + recipes.add(StackResolver.of(Material.SAND)); - recipes.add(new ItemStack(Material.MAGMA_BLOCK)); + recipes.add(StackResolver.of(Material.MAGMA_BLOCK)); recipes.add(SlimefunItems.SULFATE); recipes.add(SlimefunItems.CARBON); - recipes.add(new ItemStack(Material.COAL, 8)); + recipes.add(StackResolver.of(Material.COAL, 8)); recipes.add(SlimefunItems.COMPRESSED_CARBON); recipes.add(new SlimefunItemStack(SlimefunItems.CARBON, 4)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - recipes.add(new ItemStack(Material.COBBLED_DEEPSLATE, 8)); - recipes.add(new ItemStack(Material.SAND, 1)); + recipes.add(StackResolver.of(Material.COBBLED_DEEPSLATE, 8)); + recipes.add(StackResolver.of(Material.SAND, 1)); } } @@ -119,31 +120,31 @@ public void postRegister() { // @formatter:off displayRecipes.addAll(Arrays.asList( - new ItemStack(Material.COAL_ORE), doubleOres.getCoal(), - new ItemStack(Material.LAPIS_ORE), doubleOres.getLapisLazuli(), - new ItemStack(Material.REDSTONE_ORE), doubleOres.getRedstone(), - new ItemStack(Material.DIAMOND_ORE), doubleOres.getDiamond(), - new ItemStack(Material.EMERALD_ORE), doubleOres.getEmerald(), - new ItemStack(Material.NETHER_QUARTZ_ORE), doubleOres.getNetherQuartz() + StackResolver.of(Material.COAL_ORE), doubleOres.getCoal(), + StackResolver.of(Material.LAPIS_ORE), doubleOres.getLapisLazuli(), + StackResolver.of(Material.REDSTONE_ORE), doubleOres.getRedstone(), + StackResolver.of(Material.DIAMOND_ORE), doubleOres.getDiamond(), + StackResolver.of(Material.EMERALD_ORE), doubleOres.getEmerald(), + StackResolver.of(Material.NETHER_QUARTZ_ORE), doubleOres.getNetherQuartz() )); // @formatter:on // Gold ore variants (1.16+) - displayRecipes.add(new ItemStack(Material.NETHER_GOLD_ORE)); + displayRecipes.add(StackResolver.of(Material.NETHER_GOLD_ORE)); displayRecipes.add(doubleOres.getGoldNuggets()); - displayRecipes.add(new ItemStack(Material.GILDED_BLACKSTONE)); + displayRecipes.add(StackResolver.of(Material.GILDED_BLACKSTONE)); displayRecipes.add(doubleOres.getGoldNuggets()); // Raw metal ores (1.17+) if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - displayRecipes.add(new ItemStack(Material.RAW_IRON)); + displayRecipes.add(StackResolver.of(Material.RAW_IRON)); displayRecipes.add(SlimefunItems.IRON_DUST); - displayRecipes.add(new ItemStack(Material.RAW_COPPER)); + displayRecipes.add(StackResolver.of(Material.RAW_COPPER)); displayRecipes.add(SlimefunItems.COPPER_DUST); - displayRecipes.add(new ItemStack(Material.RAW_GOLD)); + displayRecipes.add(StackResolver.of(Material.RAW_GOLD)); displayRecipes.add(SlimefunItems.GOLD_DUST); } @@ -151,25 +152,25 @@ public void postRegister() { if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { // @formatter:off displayRecipes.addAll(Arrays.asList( - new ItemStack(Material.DEEPSLATE_COAL_ORE), doubleOres.getCoal(), - new ItemStack(Material.DEEPSLATE_LAPIS_ORE), doubleOres.getLapisLazuli(), - new ItemStack(Material.DEEPSLATE_REDSTONE_ORE), doubleOres.getRedstone(), - new ItemStack(Material.DEEPSLATE_DIAMOND_ORE), doubleOres.getDiamond(), - new ItemStack(Material.DEEPSLATE_EMERALD_ORE), doubleOres.getEmerald() + StackResolver.of(Material.DEEPSLATE_COAL_ORE), doubleOres.getCoal(), + StackResolver.of(Material.DEEPSLATE_LAPIS_ORE), doubleOres.getLapisLazuli(), + StackResolver.of(Material.DEEPSLATE_REDSTONE_ORE), doubleOres.getRedstone(), + StackResolver.of(Material.DEEPSLATE_DIAMOND_ORE), doubleOres.getDiamond(), + StackResolver.of(Material.DEEPSLATE_EMERALD_ORE), doubleOres.getEmerald() )); // @formatter:on // More deepslate ores and copper ore - displayRecipes.add(new ItemStack(Material.DEEPSLATE_IRON_ORE)); + displayRecipes.add(StackResolver.of(Material.DEEPSLATE_IRON_ORE)); displayRecipes.add(new SlimefunItemStack(SlimefunItems.IRON_DUST, isOreDoublingEnabled() ? 2 : 1)); - displayRecipes.add(new ItemStack(Material.DEEPSLATE_GOLD_ORE)); + displayRecipes.add(StackResolver.of(Material.DEEPSLATE_GOLD_ORE)); displayRecipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, isOreDoublingEnabled() ? 2 : 1)); - displayRecipes.add(new ItemStack(Material.DEEPSLATE_COPPER_ORE)); + displayRecipes.add(StackResolver.of(Material.DEEPSLATE_COPPER_ORE)); displayRecipes.add(new SlimefunItemStack(SlimefunItems.COPPER_DUST, isOreDoublingEnabled() ? 2 : 1)); - displayRecipes.add(new ItemStack(Material.COPPER_ORE)); + displayRecipes.add(StackResolver.of(Material.COPPER_ORE)); displayRecipes.add(new SlimefunItemStack(SlimefunItems.COPPER_DUST, isOreDoublingEnabled() ? 2 : 1)); } } @@ -218,13 +219,13 @@ public void onInteract(Player p, Block b) { private class DoubleOreSetting extends ItemSetting { - private final ItemStack coal = new ItemStack(Material.COAL, 1); - private final ItemStack lapis = new ItemStack(Material.LAPIS_LAZULI, 7); - private final ItemStack redstone = new ItemStack(Material.REDSTONE, 4); - private final ItemStack diamond = new ItemStack(Material.DIAMOND, 1); - private final ItemStack emerald = new ItemStack(Material.EMERALD, 1); - private final ItemStack quartz = new ItemStack(Material.QUARTZ, 1); - private final ItemStack goldNuggets = new ItemStack(Material.GOLD_NUGGET, 4); + private final ItemStack coal = StackResolver.of(Material.COAL, 1); + private final ItemStack lapis = StackResolver.of(Material.LAPIS_LAZULI, 7); + private final ItemStack redstone = StackResolver.of(Material.REDSTONE, 4); + private final ItemStack diamond = StackResolver.of(Material.DIAMOND, 1); + private final ItemStack emerald = StackResolver.of(Material.EMERALD, 1); + private final ItemStack quartz = StackResolver.of(Material.QUARTZ, 1); + private final ItemStack goldNuggets = StackResolver.of(Material.GOLD_NUGGET, 4); DoubleOreSetting(@Nonnull OreCrusher oreCrusher) { super(oreCrusher, "double-ores", true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java index 25a3282369..67490d9dd1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java @@ -7,6 +7,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -58,9 +59,9 @@ public class OreWasher extends MultiBlockMachine { public OreWasher(ItemGroup itemGroup, SlimefunItemStack item) { // @formatter:off super(itemGroup, item, new ItemStack[] { - null, new ItemStack(Material.DISPENSER), null, - null, new ItemStack(Material.OAK_FENCE), null, - null, new ItemStack(Material.CAULDRON), null + null, StackResolver.of(Material.DISPENSER), null, + null, StackResolver.of(Material.OAK_FENCE), null, + null, StackResolver.of(Material.CAULDRON), null }, BlockFace.SELF); // @formatter:on @@ -80,7 +81,7 @@ protected void registerDefaultRecipes(List recipes) { recipes.add(SlimefunItems.SIFTED_ORE); recipes.add(SlimefunItems.GOLD_DUST); - recipes.add(new ItemStack(Material.SAND)); + recipes.add(StackResolver.of(Material.SAND)); recipes.add(SlimefunItems.SALT); } @@ -131,7 +132,7 @@ public void onInteract(Player p, Block b) { } return; - } else if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SAND, 2), false)) { + } else if (SlimefunUtils.isItemSimilar(input, StackResolver.of(Material.SAND, 2), false)) { ItemStack output = SlimefunItems.SALT; Inventory outputInv = findOutputInventory(output, dispBlock, inv); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java index c8b75de5a3..eed31d82e8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -32,7 +33,7 @@ public class PressureChamber extends MultiBlockMachine { @ParametersAreNonnullByDefault public PressureChamber(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { new ItemStack(Material.SMOOTH_STONE_SLAB), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing down)"), new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) }, BlockFace.UP); + super(itemGroup, item, new ItemStack[] { StackResolver.of(Material.SMOOTH_STONE_SLAB), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing down)"), StackResolver.of(Material.SMOOTH_STONE_SLAB), StackResolver.of(Material.PISTON), StackResolver.of(Material.GLASS), StackResolver.of(Material.PISTON), StackResolver.of(Material.PISTON), StackResolver.of(Material.CAULDRON), StackResolver.of(Material.PISTON) }, BlockFace.UP); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java index a55abe12ff..fd86ca2067 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java @@ -9,6 +9,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -50,7 +51,7 @@ public class Smeltery extends AbstractSmeltery { @ParametersAreNonnullByDefault public Smeltery(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); + super(itemGroup, item, new ItemStack[] { null, StackResolver.of(Material.NETHER_BRICK_FENCE), null, StackResolver.of(Material.NETHER_BRICKS), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), StackResolver.of(Material.NETHER_BRICKS), null, StackResolver.of(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); addItemSetting(fireBreakingChance); } @@ -58,7 +59,7 @@ public Smeltery(ItemGroup itemGroup, SlimefunItemStack item) { @Override protected void registerDefaultRecipes(@Nonnull List recipes) { recipes.add(SlimefunItems.IRON_DUST); - recipes.add(new ItemStack(Material.IRON_INGOT)); + recipes.add(StackResolver.of(Material.IRON_INGOT)); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 40bb1b2fdd..2f0a9f6a70 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -8,6 +8,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.GameMode; @@ -49,8 +50,8 @@ public TableSaw(ItemGroup group, SlimefunItemStack item) { // @formatter:off super(group, item, new ItemStack[] { null, null, null, - new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.SMOOTH_STONE_SLAB), - null, new ItemStack(Material.IRON_BLOCK), null + StackResolver.of(Material.SMOOTH_STONE_SLAB), StackResolver.of(Material.STONECUTTER), StackResolver.of(Material.SMOOTH_STONE_SLAB), + null, StackResolver.of(Material.IRON_BLOCK), null }, BlockFace.SELF); // @formatter:on @@ -58,14 +59,14 @@ null, new ItemStack(Material.IRON_BLOCK), null Optional planks = getPlanks(log); if (planks.isPresent()) { - displayedRecipes.add(new ItemStack(log)); - displayedRecipes.add(new ItemStack(planks.get(), 8)); + displayedRecipes.add(StackResolver.of(log)); + displayedRecipes.add(StackResolver.of(planks.get(), 8)); } } for (Material plank : Tag.PLANKS.getValues()) { - displayedRecipes.add(new ItemStack(plank)); - displayedRecipes.add(new ItemStack(Material.STICK, 4)); + displayedRecipes.add(StackResolver.of(plank)); + displayedRecipes.add(StackResolver.of(Material.STICK, 4)); } } @@ -129,12 +130,12 @@ public void onInteract(@Nonnull Player p, @Nonnull Block b) { Optional planks = getPlanks(item); if (planks.isPresent()) { - return new ItemStack(planks.get(), 8); + return StackResolver.of(planks.get(), 8); } else { return null; } } else if (Tag.PLANKS.isTagged(item)) { - return new ItemStack(Material.STICK, 4); + return StackResolver.of(Material.STICK, 4); } else { return null; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java index 5cec6e1b1e..6025df3f3c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java @@ -2,6 +2,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -30,7 +31,7 @@ public AdvancedIndustrialMiner(ItemGroup itemGroup, SlimefunItemStack item) { @Override protected void registerDefaultFuelTypes() { - fuelTypes.add(new MachineFuel(48, new ItemStack(Material.LAVA_BUCKET))); + fuelTypes.add(new MachineFuel(48, StackResolver.of(Material.LAVA_BUCKET))); fuelTypes.add(new MachineFuel(64, SlimefunItems.OIL_BUCKET)); fuelTypes.add(new MachineFuel(128, SlimefunItems.FUEL_BUCKET)); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java index 3ad9381c6c..e2bcd9823f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java @@ -10,6 +10,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.Material; @@ -63,8 +64,8 @@ public IndustrialMiner(ItemGroup itemGroup, SlimefunItemStack item, Material bas // @formatter:off super(itemGroup, item, new ItemStack[] { null, null, null, - new CustomItemStack(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItemStack(Material.PISTON, "Piston (facing up)"), - new ItemStack(baseMaterial), new ItemStack(Material.BLAST_FURNACE), new ItemStack(baseMaterial) + new CustomItemStack(Material.PISTON, "Piston (facing up)"), StackResolver.of(Material.CHEST), new CustomItemStack(Material.PISTON, "Piston (facing up)"), + StackResolver.of(baseMaterial), StackResolver.of(Material.BLAST_FURNACE), StackResolver.of(baseMaterial) }, BlockFace.UP); // @formatter:on @@ -107,16 +108,16 @@ public int getRange() { */ protected void registerDefaultFuelTypes() { // Coal & Charcoal - fuelTypes.add(new MachineFuel(4, new ItemStack(Material.COAL))); - fuelTypes.add(new MachineFuel(4, new ItemStack(Material.CHARCOAL))); + fuelTypes.add(new MachineFuel(4, StackResolver.of(Material.COAL))); + fuelTypes.add(new MachineFuel(4, StackResolver.of(Material.CHARCOAL))); - fuelTypes.add(new MachineFuel(40, new ItemStack(Material.COAL_BLOCK))); - fuelTypes.add(new MachineFuel(10, new ItemStack(Material.DRIED_KELP_BLOCK))); - fuelTypes.add(new MachineFuel(4, new ItemStack(Material.BLAZE_ROD))); + fuelTypes.add(new MachineFuel(40, StackResolver.of(Material.COAL_BLOCK))); + fuelTypes.add(new MachineFuel(10, StackResolver.of(Material.DRIED_KELP_BLOCK))); + fuelTypes.add(new MachineFuel(4, StackResolver.of(Material.BLAZE_ROD))); // Logs for (Material mat : Tag.LOGS.getValues()) { - fuelTypes.add(new MachineFuel(1, new ItemStack(mat))); + fuelTypes.add(new MachineFuel(1, StackResolver.of(mat))); } } @@ -130,7 +131,7 @@ protected void registerDefaultFuelTypes() { */ public @Nonnull ItemStack getOutcome(@Nonnull Material material) { if (hasSilkTouch()) { - return new ItemStack(material); + return StackResolver.of(material); } else { Random random = ThreadLocalRandom.current(); return oreDictionary.getDrops(material, random); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java index 0169f0f846..9acdbd6a50 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; @@ -322,7 +323,7 @@ private int grabFuelFrom(@Nonnull Inventory inv) { ItemUtils.consumeItem(item, false); if (miner instanceof AdvancedIndustrialMiner) { - inv.addItem(new ItemStack(Material.BUCKET)); + inv.addItem(StackResolver.of(Material.BUCKET)); } return fuelType.getTicks(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary16.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary16.java index f69ebc46d6..da684c7a18 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary16.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary16.java @@ -5,6 +5,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -20,17 +21,17 @@ class OreDictionary16 implements OreDictionary { @ParametersAreNonnullByDefault public @Nonnull ItemStack getDrops(Material material, Random random) { return switch (material) { - case COAL_ORE -> new ItemStack(Material.COAL); - case DIAMOND_ORE -> new ItemStack(Material.DIAMOND); - case EMERALD_ORE -> new ItemStack(Material.EMERALD); - case REDSTONE_ORE -> new ItemStack(Material.REDSTONE, 4 + random.nextInt(2)); - case LAPIS_ORE -> new ItemStack(Material.LAPIS_LAZULI, 4 + random.nextInt(4)); - case NETHER_QUARTZ_ORE -> new ItemStack(Material.QUARTZ); - case IRON_ORE -> new ItemStack(Material.IRON_ORE); - case GOLD_ORE -> new ItemStack(Material.GOLD_ORE); - case NETHER_GOLD_ORE -> new ItemStack(Material.GOLD_NUGGET, 2 + random.nextInt(4)); - case ANCIENT_DEBRIS -> new ItemStack(Material.ANCIENT_DEBRIS); - default -> new ItemStack(material); + case COAL_ORE -> StackResolver.of(Material.COAL); + case DIAMOND_ORE -> StackResolver.of(Material.DIAMOND); + case EMERALD_ORE -> StackResolver.of(Material.EMERALD); + case REDSTONE_ORE -> StackResolver.of(Material.REDSTONE, 4 + random.nextInt(2)); + case LAPIS_ORE -> StackResolver.of(Material.LAPIS_LAZULI, 4 + random.nextInt(4)); + case NETHER_QUARTZ_ORE -> StackResolver.of(Material.QUARTZ); + case IRON_ORE -> StackResolver.of(Material.IRON_ORE); + case GOLD_ORE -> StackResolver.of(Material.GOLD_ORE); + case NETHER_GOLD_ORE -> StackResolver.of(Material.GOLD_NUGGET, 2 + random.nextInt(4)); + case ANCIENT_DEBRIS -> StackResolver.of(Material.ANCIENT_DEBRIS); + default -> StackResolver.of(material); }; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary17.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary17.java index 7db6e3948e..84887728db 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary17.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary17.java @@ -4,6 +4,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -21,21 +22,21 @@ public ItemStack getDrops(Material material, Random random) { // In 1.17, breaking metal ores should get raw metals. Also support deepslate ores. return switch (material) { case COAL_ORE, - DEEPSLATE_COAL_ORE -> new ItemStack(Material.COAL); + DEEPSLATE_COAL_ORE -> StackResolver.of(Material.COAL); case DIAMOND_ORE, - DEEPSLATE_DIAMOND_ORE -> new ItemStack(Material.DIAMOND); + DEEPSLATE_DIAMOND_ORE -> StackResolver.of(Material.DIAMOND); case EMERALD_ORE, - DEEPSLATE_EMERALD_ORE -> new ItemStack(Material.EMERALD); + DEEPSLATE_EMERALD_ORE -> StackResolver.of(Material.EMERALD); case REDSTONE_ORE, - DEEPSLATE_REDSTONE_ORE -> new ItemStack(Material.REDSTONE, 4 + random.nextInt(2)); + DEEPSLATE_REDSTONE_ORE -> StackResolver.of(Material.REDSTONE, 4 + random.nextInt(2)); case LAPIS_ORE, - DEEPSLATE_LAPIS_ORE -> new ItemStack(Material.LAPIS_LAZULI, 4 + random.nextInt(4)); + DEEPSLATE_LAPIS_ORE -> StackResolver.of(Material.LAPIS_LAZULI, 4 + random.nextInt(4)); case COPPER_ORE, - DEEPSLATE_COPPER_ORE -> new ItemStack(Material.RAW_COPPER); + DEEPSLATE_COPPER_ORE -> StackResolver.of(Material.RAW_COPPER); case IRON_ORE, - DEEPSLATE_IRON_ORE -> new ItemStack(Material.RAW_IRON); + DEEPSLATE_IRON_ORE -> StackResolver.of(Material.RAW_IRON); case GOLD_ORE, - DEEPSLATE_GOLD_ORE -> new ItemStack(Material.RAW_GOLD); + DEEPSLATE_GOLD_ORE -> StackResolver.of(Material.RAW_GOLD); default -> super.getDrops(material, random); }; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java index 265db240ed..80ed93f437 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java @@ -14,6 +14,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -268,7 +269,7 @@ public List getDisplayRecipes() { List display = new ArrayList<>(); for (Material mat : surfaces.keySet()) { - display.add(new ItemStack(mat)); + display.add(StackResolver.of(mat)); } return display; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java index 08f69ec27a..2717fd096d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java @@ -12,6 +12,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -89,10 +90,10 @@ public Material getInputMaterial() { protected @Nonnull Set getGoldPanDrops() { Set settings = new HashSet<>(); - settings.add(new GoldPanDrop(this, "chance.FLINT", 40, new ItemStack(Material.FLINT))); - settings.add(new GoldPanDrop(this, "chance.CLAY", 20, new ItemStack(Material.CLAY_BALL))); + settings.add(new GoldPanDrop(this, "chance.FLINT", 40, StackResolver.of(Material.FLINT))); + settings.add(new GoldPanDrop(this, "chance.CLAY", 20, StackResolver.of(Material.CLAY_BALL))); settings.add(new GoldPanDrop(this, "chance.SIFTED_ORE", 35, SlimefunItems.SIFTED_ORE)); - settings.add(new GoldPanDrop(this, "chance.IRON_NUGGET", 5, new ItemStack(Material.IRON_NUGGET))); + settings.add(new GoldPanDrop(this, "chance.IRON_NUGGET", 5, StackResolver.of(Material.IRON_NUGGET))); return settings; } @@ -129,7 +130,7 @@ public void updateRandomizer() { ItemStack item = randomizer.getRandom(); // Fixes #2804 - return item != null ? item : new ItemStack(Material.AIR); + return item != null ? item : StackResolver.of(Material.AIR); } @Override @@ -187,7 +188,7 @@ public void updateRandomizer() { } for (Material material : getInputMaterials()) { - recipes.add(new ItemStack(material)); + recipes.add(StackResolver.of(material)); recipes.add(drop.getOutput()); } } @@ -209,7 +210,7 @@ public boolean isValidInput(@Nullable ItemStack itemStack) { } Material material = itemStack.getType(); - return isValidInputMaterial(material) && SlimefunUtils.isItemSimilar(itemStack, new ItemStack(material), true, false); + return isValidInputMaterial(material) && SlimefunUtils.isItemSimilar(itemStack, StackResolver.of(material), true, false); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java index 18c996547a..d0f46e3461 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java @@ -7,6 +7,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -47,12 +48,12 @@ public Material getInputMaterial() { protected @Nonnull Set getGoldPanDrops() { Set settings = new HashSet<>(); - settings.add(new GoldPanDrop(this, "chance.QUARTZ", 50, new ItemStack(Material.QUARTZ))); - settings.add(new GoldPanDrop(this, "chance.GOLD_NUGGET", 25, new ItemStack(Material.GOLD_NUGGET))); - settings.add(new GoldPanDrop(this, "chance.NETHER_WART", 10, new ItemStack(Material.NETHER_WART))); - settings.add(new GoldPanDrop(this, "chance.BLAZE_POWDER", 8, new ItemStack(Material.BLAZE_POWDER))); - settings.add(new GoldPanDrop(this, "chance.GLOWSTONE_DUST", 5, new ItemStack(Material.GLOWSTONE_DUST))); - settings.add(new GoldPanDrop(this, "chance.GHAST_TEAR", 2, new ItemStack(Material.GHAST_TEAR))); + settings.add(new GoldPanDrop(this, "chance.QUARTZ", 50, StackResolver.of(Material.QUARTZ))); + settings.add(new GoldPanDrop(this, "chance.GOLD_NUGGET", 25, StackResolver.of(Material.GOLD_NUGGET))); + settings.add(new GoldPanDrop(this, "chance.NETHER_WART", 10, StackResolver.of(Material.NETHER_WART))); + settings.add(new GoldPanDrop(this, "chance.BLAZE_POWDER", 8, StackResolver.of(Material.BLAZE_POWDER))); + settings.add(new GoldPanDrop(this, "chance.GLOWSTONE_DUST", 5, StackResolver.of(Material.GLOWSTONE_DUST))); + settings.add(new GoldPanDrop(this, "chance.GHAST_TEAR", 2, StackResolver.of(Material.GHAST_TEAR))); return settings; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java index 86499f2bee..6139589bd7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java @@ -3,6 +3,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -78,7 +79,7 @@ public PickaxeOfContainment(ItemGroup itemGroup, SlimefunItemStack item, RecipeT return spawner.getItemForEntityType(entityType); } - return new ItemStack(Material.SPAWNER); + return StackResolver.of(Material.SPAWNER); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java index 4cae8ed99d..c5a82f01b5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java @@ -5,6 +5,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -60,7 +61,7 @@ private void breakBlocks(Player p, List blocks, int fortune, ItemStack to b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); if (tool.containsEnchantment(Enchantment.SILK_TOUCH)) { - b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(b.getType())); + b.getWorld().dropItemNaturally(b.getLocation(), StackResolver.of(b.getType())); } else { for (ItemStack drop : b.getDrops(tool)) { b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop : new CustomItemStack(drop, fortune)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java index ce40980ded..6555c7c716 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java @@ -5,6 +5,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.entity.Creeper; import org.bukkit.entity.Monster; @@ -63,33 +64,33 @@ public EntityKillHandler getItemHandler() { switch (e.getEntityType()) { case ZOMBIE -> { if (random.nextInt(100) < chanceZombie.getValue()) { - e.getDrops().add(new ItemStack(Material.ZOMBIE_HEAD)); + e.getDrops().add(StackResolver.of(Material.ZOMBIE_HEAD)); } } case SKELETON -> { if (random.nextInt(100) < chanceSkeleton.getValue()) { - e.getDrops().add(new ItemStack(Material.SKELETON_SKULL)); + e.getDrops().add(StackResolver.of(Material.SKELETON_SKULL)); } } case CREEPER -> { if (random.nextInt(100) < chanceCreeper.getValue()) { - e.getDrops().add(new ItemStack(Material.CREEPER_HEAD)); + e.getDrops().add(StackResolver.of(Material.CREEPER_HEAD)); } } case WITHER_SKELETON -> { if (random.nextInt(100) < chanceWitherSkeleton.getValue()) { - e.getDrops().add(new ItemStack(Material.WITHER_SKELETON_SKULL)); + e.getDrops().add(StackResolver.of(Material.WITHER_SKELETON_SKULL)); } } case PIGLIN -> { if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_20) && random.nextInt(100) < chancePiglin.getValue()) { - e.getDrops().add(new ItemStack(Material.PIGLIN_HEAD)); + e.getDrops().add(StackResolver.of(Material.PIGLIN_HEAD)); } } case PLAYER -> { if (random.nextInt(100) < chancePlayer.getValue()) { - ItemStack skull = new ItemStack(Material.PLAYER_HEAD); + ItemStack skull = StackResolver.of(Material.PLAYER_HEAD); ItemMeta meta = skull.getItemMeta(); ((SkullMeta) meta).setOwningPlayer((Player) e.getEntity()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java index d63289aa46..689c3cde68 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java @@ -2,6 +2,7 @@ import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -49,7 +50,7 @@ public void onBlockFall(EntityChangeBlockEvent e) { FallingBlock block = (FallingBlock) e.getEntity(); if (block.getDropItem()) { - block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(block.getBlockData().getMaterial(), 1)); + block.getWorld().dropItemNaturally(block.getLocation(), StackResolver.of(block.getBlockData().getMaterial(), 1)); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java index 9e63107680..dbe0713a56 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java @@ -8,6 +8,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -82,15 +83,15 @@ private void addExtraDrops(List drops, EntityType entityType) { Random random = ThreadLocalRandom.current(); if (entityType == EntityType.WITHER_SKELETON && random.nextInt(250) < 2) { - drops.add(new ItemStack(Material.WITHER_SKELETON_SKULL)); + drops.add(StackResolver.of(Material.WITHER_SKELETON_SKULL)); } if (entityType == EntityType.BLAZE) { - drops.add(new ItemStack(Material.BLAZE_ROD, 1 + random.nextInt(1))); + drops.add(StackResolver.of(Material.BLAZE_ROD, 1 + random.nextInt(1))); } if (entityType == EntityType.VINDICATOR) { - drops.add(new ItemStack(Material.EMERALD, 1 + random.nextInt(2))); + drops.add(StackResolver.of(Material.EMERALD, 1 + random.nextInt(2))); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java index c03e238c4a..8017cdff65 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java @@ -4,6 +4,7 @@ import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.block.Furnace; @@ -87,7 +88,7 @@ public void onItemSmelt(FurnaceSmeltEvent e) { ItemStack item = result.get(); int previous = inventory.getResult() != null ? inventory.getResult().getAmount() : 0; amount = Math.min(item.getMaxStackSize() - previous, amount); - e.setResult(new ItemStack(item.getType(), amount)); + e.setResult(StackResolver.of(item.getType(), amount)); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index 7a8b29c0df..44a0fd85c3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -11,6 +11,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -190,7 +191,7 @@ private Collection getExtraDrops(LivingEntity entity, Collection> entry : iterators.entrySet()) { - inventory.setItem(entry.getKey(), new ItemStack(entry.getValue().next())); + inventory.setItem(entry.getKey(), StackResolver.of(entry.getValue().next())); } } finally { lock.readLock().unlock(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index a509b207f3..ad6fbce9fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -11,6 +11,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -233,7 +234,7 @@ public static boolean isRadioactive(@Nullable ItemStack item) { if (Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { // com.mojang.authlib.GameProfile does not exist in a Test Environment - return new ItemStack(Material.PLAYER_HEAD); + return StackResolver.of(Material.PLAYER_HEAD); } String base64 = texture; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java index db5555f6c9..02c47ae4f8 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java @@ -7,6 +7,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.utils.multiversion.StackResolver; import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.Material; @@ -161,7 +162,7 @@ public int getGeneratedOutput(Location l, Config data) { ItemStack fuel = operation.getIngredient(); if (isBucket(fuel)) { - inv.pushItem(new ItemStack(Material.BUCKET), getOutputSlots()); + inv.pushItem(StackResolver.of(Material.BUCKET), getOutputSlots()); } inv.replaceExistingItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "));