From 927eefd63ccd04615f5488b604ecbe6f58a35cb5 Mon Sep 17 00:00:00 2001 From: Scott Gomez Andoy Date: Tue, 4 Aug 2020 12:46:42 +0000 Subject: [PATCH 1/7] Translate recipes_tl.yml via GitLocalize --- src/main/resources/languages/recipes_tl.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/resources/languages/recipes_tl.yml b/src/main/resources/languages/recipes_tl.yml index e5b7025b9..e6c906b16 100644 --- a/src/main/resources/languages/recipes_tl.yml +++ b/src/main/resources/languages/recipes_tl.yml @@ -118,6 +118,11 @@ slimefun: lore: - I-craft ang item na ito tulad ng ipinakita - gamit ang Refinery. + barter_drop: + name: Piglin Bartering Drop + lore: + - Mag-barter kasama ang mga Piglins gamit ang mga + - Gold Ingots upang makuha ang aytem na ito. minecraft: shaped: name: Shaped Crafting Recipe From 35684b60fce3130eadc83b0149049b948c095e41 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 4 Aug 2020 17:59:41 +0200 Subject: [PATCH 2/7] Optimized performance for rainbow blocks --- .../slimefun4/core/handlers/RainbowTickHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java index 70fa1ce35..5cd2867ea 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java @@ -104,7 +104,7 @@ public class RainbowTickHandler extends BlockTicker { } }); - b.setBlockData(block); + b.setBlockData(block, false); return; } } From 06f64725d9adbb63de28764f95ba37c2ef8ec310 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 4 Aug 2020 18:00:31 +0200 Subject: [PATCH 3/7] Improved performance for idling Enhanced Furnaces on Paper --- CHANGELOG.md | 2 ++ .../items/blocks/EnhancedFurnace.java | 26 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c31f1753..6030626c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,8 @@ * Performance improvement for Programmable Android rotations * Removed Gravel -> Flint recipe from the Grind stone * Performance improvements for miner talismans +* Performance improvements for idling Enhanced Furnaces when using Paper +* Performance improvements for Rainbow Blocks #### Fixes * Fixed Programmable Androids rotating in the wrong direction diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java index a57ea975c..47f305dbf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java @@ -4,10 +4,13 @@ import java.util.concurrent.ThreadLocalRandom; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.block.Furnace; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.papermc.lib.PaperLib; +import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; @@ -64,12 +67,18 @@ public class EnhancedFurnace extends SimpleSlimefunItem { BlockStorage.clearBlockInfo(b); } else { - Furnace furnace = (Furnace) b.getState(); + BlockStateSnapshotResult result = PaperLib.getBlockState(b, false); + BlockState state = result.getState(); - if (furnace.getCookTime() > 0) { - int cookTime = furnace.getCookTime() + getSpeed() * 10; - furnace.setCookTime((short) Math.min(cookTime, furnace.getCookTimeTotal() - 1)); - furnace.update(true, false); + // Check if the BlockState is a Furnace and cooking something + if (state instanceof Furnace && ((Furnace) state).getCookTime() > 0) { + // Only get a snapshot if necessary + if (result.isSnapshot()) { + updateFurnace((Furnace) state); + } + else { + updateFurnace((Furnace) b.getState()); + } } } } @@ -80,4 +89,11 @@ public class EnhancedFurnace extends SimpleSlimefunItem { } }; } + + private void updateFurnace(Furnace furnace) { + // Update the cooktime + int cookTime = furnace.getCookTime() + getSpeed() * 10; + furnace.setCookTime((short) Math.min(cookTime, furnace.getCookTimeTotal() - 1)); + furnace.update(true, false); + } } From cf82201dcaf6fd6f89e021757e17dc10a8c641f3 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 4 Aug 2020 16:31:44 +0000 Subject: [PATCH 4/7] Update dependency me.clip:placeholderapi to v2.10.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 12c6a8e0d..b59367211 100644 --- a/pom.xml +++ b/pom.xml @@ -364,7 +364,7 @@ me.clip placeholderapi - 2.10.6 + 2.10.9 provided From f50d1d2faab7526187ba03330bb9943287909f36 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 4 Aug 2020 20:15:21 +0200 Subject: [PATCH 5/7] Big performance improvements to Enhanced Furnaces when using Paper --- .../implementation/items/RadioactiveItem.java | 1 + .../items/blocks/BlockPlacer.java | 11 +++++++ .../items/blocks/EnhancedFurnace.java | 30 ++++++++++++------- .../listeners/EnhancedFurnaceListener.java | 2 +- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java index e3966b274..54f5d83e0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java @@ -15,6 +15,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; /** * A quick and easy implementation of {@link SlimefunItem} that also implements the * interface {@link Radioactive}. + * This implementation is {@link NotPlaceable}! * * Simply specify a level of {@link Radioactivity} in the constructor. * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java index a85013b74..d478f9b59 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java @@ -28,6 +28,17 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +/** + * The {@link BlockPlacer} is a machine which can place {@link Block Blocks}, as the name + * would suggest. + * It really just is a special type of {@link Dispenser} which places items instead of + * shooting them. + * + * @author TheBusyBiscuit + * + * @see BlockPlacerPlaceEvent + * + */ public class BlockPlacer extends SimpleSlimefunItem { private final ItemSetting> blacklist = new ItemSetting<>("unplaceable-blocks", MaterialCollections.getAllUnbreakableBlocks().stream().map(Material::name).collect(Collectors.toList())); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java index 47f305dbf..bfdc7464b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java @@ -43,15 +43,26 @@ public class EnhancedFurnace extends SimpleSlimefunItem { this.fortuneLevel = fortune - 1; } - public int getSpeed() { + /** + * This returns the processing speed of this {@link EnhancedFurnace}. + * + * @return The processing speed + */ + public int getProcessingSpeed() { return speed; } + /** + * This returns the fuel efficiency of this {@link EnhancedFurnace}. + * The fuel efficiency is a multiplier that is applied to any fuel burnt in this {@link EnhancedFurnace}. + * + * @return The fuel multiplier + */ public int getFuelEfficiency() { return efficiency; } - public int getOutput() { + public int getRandomOutputAmount() { int bonus = ThreadLocalRandom.current().nextInt(fortuneLevel + 2); return 1 + bonus; } @@ -72,12 +83,11 @@ public class EnhancedFurnace extends SimpleSlimefunItem { // Check if the BlockState is a Furnace and cooking something if (state instanceof Furnace && ((Furnace) state).getCookTime() > 0) { - // Only get a snapshot if necessary + setProgress((Furnace) state); + + // Only update if necessary if (result.isSnapshot()) { - updateFurnace((Furnace) state); - } - else { - updateFurnace((Furnace) b.getState()); + state.update(true, false); } } } @@ -85,15 +95,15 @@ public class EnhancedFurnace extends SimpleSlimefunItem { @Override public boolean isSynchronized() { + // This messes with BlockStates, so it needs to be synchronized return true; } }; } - private void updateFurnace(Furnace furnace) { + private void setProgress(Furnace furnace) { // Update the cooktime - int cookTime = furnace.getCookTime() + getSpeed() * 10; + int cookTime = furnace.getCookTime() + getProcessingSpeed() * 10; furnace.setCookTime((short) Math.min(cookTime, furnace.getCookTimeTotal() - 1)); - furnace.update(true, false); } } 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 fcfb83f4f..d4e94d139 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 @@ -65,7 +65,7 @@ public class EnhancedFurnaceListener implements Listener { if (state instanceof Furnace) { FurnaceInventory inventory = ((Furnace) state).getInventory(); - int amount = inventory.getSmelting().getType().toString().endsWith("_ORE") ? ((EnhancedFurnace) sfItem).getOutput() : 1; + int amount = inventory.getSmelting().getType().toString().endsWith("_ORE") ? ((EnhancedFurnace) sfItem).getRandomOutputAmount() : 1; Optional result = SlimefunPlugin.getMinecraftRecipeService().getFurnaceOutput(inventory.getSmelting()); if (result.isPresent()) { From c168497e79800adcfcfe2a37c2be7ec370eaa164 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 5 Aug 2020 13:31:35 +0200 Subject: [PATCH 6/7] [CI skip] Reduced technical debt --- CHANGELOG.md | 1 + .../items/cargo/AbstractCargoNode.java | 82 ++++++++++ .../items/cargo/AbstractFilterNode.java | 140 ++++++++++++++++ .../items/cargo/AdvancedCargoOutputNode.java | 149 +---------------- .../items/cargo/CargoInputNode.java | 154 ++---------------- .../items/cargo/CargoOutputNode.java | 61 +------ .../slimefun4/utils/HeadTexture.java | 5 +- 7 files changed, 248 insertions(+), 344 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 6030626c9..41d84540a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ * Fixed #2183 * Fixed #2181 * Fixed #2180 +* Fixed #2122 ## Release Candidate 15 (01 Aug 2020) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java index 79f38daa7..fac303f2f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java @@ -2,19 +2,33 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; +import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; +/** + * This abstract class is the super class of all cargo nodes. + * + * @author TheBusyBiscuit + * + */ abstract class AbstractCargoNode extends SlimefunItem { protected static final String FREQUENCY = "frequency"; @@ -22,6 +36,21 @@ abstract class AbstractCargoNode extends SlimefunItem { public AbstractCargoNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); + addItemHandler(new BlockPlaceHandler(false) { + + @Override + public void onPlayerPlace(BlockPlaceEvent e) { + Block b = e.getBlock(); + + // The owner and frequency are required by every node + BlockStorage.addBlockInfo(b, "owner", e.getPlayer().getUniqueId().toString()); + BlockStorage.addBlockInfo(b, FREQUENCY, "0"); + + onPlace(e); + } + + }); + new BlockMenuPreset(getID(), ChatUtils.removeColorCodes(item.getItemMeta().getDisplayName())) { @Override @@ -46,6 +75,59 @@ abstract class AbstractCargoNode extends SlimefunItem { }; } + protected void addChannelSelector(Block b, BlockMenu menu, int slotPrev, int slotCurrent, int slotNext) { + boolean isChestTerminalInstalled = SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled(); + + menu.replaceExistingItem(slotPrev, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.CARGO_ARROW_LEFT.getTexture()), "&bPrevious Channel", "", "&e> Click to decrease the Channel ID by 1")); + menu.addMenuClickHandler(slotPrev, (p, slot, item, action) -> { + int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) - 1; + + if (channel < 0) { + if (isChestTerminalInstalled) { + channel = 16; + } + else { + channel = 15; + } + } + + BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channel)); + updateBlockMenu(menu, b); + return false; + }); + + int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY) == null) ? 0 : (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)))); + + if (channel == 16) { + menu.replaceExistingItem(slotCurrent, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.CHEST_TERMINAL.getTexture()), "&bChannel ID: &3" + (channel + 1))); + menu.addMenuClickHandler(slotCurrent, ChestMenuUtils.getEmptyClickHandler()); + } + else { + menu.replaceExistingItem(slotCurrent, new CustomItem(MaterialCollections.getAllWoolColors().get(channel), "&bChannel ID: &3" + (channel + 1))); + menu.addMenuClickHandler(slotCurrent, ChestMenuUtils.getEmptyClickHandler()); + } + + menu.replaceExistingItem(slotNext, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.CARGO_ARROW_RIGHT.getTexture()), "&bNext Channel", "", "&e> Click to increase the Channel ID by 1")); + menu.addMenuClickHandler(slotNext, (p, slot, item, action) -> { + int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) + 1; + + if (isChestTerminalInstalled) { + if (channeln > 16) { + channeln = 0; + } + } + else if (channeln > 15) { + channeln = 0; + } + + BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channeln)); + updateBlockMenu(menu, b); + return false; + }); + } + + protected abstract void onPlace(BlockPlaceEvent e); + protected abstract void createBorder(BlockMenuPreset preset); protected abstract void updateBlockMenu(BlockMenu menu, Block b); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java new file mode 100644 index 000000000..c93b1b37e --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java @@ -0,0 +1,140 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; +import org.bukkit.inventory.meta.ItemMeta; + +import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.api.BlockStorage; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; + +/** + * This abstract super class represents all filtered Cargo nodes. + * + * @author TheBusyBiscuit + * + * @see CargoInputNode + * @see AdvancedCargoOutputNode + * + */ +abstract class AbstractFilterNode extends AbstractCargoNode { + + protected static final int[] SLOTS = { 19, 20, 21, 28, 29, 30, 37, 38, 39 }; + + public AbstractFilterNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { + super(category, item, recipeType, recipe, recipeOutput); + + registerBlockHandler(getID(), (p, b, stack, reason) -> { + BlockMenu inv = BlockStorage.getInventory(b); + + if (inv != null) { + inv.dropItems(b.getLocation(), SLOTS); + } + + return true; + }); + } + + protected abstract int[] getBorder(); + + @Override + protected void onPlace(BlockPlaceEvent e) { + Block b = e.getBlock(); + BlockStorage.addBlockInfo(b, "index", "0"); + BlockStorage.addBlockInfo(b, "filter-type", "whitelist"); + BlockStorage.addBlockInfo(b, "filter-lore", String.valueOf(true)); + BlockStorage.addBlockInfo(b, "filter-durability", String.valueOf(false)); + } + + @Override + protected void createBorder(BlockMenuPreset preset) { + for (int i : getBorder()) { + preset.addItem(i, new CustomItem(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + } + + preset.addItem(2, new CustomItem(Material.PAPER, "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"), ChestMenuUtils.getEmptyClickHandler()); + } + + @Override + protected void updateBlockMenu(BlockMenu menu, Block b) { + String filterType = BlockStorage.getLocationInfo(b.getLocation(), "filter-type"); + + if (!BlockStorage.hasBlockInfo(b) || filterType == null || filterType.equals("whitelist")) { + menu.replaceExistingItem(15, new CustomItem(Material.WHITE_WOOL, "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist")); + menu.addMenuClickHandler(15, (p, slot, item, action) -> { + BlockStorage.addBlockInfo(b, "filter-type", "blacklist"); + updateBlockMenu(menu, b); + return false; + }); + } + else { + menu.replaceExistingItem(15, new CustomItem(Material.BLACK_WOOL, "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist")); + menu.addMenuClickHandler(15, (p, slot, item, action) -> { + BlockStorage.addBlockInfo(b, "filter-type", "whitelist"); + updateBlockMenu(menu, b); + return false; + }); + } + + String durability = BlockStorage.getLocationInfo(b.getLocation(), "filter-durability"); + + if (!BlockStorage.hasBlockInfo(b) || durability == null || durability.equals(String.valueOf(false))) { + ItemStack is = new ItemStack(Material.STONE_SWORD); + ItemMeta meta = is.getItemMeta(); + meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + is.setItemMeta(meta); + + menu.replaceExistingItem(16, new CustomItem(is, "&7Include Sub-IDs/Durability: &4\u2718", "", "&e> Click to toggle whether the Durability has to match")); + menu.addMenuClickHandler(16, (p, slot, item, action) -> { + BlockStorage.addBlockInfo(b, "filter-durability", String.valueOf(true)); + updateBlockMenu(menu, b); + return false; + }); + } + else { + ItemStack is = new ItemStack(Material.GOLDEN_SWORD); + ItemMeta meta = is.getItemMeta(); + meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + ((Damageable) meta).setDamage(20); + is.setItemMeta(meta); + + menu.replaceExistingItem(16, new CustomItem(is, "&7Include Sub-IDs/Durability: &2\u2714", "", "&e> Click to toggle whether the Durability has to match")); + menu.addMenuClickHandler(16, (p, slot, item, action) -> { + BlockStorage.addBlockInfo(b, "filter-durability", String.valueOf(false)); + updateBlockMenu(menu, b); + return false; + }); + } + + String lore = BlockStorage.getLocationInfo(b.getLocation(), "filter-lore"); + + if (!BlockStorage.hasBlockInfo(b) || lore == null || lore.equals(String.valueOf(true))) { + menu.replaceExistingItem(25, new CustomItem(Material.MAP, "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match")); + menu.addMenuClickHandler(25, (p, slot, item, action) -> { + BlockStorage.addBlockInfo(b, "filter-lore", String.valueOf(false)); + updateBlockMenu(menu, b); + return false; + }); + } + else { + menu.replaceExistingItem(25, new CustomItem(Material.MAP, "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match")); + menu.addMenuClickHandler(25, (p, slot, item, action) -> { + BlockStorage.addBlockInfo(b, "filter-lore", String.valueOf(true)); + updateBlockMenu(menu, b); + return false; + }); + } + + addChannelSelector(b, menu, 41, 42, 43); + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java index db54c90b0..a8f42c3bf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java @@ -1,165 +1,22 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.Damageable; -import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.cscorelib2.item.CustomItem; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; -public class AdvancedCargoOutputNode extends AbstractCargoNode { +public class AdvancedCargoOutputNode extends AbstractFilterNode { private static final int[] BORDER = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 22, 23, 24, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 }; - private static final int[] SLOTS = { 19, 20, 21, 28, 29, 30, 37, 38, 39 }; public AdvancedCargoOutputNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); - - addItemHandler(onPlace()); - registerBlockHandler(getID(), (p, b, stack, reason) -> { - BlockMenu inv = BlockStorage.getInventory(b); - - if (inv != null) { - inv.dropItems(b.getLocation(), SLOTS); - } - return true; - }); - } - - private BlockPlaceHandler onPlace() { - return new BlockPlaceHandler(false) { - - @Override - public void onPlayerPlace(BlockPlaceEvent e) { - Block b = e.getBlock(); - BlockStorage.addBlockInfo(b, "owner", e.getPlayer().getUniqueId().toString()); - BlockStorage.addBlockInfo(b, "index", "0"); - BlockStorage.addBlockInfo(b, FREQUENCY, "0"); - BlockStorage.addBlockInfo(b, "filter-type", "whitelist"); - BlockStorage.addBlockInfo(b, "filter-lore", String.valueOf(true)); - BlockStorage.addBlockInfo(b, "filter-durability", String.valueOf(false)); - } - }; } @Override - protected void createBorder(BlockMenuPreset preset) { - for (int i : BORDER) { - preset.addItem(i, new CustomItem(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); - } - - preset.addItem(2, new CustomItem(Material.PAPER, "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"), ChestMenuUtils.getEmptyClickHandler()); - } - - @Override - protected void updateBlockMenu(BlockMenu menu, Block b) { - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) { - menu.replaceExistingItem(15, new CustomItem(Material.WHITE_WOOL, "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist")); - menu.addMenuClickHandler(15, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-type", "blacklist"); - updateBlockMenu(menu, b); - return false; - }); - } - else { - menu.replaceExistingItem(15, new CustomItem(Material.BLACK_WOOL, "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist")); - menu.addMenuClickHandler(15, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-type", "whitelist"); - updateBlockMenu(menu, b); - return false; - }); - } - - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability").equals(String.valueOf(false))) { - menu.replaceExistingItem(16, new CustomItem(Material.STONE_SWORD, "&7Include Sub-IDs/Durability: &4\u2718", "", "&e> Click to toggle whether the Durability has to match")); - menu.addMenuClickHandler(16, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-durability", String.valueOf(true)); - updateBlockMenu(menu, b); - return false; - }); - } - else { - ItemStack is = new ItemStack(Material.GOLDEN_SWORD); - Damageable dmg = (Damageable) is.getItemMeta(); - dmg.setDamage(20); - is.setItemMeta((ItemMeta) dmg); - - menu.replaceExistingItem(16, new CustomItem(is, "&7Include Sub-IDs/Durability: &2\u2714", "", "&e> Click to toggle whether the Durability has to match")); - menu.addMenuClickHandler(16, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-durability", String.valueOf(false)); - updateBlockMenu(menu, b); - return false; - }); - } - - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore").equals(String.valueOf(true))) { - menu.replaceExistingItem(25, new CustomItem(Material.MAP, "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match")); - menu.addMenuClickHandler(25, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-lore", String.valueOf(false)); - updateBlockMenu(menu, b); - return false; - }); - } - else { - menu.replaceExistingItem(25, new CustomItem(Material.MAP, "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match")); - menu.addMenuClickHandler(25, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-lore", String.valueOf(true)); - updateBlockMenu(menu, b); - return false; - }); - } - - menu.replaceExistingItem(41, new CustomItem(SlimefunUtils.getCustomHead("f2599bd986659b8ce2c4988525c94e19ddd39fad08a38284a197f1b70675acc"), "&bChannel", "", "&e> Click to decrease the Channel ID by 1")); - menu.addMenuClickHandler(41, (p, slot, item, action) -> { - int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) - 1; - if (channel < 0) { - if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) channel = 16; - else channel = 15; - } - BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channel)); - updateBlockMenu(menu, b); - return false; - }); - - int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY) == null) ? 0 : (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)))); - - if (channel == 16) { - menu.replaceExistingItem(42, new CustomItem(SlimefunUtils.getCustomHead("7a44ff3a5f49c69cab676bad8d98a063fa78cfa61916fdef3e267557fec18283"), "&bChannel ID: &3" + (channel + 1))); - menu.addMenuClickHandler(42, ChestMenuUtils.getEmptyClickHandler()); - } - else { - menu.replaceExistingItem(42, new CustomItem(MaterialCollections.getAllWoolColors().get(channel), "&bChannel ID: &3" + (channel + 1))); - menu.addMenuClickHandler(42, ChestMenuUtils.getEmptyClickHandler()); - } - - menu.replaceExistingItem(43, new CustomItem(SlimefunUtils.getCustomHead("c2f910c47da042e4aa28af6cc81cf48ac6caf37dab35f88db993accb9dfe516"), "&bChannel", "", "&e> Click to increase the Channel ID by 1")); - menu.addMenuClickHandler(43, (p, slot, item, action) -> { - int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) + 1; - - if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) { - if (channeln > 16) channeln = 0; - } - else { - if (channeln > 15) channeln = 0; - } - - BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channeln)); - updateBlockMenu(menu, b); - return false; - }); + protected int[] getBorder() { + return BORDER; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java index 7dbc91c49..f0876b835 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java @@ -1,114 +1,44 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.Damageable; -import org.bukkit.inventory.meta.ItemMeta; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; -public class CargoInputNode extends AbstractCargoNode { +public class CargoInputNode extends AbstractFilterNode { private static final int[] BORDER = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 22, 23, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 }; - private static final int[] SLOTS = { 19, 20, 21, 28, 29, 30, 37, 38, 39 }; public CargoInputNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); - - addItemHandler(onPlace()); - registerBlockHandler(getID(), (p, b, stack, reason) -> { - BlockMenu inv = BlockStorage.getInventory(b); - - if (inv != null) { - inv.dropItems(b.getLocation(), SLOTS); - } - - return true; - }); - } - - private BlockPlaceHandler onPlace() { - return new BlockPlaceHandler(false) { - - @Override - public void onPlayerPlace(BlockPlaceEvent e) { - Block b = e.getBlock(); - BlockStorage.addBlockInfo(b, "owner", e.getPlayer().getUniqueId().toString()); - BlockStorage.addBlockInfo(b, "index", "0"); - BlockStorage.addBlockInfo(b, FREQUENCY, "0"); - BlockStorage.addBlockInfo(b, "filter-type", "whitelist"); - BlockStorage.addBlockInfo(b, "filter-lore", String.valueOf(true)); - BlockStorage.addBlockInfo(b, "filter-durability", String.valueOf(false)); - BlockStorage.addBlockInfo(b, "round-robin", String.valueOf(false)); - } - }; } @Override - protected void createBorder(BlockMenuPreset preset) { - for (int i : BORDER) { - preset.addItem(i, new CustomItem(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); - } + protected int[] getBorder() { + return BORDER; + } - preset.addItem(2, new CustomItem(Material.PAPER, "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"), ChestMenuUtils.getEmptyClickHandler()); + @Override + protected void onPlace(BlockPlaceEvent e) { + super.onPlace(e); + BlockStorage.addBlockInfo(e.getBlock(), "round-robin", String.valueOf(false)); } @Override protected void updateBlockMenu(BlockMenu menu, Block b) { - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) { - menu.replaceExistingItem(15, new CustomItem(Material.WHITE_WOOL, "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist")); - menu.addMenuClickHandler(15, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-type", "blacklist"); - updateBlockMenu(menu, b); - return false; - }); - } - else { - menu.replaceExistingItem(15, new CustomItem(Material.BLACK_WOOL, "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist")); - menu.addMenuClickHandler(15, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-type", "whitelist"); - updateBlockMenu(menu, b); - return false; - }); - } + super.updateBlockMenu(menu, b); - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability").equals(String.valueOf(false))) { - menu.replaceExistingItem(16, new CustomItem(Material.STONE_SWORD, "&7Include Sub-IDs/Durability: &4\u2718", "", "&e> Click to toggle whether the Durability has to match")); - menu.addMenuClickHandler(16, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-durability", String.valueOf(true)); - updateBlockMenu(menu, b); - return false; - }); - } - else { - ItemStack is = new ItemStack(Material.GOLDEN_SWORD); - Damageable dmg = (Damageable) is.getItemMeta(); - dmg.setDamage(20); - is.setItemMeta((ItemMeta) dmg); - - menu.replaceExistingItem(16, new CustomItem(is, "&7Include Sub-IDs/Durability: &2\u2714", "", "&e> Click to toggle whether the Durability has to match")); - menu.addMenuClickHandler(16, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-durability", String.valueOf(false)); - updateBlockMenu(menu, b); - return false; - }); - } - - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "round-robin") == null || BlockStorage.getLocationInfo(b.getLocation(), "round-robin").equals(String.valueOf(false))) { - menu.replaceExistingItem(24, new CustomItem(SlimefunUtils.getCustomHead("d78f2b7e5e75639ea7fb796c35d364c4df28b4243e66b76277aadcd6261337"), "&7Round-Robin Mode: &4\u2718", "", "&e> Click to enable Round Robin Mode", "&e(Items will be equally distributed on the Channel)")); + String roundRobinMode = BlockStorage.getLocationInfo(b.getLocation(), "round-robin"); + if (!BlockStorage.hasBlockInfo(b) || roundRobinMode == null || roundRobinMode.equals(String.valueOf(false))) { + menu.replaceExistingItem(24, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.ENERGY_REGULATOR.getTexture()), "&7Round-Robin Mode: &4\u2718", "", "&e> Click to enable Round Robin Mode", "&e(Items will be equally distributed on the Channel)")); menu.addMenuClickHandler(24, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, "round-robin", String.valueOf(true)); updateBlockMenu(menu, b); @@ -116,69 +46,13 @@ public class CargoInputNode extends AbstractCargoNode { }); } else { - menu.replaceExistingItem(24, new CustomItem(SlimefunUtils.getCustomHead("d78f2b7e5e75639ea7fb796c35d364c4df28b4243e66b76277aadcd6261337"), "&7Round-Robin Mode: &2\u2714", "", "&e> Click to disable Round Robin Mode", "&e(Items will be equally distributed on the Channel)")); + menu.replaceExistingItem(24, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.ENERGY_REGULATOR.getTexture()), "&7Round-Robin Mode: &2\u2714", "", "&e> Click to disable Round Robin Mode", "&e(Items will be equally distributed on the Channel)")); menu.addMenuClickHandler(24, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, "round-robin", String.valueOf(false)); updateBlockMenu(menu, b); return false; }); } - - if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore").equals(String.valueOf(true))) { - menu.replaceExistingItem(25, new CustomItem(Material.MAP, "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match")); - menu.addMenuClickHandler(25, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-lore", String.valueOf(false)); - updateBlockMenu(menu, b); - return false; - }); - } - else { - menu.replaceExistingItem(25, new CustomItem(Material.MAP, "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match")); - menu.addMenuClickHandler(25, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "filter-lore", String.valueOf(true)); - updateBlockMenu(menu, b); - return false; - }); - } - - menu.replaceExistingItem(41, new CustomItem(SlimefunUtils.getCustomHead("f2599bd986659b8ce2c4988525c94e19ddd39fad08a38284a197f1b70675acc"), "&bChannel", "", "&e> Click to decrease the Channel ID by 1")); - menu.addMenuClickHandler(41, (p, slot, item, action) -> { - int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) - 1; - if (channel < 0) { - if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) channel = 16; - else channel = 15; - } - BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channel)); - updateBlockMenu(menu, b); - return false; - }); - - int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY) == null) ? 0 : (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)))); - - if (channel == 16) { - menu.replaceExistingItem(42, new CustomItem(SlimefunUtils.getCustomHead("7a44ff3a5f49c69cab676bad8d98a063fa78cfa61916fdef3e267557fec18283"), "&bChannel ID: &3" + (channel + 1))); - menu.addMenuClickHandler(42, ChestMenuUtils.getEmptyClickHandler()); - } - else { - menu.replaceExistingItem(42, new CustomItem(new ItemStack(MaterialCollections.getAllWoolColors().get(channel)), "&bChannel ID: &3" + (channel + 1))); - menu.addMenuClickHandler(42, ChestMenuUtils.getEmptyClickHandler()); - } - - menu.replaceExistingItem(43, new CustomItem(SlimefunUtils.getCustomHead("c2f910c47da042e4aa28af6cc81cf48ac6caf37dab35f88db993accb9dfe516"), "&bChannel", "", "&e> Click to increase the Channel ID by 1")); - menu.addMenuClickHandler(43, (p, slot, item, action) -> { - int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) + 1; - - if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) { - if (channeln > 16) channeln = 0; - } - else { - if (channeln > 15) channeln = 0; - } - - BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channeln)); - updateBlockMenu(menu, b); - return false; - }); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java index f92e6fdfa..31ea4dcd8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java @@ -6,14 +6,9 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -24,20 +19,11 @@ public class CargoOutputNode extends AbstractCargoNode { public CargoOutputNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); - - addItemHandler(onPlace()); } - private BlockPlaceHandler onPlace() { - return new BlockPlaceHandler(false) { - - @Override - public void onPlayerPlace(BlockPlaceEvent e) { - Block b = e.getBlock(); - BlockStorage.addBlockInfo(b, "owner", e.getPlayer().getUniqueId().toString()); - BlockStorage.addBlockInfo(b, FREQUENCY, "0"); - } - }; + @Override + protected void onPlace(BlockPlaceEvent e) { + // We only require the default values } @Override @@ -49,46 +35,7 @@ public class CargoOutputNode extends AbstractCargoNode { @Override protected void updateBlockMenu(BlockMenu menu, Block b) { - menu.replaceExistingItem(12, new CustomItem(SlimefunUtils.getCustomHead("f2599bd986659b8ce2c4988525c94e19ddd39fad08a38284a197f1b70675acc"), "&bChannel", "", "&e> Click to decrease the Channel ID by 1")); - menu.addMenuClickHandler(12, (p, slot, item, action) -> { - int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) - 1; - - if (channel < 0) { - if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) channel = 16; - else channel = 15; - } - - BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channel)); - updateBlockMenu(menu, b); - return false; - }); - - int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY) == null) ? 0 : (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)))); - - if (channel == 16) { - menu.replaceExistingItem(13, new CustomItem(SlimefunUtils.getCustomHead("7a44ff3a5f49c69cab676bad8d98a063fa78cfa61916fdef3e267557fec18283"), "&bChannel ID: &3" + (channel + 1))); - menu.addMenuClickHandler(13, ChestMenuUtils.getEmptyClickHandler()); - } - else { - menu.replaceExistingItem(13, new CustomItem(MaterialCollections.getAllWoolColors().get(channel), "&bChannel ID: &3" + (channel + 1))); - menu.addMenuClickHandler(13, ChestMenuUtils.getEmptyClickHandler()); - } - - menu.replaceExistingItem(14, new CustomItem(SlimefunUtils.getCustomHead("c2f910c47da042e4aa28af6cc81cf48ac6caf37dab35f88db993accb9dfe516"), "&bChannel", "", "&e> Click to increase the Channel ID by 1")); - menu.addMenuClickHandler(14, (p, slot, item, action) -> { - int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) + 1; - - if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) { - if (channeln > 16) channeln = 0; - } - else { - if (channeln > 15) channeln = 0; - } - - BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channeln)); - updateBlockMenu(menu, b); - return false; - }); + addChannelSelector(b, menu, 12, 13, 14); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java index d8aecf27e..87e9f49e1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java @@ -96,7 +96,10 @@ public enum HeadTexture { NETHER_STAR_REACTOR("a11ed1d1b25b624665ecdddc3d3a5dff0b9f35e3de77a12f516e60fe8501cc8d"), UNKNOWN("46ba63344f49dd1c4f5488e926bf3d9e2b29916a6c50d610bb40a5273dc8c82"), MISSING_TEXTURE("e9eb9da26cf2d3341397a7f4913ba3d37d1ad10eae30ab25fa39ceb84bc"), - MINECRAFT_CHUNK("8449b9318e33158e64a46ab0de121c3d40000e3332c1574932b3c849d8fa0dc2"); + MINECRAFT_CHUNK("8449b9318e33158e64a46ab0de121c3d40000e3332c1574932b3c849d8fa0dc2"), + CHEST_TERMINAL("7a44ff3a5f49c69cab676bad8d98a063fa78cfa61916fdef3e267557fec18283"), + CARGO_ARROW_LEFT("f2599bd986659b8ce2c4988525c94e19ddd39fad08a38284a197f1b70675acc"), + CARGO_ARROW_RIGHT("c2f910c47da042e4aa28af6cc81cf48ac6caf37dab35f88db993accb9dfe516"); private final String texture; From 7c3599c8625ed6449c37622981a059afc4e0edf4 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 5 Aug 2020 16:44:43 +0200 Subject: [PATCH 7/7] [CI skip] Reduced technical debt --- CHANGELOG.md | 1 + .../api/events/BlockPlacerPlaceEvent.java | 2 + .../core/attributes/PiglinBarterDrop.java | 3 +- .../items/androids/ProgrammableAndroid.java | 4 +- .../items/electric/machines/AutoDrier.java | 109 ++++------------- .../implementation/items/medical/Bandage.java | 15 ++- .../implementation/items/medical/Rag.java | 47 -------- .../setup/SlimefunItemSetup.java | 111 +++++++----------- 8 files changed, 85 insertions(+), 207 deletions(-) delete mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Rag.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 41d84540a..df82aa2e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ * Performance improvements for miner talismans * Performance improvements for idling Enhanced Furnaces when using Paper * Performance improvements for Rainbow Blocks +* Crafting a Rag now yields two items #### Fixes * Fixed Programmable Androids rotating in the wrong direction diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java index 43bc0e811..b2e30f85c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java @@ -32,6 +32,8 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { * * @param blockPlacer * The {@link BlockPlacer} + * @param placedItem + * The {@link ItemStack} of the {@link Block} that was placed * @param block * The placed {@link Block} */ diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java index 7cf46be4d..32a3b6449 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java @@ -1,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; import org.bukkit.entity.Piglin; +import org.bukkit.event.entity.EntityDropItemEvent; import io.github.thebusybiscuit.slimefun4.implementation.listeners.PiglinListener; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -8,7 +9,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; /** * This interface, when attached to a {@link SlimefunItem}, provides a variable (0-100%) chance for - * a {@link SlimefunItem} to be dropped by a {@link Piglin} on {@link EntityItemDropEvent}. + * a {@link SlimefunItem} to be dropped by a {@link Piglin} on {@link EntityDropItemEvent}. * * @author dNiym * 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 725f03a46..4bd2b00e5 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 @@ -174,7 +174,9 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent * * @return The type of this {@link ProgrammableAndroid} */ - public abstract AndroidType getAndroidType(); + public AndroidType getAndroidType() { + return AndroidType.NONE; + } /** * This returns the {@link AndroidFuelSource} for this {@link ProgrammableAndroid}. 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 c25892873..43fa7d251 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 @@ -5,22 +5,14 @@ import java.util.List; import org.bukkit.Material; import org.bukkit.Tag; -import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; -import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; /** * The {@link AutoDrier} is an implementation of {@link AContainer} that features recipes @@ -32,11 +24,15 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; */ public class AutoDrier extends AContainer implements RecipeDisplayItem { - private final List recipeList = new ArrayList<>(); + private List recipeList; public AutoDrier(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); + } + @Override + protected void registerDefaultRecipes() { + recipeList = new ArrayList<>(); recipeList.add(new ItemStack(Material.ROTTEN_FLESH)); recipeList.add(new ItemStack(Material.LEATHER)); @@ -49,11 +45,11 @@ public class AutoDrier extends AContainer implements RecipeDisplayItem { recipeList.add(new ItemStack(Material.POTION)); recipeList.add(new ItemStack(Material.GLASS_BOTTLE)); - recipeList.add(new ItemStack(Material.OAK_SAPLING)); - recipeList.add(new ItemStack(Material.STICK, 2)); + recipeList.add(new ItemStack(Material.SPLASH_POTION)); + recipeList.add(new ItemStack(Material.GLASS_BOTTLE)); - recipeList.add(new ItemStack(Material.OAK_LEAVES)); - recipeList.add(new ItemStack(Material.STICK)); + recipeList.add(new ItemStack(Material.LINGERING_POTION)); + recipeList.add(new ItemStack(Material.GLASS_BOTTLE)); recipeList.add(new ItemStack(Material.WATER_BUCKET)); recipeList.add(new ItemStack(Material.BUCKET)); @@ -78,6 +74,21 @@ public class AutoDrier extends AContainer implements RecipeDisplayItem { recipeList.add(new ItemStack(Material.COOKED_SALMON)); recipeList.add(SlimefunItems.FISH_JERKY); + + for (Material sapling : Tag.SAPLINGS.getValues()) { + recipeList.add(new ItemStack(sapling)); + recipeList.add(new ItemStack(Material.STICK, 2)); + } + + for (Material leaves : Tag.LEAVES.getValues()) { + recipeList.add(new ItemStack(leaves)); + recipeList.add(new ItemStack(Material.STICK)); + } + + // Now convert them to machine recipes + for (int i = 0; i < recipeList.size(); i += 2) { + registerRecipe(6, recipeList.get(i), recipeList.get(i + 1)); + } } @Override @@ -95,78 +106,6 @@ public class AutoDrier extends AContainer implements RecipeDisplayItem { return recipeList; } - @Override - protected void tick(Block b) { - BlockMenu menu = BlockStorage.getInventory(b); - - if (isProcessing(b)) { - int timeleft = progress.get(b); - if (timeleft > 0) { - ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar()); - - if (ChargableBlock.getCharge(b) < getEnergyConsumption()) { - return; - } - - ChargableBlock.addCharge(b, -getEnergyConsumption()); - progress.put(b, timeleft - 1); - } - else { - menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " ")); - menu.pushItem(processing.get(b).getOutput()[0], getOutputSlots()); - - progress.remove(b); - processing.remove(b); - } - } - else { - MachineRecipe r = null; - int inputSlot = -1; - - for (int slot : getInputSlots()) { - ItemStack item = menu.getItemInSlot(slot); - if (item != null) { - ItemStack output = getOutput(item); - - if (output != null) { - r = new MachineRecipe(6, new ItemStack[] { item }, new ItemStack[] { output.clone() }); - inputSlot = slot; - break; - } - } - } - - if (r != null) { - if (inputSlot == -1) return; - if (!menu.fits(r.getOutput()[0], getOutputSlots())) return; - - menu.consumeItem(inputSlot); - processing.put(b, r); - progress.put(b, r.getTicks()); - } - } - } - - private ItemStack getOutput(ItemStack item) { - for (int i = 0; i < recipeList.size(); i += 2) { - if (SlimefunUtils.isItemSimilar(item, recipeList.get(i), true)) { - return recipeList.get(i + 1); - } - } - - if (Tag.SAPLINGS.isTagged(item.getType())) { - return new ItemStack(Material.STICK, 2); - } - else if (Tag.LEAVES.isTagged(item.getType())) { - return new ItemStack(Material.STICK, 1); - } - else if (item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION) { - return new ItemStack(Material.GLASS_BOTTLE); - } - - return null; - } - @Override public int getEnergyConsumption() { return 5; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java index 33235a6a3..4c2acb049 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java @@ -16,10 +16,21 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +/** + * A {@link Bandage} or Rag is a medical supply which heals the {@link Player} and extinguishes + * fire. + * + * @author TheBusyBiscuit + * + */ public class Bandage extends SimpleSlimefunItem { - public Bandage(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { + private final int healingLevel; + + public Bandage(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput, int healingLevel) { super(category, item, recipeType, recipe, recipeOutput); + + this.healingLevel = healingLevel; } @Override @@ -37,7 +48,7 @@ public class Bandage extends SimpleSlimefunItem { } p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL); - p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1)); + p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, healingLevel)); p.setFireTicks(0); e.cancel(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Rag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Rag.java deleted file mode 100644 index 2d314ee86..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Rag.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.medical; - -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.attribute.Attribute; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import me.mrCookieSlime.Slimefun.Lists.RecipeType; -import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; - -public class Rag extends SimpleSlimefunItem { - - public Rag(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { - super(category, item, recipeType, recipe); - } - - @Override - public ItemUseHandler getItemHandler() { - return e -> { - Player p = e.getPlayer(); - - // Player is neither burning nor injured - if (p.getFireTicks() <= 0 && p.getHealth() >= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { - return; - } - - if (p.getGameMode() != GameMode.CREATIVE) { - ItemUtils.consumeItem(e.getItem(), false); - } - - p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL); - p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0)); - p.setFireTicks(0); - - e.cancel(); - }; - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 607c000ee..89fb366f7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -25,7 +25,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AdvancedFarmerAndroid; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidType; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ButcherAndroid; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FisherAndroid; @@ -139,7 +138,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman; import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Bandage; import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Medicine; -import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Rag; import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Splint; import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Vitamins; import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard; @@ -417,7 +415,7 @@ public final class SlimefunItemSetup { new ItemStack[] {null, new ItemStack(Material.REDSTONE), null, SlimefunItems.ZINC_INGOT, SlimefunItems.SULFATE, SlimefunItems.COPPER_INGOT, SlimefunItems.ZINC_INGOT, SlimefunItems.SULFATE, SlimefunItems.COPPER_INGOT}) .register(plugin); - registerArmorSet(categories.magicalArmor, new ItemStack(Material.GLOWSTONE), new ItemStack[] {SlimefunItems.GLOWSTONE_HELMET, SlimefunItems.GLOWSTONE_CHESTPLATE, SlimefunItems.GLOWSTONE_LEGGINGS, SlimefunItems.GLOWSTONE_BOOTS}, "GLOWSTONE", + registerArmorSet(categories.magicalArmor, new ItemStack(Material.GLOWSTONE), new ItemStack[] {SlimefunItems.GLOWSTONE_HELMET, SlimefunItems.GLOWSTONE_CHESTPLATE, SlimefunItems.GLOWSTONE_LEGGINGS, SlimefunItems.GLOWSTONE_BOOTS}, "GLOWSTONE", false, new PotionEffect[][] { new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)}, new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)}, @@ -425,11 +423,11 @@ public final class SlimefunItemSetup { new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 0)} }, plugin); - registerArmorSet(categories.armor, SlimefunItems.DAMASCUS_STEEL_INGOT, new ItemStack[] {SlimefunItems.DAMASCUS_STEEL_HELMET, SlimefunItems.DAMASCUS_STEEL_CHESTPLATE, SlimefunItems.DAMASCUS_STEEL_LEGGINGS, SlimefunItems.DAMASCUS_STEEL_BOOTS}, "DAMASCUS_STEEL", false, plugin); + registerArmorSet(categories.armor, SlimefunItems.DAMASCUS_STEEL_INGOT, new ItemStack[] {SlimefunItems.DAMASCUS_STEEL_HELMET, SlimefunItems.DAMASCUS_STEEL_CHESTPLATE, SlimefunItems.DAMASCUS_STEEL_LEGGINGS, SlimefunItems.DAMASCUS_STEEL_BOOTS}, "DAMASCUS_STEEL", false, new PotionEffect[0][0], plugin); - registerArmorSet(categories.armor, SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack[] {SlimefunItems.REINFORCED_ALLOY_HELMET, SlimefunItems.REINFORCED_ALLOY_CHESTPLATE, SlimefunItems.REINFORCED_ALLOY_LEGGINGS, SlimefunItems.REINFORCED_ALLOY_BOOTS}, "REINFORCED_ALLOY", false, plugin); + registerArmorSet(categories.armor, SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack[] {SlimefunItems.REINFORCED_ALLOY_HELMET, SlimefunItems.REINFORCED_ALLOY_CHESTPLATE, SlimefunItems.REINFORCED_ALLOY_LEGGINGS, SlimefunItems.REINFORCED_ALLOY_BOOTS}, "REINFORCED_ALLOY", false, new PotionEffect[0][0], plugin); - registerArmorSet(categories.armor, new ItemStack(Material.CACTUS), new ItemStack[] {SlimefunItems.CACTUS_HELMET, SlimefunItems.CACTUS_CHESTPLATE, SlimefunItems.CACTUS_LEGGINGS, SlimefunItems.CACTUS_BOOTS}, "CACTUS", false, plugin); + registerArmorSet(categories.armor, new ItemStack(Material.CACTUS), new ItemStack[] {SlimefunItems.CACTUS_HELMET, SlimefunItems.CACTUS_CHESTPLATE, SlimefunItems.CACTUS_LEGGINGS, SlimefunItems.CACTUS_BOOTS}, "CACTUS", false, new PotionEffect[0][0], plugin); new SlimefunItem(categories.resources, SlimefunItems.REINFORCED_ALLOY_INGOT, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.HARDENED_METAL_INGOT, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.SOLDER_INGOT, SlimefunItems.BILLON_INGOT, SlimefunItems.GOLD_24K, null, null, null}) @@ -876,7 +874,7 @@ public final class SlimefunItemSetup { registerArmorSet(categories.armor, SlimefunItems.CHAIN, new ItemStack[] { new ItemStack(Material.CHAINMAIL_HELMET), new ItemStack(Material.CHAINMAIL_CHESTPLATE), new ItemStack(Material.CHAINMAIL_LEGGINGS), new ItemStack(Material.CHAINMAIL_BOOTS) - }, "CHAIN", true, plugin); + }, "CHAIN", true, new PotionEffect[0][0], plugin); new Talisman(SlimefunItems.TALISMAN_WHIRLWIND, new ItemStack[] {SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, SlimefunItems.STAFF_WIND, SlimefunItems.TALISMAN_TRAVELLER, SlimefunItems.STAFF_WIND, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3} @@ -911,7 +909,7 @@ public final class SlimefunItemSetup { registerArmorSet(categories.armor, SlimefunItems.GILDED_IRON, new ItemStack[] { SlimefunItems.GILDED_IRON_HELMET, SlimefunItems.GILDED_IRON_CHESTPLATE, SlimefunItems.GILDED_IRON_LEGGINGS, SlimefunItems.GILDED_IRON_BOOTS - }, "GILDED_IRON", false, plugin); + }, "GILDED_IRON", false, new PotionEffect[0][0], plugin); new SlimefunItem(categories.technicalComponents, SlimefunItems.REINFORCED_CLOTH, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {null, SlimefunItems.CLOTH, null, SlimefunItems.CLOTH, SlimefunItems.LEAD_INGOT, SlimefunItems.CLOTH, null, SlimefunItems.CLOTH, null}, new SlimefunItemStack(SlimefunItems.REINFORCED_CLOTH, 2)) @@ -965,20 +963,21 @@ public final class SlimefunItemSetup { registerArmorSet(categories.armor, SlimefunItems.GOLD_12K, new ItemStack[] { SlimefunItems.GOLD_HELMET, SlimefunItems.GOLD_CHESTPLATE, SlimefunItems.GOLD_LEGGINGS, SlimefunItems.GOLD_BOOTS - }, "GOLD_12K", false, plugin); + }, "GOLD_12K", false, new PotionEffect[0][0], plugin); new SlimefunItem(categories.misc, SlimefunItems.CLOTH, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {new ItemStack(Material.WHITE_WOOL), null, null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.CLOTH, 8)) .register(plugin); - new Rag(categories.usefulItems, SlimefunItems.RAG, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.CLOTH, SlimefunItems.CLOTH, SlimefunItems.CLOTH, new ItemStack(Material.STRING), null, new ItemStack(Material.STRING), SlimefunItems.CLOTH, SlimefunItems.CLOTH, SlimefunItems.CLOTH}) + new Bandage(categories.usefulItems, SlimefunItems.RAG, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {SlimefunItems.CLOTH, SlimefunItems.CLOTH, SlimefunItems.CLOTH, new ItemStack(Material.STRING), null, new ItemStack(Material.STRING), SlimefunItems.CLOTH, SlimefunItems.CLOTH, SlimefunItems.CLOTH}, + new SlimefunItemStack(SlimefunItems.RAG, 2), 0) .register(plugin); new Bandage(categories.usefulItems, SlimefunItems.BANDAGE, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.RAG, new ItemStack(Material.STRING), SlimefunItems.RAG, null, null, null, null, null, null}, - new CustomItem(SlimefunItems.BANDAGE, 4)) + new SlimefunItemStack(SlimefunItems.BANDAGE, 4), 1) .register(plugin); new Splint(categories.usefulItems, SlimefunItems.SPLINT, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -2201,11 +2200,6 @@ public final class SlimefunItemSetup { new ProgrammableAndroid(categories.androids, SlimefunItems.PROGRAMMABLE_ANDROID, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.PLASTIC_SHEET, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.PLASTIC_SHEET, SlimefunItems.COAL_GENERATOR, SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.CHEST), SlimefunItems.PLASTIC_SHEET, SlimefunItems.PLASTIC_SHEET, SlimefunItems.PLASTIC_SHEET}) { - @Override - public AndroidType getAndroidType() { - return AndroidType.NONE; - } - @Override public float getFuelEfficiency() { return 1; @@ -2302,11 +2296,6 @@ public final class SlimefunItemSetup { new ProgrammableAndroid(categories.androids, SlimefunItems.PROGRAMMABLE_ANDROID_2, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.PLASTIC_SHEET, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.PLASTIC_SHEET, SlimefunItems.COMBUSTION_REACTOR, SlimefunItems.PROGRAMMABLE_ANDROID, new ItemStack(Material.CHEST), SlimefunItems.PLASTIC_SHEET, SlimefunItems.POWER_CRYSTAL, SlimefunItems.PLASTIC_SHEET}) { - @Override - public AndroidType getAndroidType() { - return AndroidType.NONE; - } - @Override public float getFuelEfficiency() { return 1.5F; @@ -2371,11 +2360,6 @@ public final class SlimefunItemSetup { new ProgrammableAndroid(categories.androids, SlimefunItems.PROGRAMMABLE_ANDROID_3, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.PLASTIC_SHEET, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.PLASTIC_SHEET, SlimefunItems.NUCLEAR_REACTOR, SlimefunItems.PROGRAMMABLE_ANDROID_2, new ItemStack(Material.CHEST), SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.POWER_CRYSTAL, SlimefunItems.BLISTERING_INGOT_3}) { - @Override - public AndroidType getAndroidType() { - return AndroidType.NONE; - } - @Override public float getFuelEfficiency() { return 1F; @@ -2469,7 +2453,7 @@ public final class SlimefunItemSetup { new InfernalBonemeal(categories.magicalGadgets, SlimefunItems.INFERNAL_BONEMEAL, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.NETHER_WART), SlimefunItems.EARTH_RUNE, new ItemStack(Material.NETHER_WART), SlimefunItems.MAGIC_LUMP_2, new ItemStack(Material.BONE_MEAL), SlimefunItems.MAGIC_LUMP_2, new ItemStack(Material.NETHER_WART), new ItemStack(Material.BLAZE_POWDER), new ItemStack(Material.NETHER_WART)}, - new CustomItem(SlimefunItems.INFERNAL_BONEMEAL, 8)) + new SlimefunItemStack(SlimefunItems.INFERNAL_BONEMEAL, 8)) .register(plugin); new SlimefunItem(categories.magicalGadgets, SlimefunItems.ELYTRA_SCALE, RecipeType.ANCIENT_ALTAR, @@ -2494,54 +2478,54 @@ public final class SlimefunItemSetup { new RainbowBlock(categories.magicalGadgets, SlimefunItems.RAINBOW_WOOL, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL)}, - new CustomItem(SlimefunItems.RAINBOW_WOOL, 8), new RainbowTickHandler(MaterialCollections.getAllWoolColors())) + new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL, 8), new RainbowTickHandler(MaterialCollections.getAllWoolColors())) .register(plugin); new RainbowBlock(categories.magicalGadgets, SlimefunItems.RAINBOW_GLASS, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS)}, - new CustomItem(SlimefunItems.RAINBOW_GLASS, 8), new RainbowTickHandler(MaterialCollections.getAllStainedGlassColors())) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS, 8), new RainbowTickHandler(MaterialCollections.getAllStainedGlassColors())) .register(plugin); new RainbowBlock(categories.magicalGadgets, SlimefunItems.RAINBOW_GLASS_PANE, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE)}, - new CustomItem(SlimefunItems.RAINBOW_GLASS_PANE, 8), new RainbowTickHandler(MaterialCollections.getAllStainedGlassPaneColors())) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE, 8), new RainbowTickHandler(MaterialCollections.getAllStainedGlassPaneColors())) .register(plugin); new RainbowBlock(categories.magicalGadgets, SlimefunItems.RAINBOW_CLAY, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA)}, - new CustomItem(SlimefunItems.RAINBOW_CLAY, 8), new RainbowTickHandler(MaterialCollections.getAllTerracottaColors())) + new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY, 8), new RainbowTickHandler(MaterialCollections.getAllTerracottaColors())) .register(plugin); new RainbowBlock(categories.magicalGadgets, SlimefunItems.RAINBOW_CONCRETE, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE)}, - new CustomItem(SlimefunItems.RAINBOW_CONCRETE, 8), new RainbowTickHandler(MaterialCollections.getAllConcreteColors())) + new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE, 8), new RainbowTickHandler(MaterialCollections.getAllConcreteColors())) .register(plugin); new RainbowBlock(categories.magicalGadgets, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA)}, - new CustomItem(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA, 8), new RainbowTickHandler(MaterialCollections.getAllGlazedTerracottaColors())) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA, 8), new RainbowTickHandler(MaterialCollections.getAllGlazedTerracottaColors())) .register(plugin); // Christmas new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_WOOL_XMAS, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_WOOL_XMAS, 2), new RainbowTickHandler(Material.RED_WOOL, Material.GREEN_WOOL)) + new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_XMAS, 2), new RainbowTickHandler(Material.RED_WOOL, Material.GREEN_WOOL)) .register(plugin); new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_GLASS_XMAS, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_GLASS_XMAS, 2), new RainbowTickHandler(Material.RED_STAINED_GLASS, Material.GREEN_STAINED_GLASS)) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_XMAS, 2), new RainbowTickHandler(Material.RED_STAINED_GLASS, Material.GREEN_STAINED_GLASS)) .register(plugin); new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_GLASS_PANE_XMAS, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_GLASS_PANE_XMAS, 2), new RainbowTickHandler(Material.RED_STAINED_GLASS_PANE, Material.GREEN_STAINED_GLASS_PANE)) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_XMAS, 2), new RainbowTickHandler(Material.RED_STAINED_GLASS_PANE, Material.GREEN_STAINED_GLASS_PANE)) .register(plugin); new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_CLAY_XMAS, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_CLAY_XMAS, 2), new RainbowTickHandler(Material.RED_TERRACOTTA, Material.GREEN_TERRACOTTA)) + new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_XMAS, 2), new RainbowTickHandler(Material.RED_TERRACOTTA, Material.GREEN_TERRACOTTA)) .register(plugin); new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_CONCRETE_XMAS, RecipeType.ANCIENT_ALTAR, @@ -2551,76 +2535,76 @@ public final class SlimefunItemSetup { new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_XMAS, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_XMAS, 2), new RainbowTickHandler(Material.RED_GLAZED_TERRACOTTA, Material.GREEN_GLAZED_TERRACOTTA)) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_XMAS, 2), new RainbowTickHandler(Material.RED_GLAZED_TERRACOTTA, Material.GREEN_GLAZED_TERRACOTTA)) .register(plugin); // Valentines Day new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_WOOL_VALENTINE, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_WOOL_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_WOOL, Material.PINK_WOOL)) + new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_WOOL, Material.PINK_WOOL)) .register(plugin); new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_GLASS_VALENTINE, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_GLASS_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_STAINED_GLASS, Material.PINK_STAINED_GLASS)) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_STAINED_GLASS, Material.PINK_STAINED_GLASS)) .register(plugin); new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_GLASS_PANE_VALENTINE, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_GLASS_PANE_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_STAINED_GLASS_PANE, Material.PINK_STAINED_GLASS_PANE)) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_STAINED_GLASS_PANE, Material.PINK_STAINED_GLASS_PANE)) .register(plugin); new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_CLAY_VALENTINE, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_CLAY_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_TERRACOTTA, Material.PINK_TERRACOTTA)) + new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_TERRACOTTA, Material.PINK_TERRACOTTA)) .register(plugin); new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_CONCRETE_VALENTINE, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_CONCRETE_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_CONCRETE, Material.PINK_CONCRETE)) + new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_CONCRETE, Material.PINK_CONCRETE)) .register(plugin); new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_VALENTINE, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_GLAZED_TERRACOTTA, Material.PINK_GLAZED_TERRACOTTA)) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_GLAZED_TERRACOTTA, Material.PINK_GLAZED_TERRACOTTA)) .register(plugin); // Halloween new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_WOOL_HALLOWEEN, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_WOOL_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_WOOL, Material.BLACK_WOOL)) + new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_WOOL, Material.BLACK_WOOL)) .register(plugin); new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_GLASS_HALLOWEEN, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_GLASS_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_STAINED_GLASS, Material.BLACK_STAINED_GLASS)) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_STAINED_GLASS, Material.BLACK_STAINED_GLASS)) .register(plugin); new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_GLASS_PANE_HALLOWEEN, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_GLASS_PANE_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_STAINED_GLASS_PANE, Material.BLACK_STAINED_GLASS_PANE)) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_STAINED_GLASS_PANE, Material.BLACK_STAINED_GLASS_PANE)) .register(plugin); new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_CLAY_HALLOWEEN, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_CLAY_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_TERRACOTTA, Material.BLACK_TERRACOTTA)) + new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_TERRACOTTA, Material.BLACK_TERRACOTTA)) .register(plugin); new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_CONCRETE_HALLOWEEN, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_CONCRETE), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_CONCRETE_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_CONCRETE, Material.BLACK_CONCRETE)) + new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_CONCRETE, Material.BLACK_CONCRETE)) .register(plugin); new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN, RecipeType.ANCIENT_ALTAR, new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new CustomItem(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_GLAZED_TERRACOTTA, Material.BLACK_GLAZED_TERRACOTTA)) + new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_GLAZED_TERRACOTTA, Material.BLACK_GLAZED_TERRACOTTA)) .register(plugin); new WitherProofBlock(categories.technicalComponents, SlimefunItems.WITHER_PROOF_GLASS, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.LEAD_INGOT, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.LEAD_INGOT, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.HARDENED_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.LEAD_INGOT, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.LEAD_INGOT}, - new CustomItem(SlimefunItems.WITHER_PROOF_GLASS, 4)) + new SlimefunItemStack(SlimefunItems.WITHER_PROOF_GLASS, 4)) .register(plugin); new GEOScanner(categories.gps, SlimefunItems.GPS_GEO_SCANNER, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -3240,10 +3224,11 @@ public final class SlimefunItemSetup { .register(plugin); } } - - private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, SlimefunAddon addon) { + + private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, PotionEffect[][] effects, SlimefunAddon addon) { String[] components = new String[] { "_HELMET", "_CHESTPLATE", "_LEGGINGS", "_BOOTS" }; List recipes = new ArrayList<>(); + recipes.add(new ItemStack[] { baseComponent, baseComponent, baseComponent, baseComponent, null, baseComponent, null, null, null }); recipes.add(new ItemStack[] { baseComponent, null, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent }); recipes.add(new ItemStack[] { baseComponent, baseComponent, baseComponent, baseComponent, null, baseComponent, baseComponent, null, baseComponent }); @@ -3253,23 +3238,7 @@ public final class SlimefunItemSetup { if (vanilla) { new VanillaItem(category, items[i], idSyntax + components[i], RecipeType.ARMOR_FORGE, recipes.get(i)).register(addon); } - else { - new SlimefunItem(category, new SlimefunItemStack(idSyntax + components[i], items[i]), RecipeType.ARMOR_FORGE, recipes.get(i)).register(addon); - } - } - } - - private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, PotionEffect[][] effects, SlimefunAddon addon) { - String[] components = new String[] { "_HELMET", "_CHESTPLATE", "_LEGGINGS", "_BOOTS" }; - List recipes = new ArrayList<>(); - - recipes.add(new ItemStack[] { baseComponent, baseComponent, baseComponent, baseComponent, null, baseComponent, null, null, null }); - recipes.add(new ItemStack[] { baseComponent, null, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent }); - recipes.add(new ItemStack[] { baseComponent, baseComponent, baseComponent, baseComponent, null, baseComponent, baseComponent, null, baseComponent }); - recipes.add(new ItemStack[] { null, null, null, baseComponent, null, baseComponent, baseComponent, null, baseComponent }); - - for (int i = 0; i < 4; i++) { - if (i < effects.length && effects[i].length > 0) { + else if (i < effects.length && effects[i].length > 0) { new SlimefunArmorPiece(category, new SlimefunItemStack(idSyntax + components[i], items[i]), RecipeType.ARMOR_FORGE, recipes.get(i), effects[i]).register(addon); } else {