From 3c3dd48e9bd34e6aa3715720d650a0de798ad7ad Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 18 Jun 2020 21:15:47 +0200 Subject: [PATCH] Fixes #2005 --- CHANGELOG.md | 4 +++ .../core/networks/cargo/CargoUtils.java | 29 ++++++++++++++++++- .../core/services/MinecraftRecipeService.java | 12 ++++++++ .../implementation/items/androids/Script.java | 6 ++-- .../items/blocks/RepairedSpawner.java | 4 ++- .../items/multiblocks/package-info.java | 2 +- 6 files changed, 52 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a118b3245..c8d87d7cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ **Table of contents** +- [Release Candidate 14 (TBD)](#release-candidate-14-tbd) - [Release Candidate 13 (16 Jun 2020)](#release-candidate-13-16-jun-2020) - [Release Candidate 12 (27 May 2020)](#release-candidate-12-27-may-2020) - [Release Candidate 11 (25 Apr 2020)](#release-candidate-11-25-apr-2020) @@ -23,6 +24,9 @@ #### Changes * Coolant Cells now last twice as long +#### Fixes +* Fixed #2005 + ## Release Candidate 13 (16 Jun 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#13 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java index 1a233182a..8d9801f69 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.logging.Level; import org.bukkit.Material; +import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.inventory.BrewerInventory; @@ -254,8 +255,12 @@ final class CargoUtils { if (inv instanceof FurnaceInventory) { // Check if it is fuel or not if (stack.getType().isFuel()) { - minSlot = 1; maxSlot = 2; + + // Any non-smeltable items should not land in the upper slot + if (!isSmeltable(stack, true)) { + minSlot = 1; + } } else { maxSlot = 1; @@ -313,6 +318,28 @@ final class CargoUtils { return stack; } + /** + * This method checks if a given {@link ItemStack} is smeltable or not. + * The lazy-option is a performance-saver since actually calculating this can be quite expensive. + * For the current applicational purposes a quick check for any wooden logs is sufficient. + * Otherwise the "lazyness" can be turned off in the future. + * + * @param stack + * The {@link ItemStack} to test + * @param lazy + * Whether or not to perform a "lazy" but performance-saving check + * + * @return Whether the given {@link ItemStack} can be smelted or not + */ + private static boolean isSmeltable(ItemStack stack, boolean lazy) { + if (lazy) { + return stack != null && Tag.LOGS.isTagged(stack.getType()); + } + else { + return SlimefunPlugin.getMinecraftRecipes().isSmeltable(stack); + } + } + static DirtyChestMenu getChestMenu(Block block) { if (BlockStorage.hasInventory(block)) { return BlockStorage.getInventory(block); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java index c8e84ce60..32bea1e6c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java @@ -90,6 +90,18 @@ public class MinecraftRecipeService { return snapshot.getRecipeOutput(MinecraftRecipe.FURNACE, input); } + /** + * This returns whether a given {@link ItemStack} can be smelted in a {@link FurnaceRecipe}. + * + * @param input + * The {@link ItemStack} to test + * + * @return Whether this item can be smelted + */ + public boolean isSmeltable(ItemStack input) { + return getFurnaceOutput(input).isPresent(); + } + /** * This returns the shape of a given {@link Recipe}. * For any shapeless {@link Recipe} the result will be equivalent to diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java index b7093dc7a..bd80e3ec2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java @@ -83,10 +83,12 @@ public final class Script { /** * This method checks whether a given {@link Player} is able to leave a rating for this {@link Script}. - * + * A {@link Player} is unable to rate his own {@link Script} or a {@link Script} he already rated before. * * @param p - * @return + * The {@link Player} to check for + * + * @return Whether the given {@link Player} is able to rate this {@link Script} */ public boolean canRate(Player p) { if (isAuthor(p)) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java index fb20146c8..3af6687a6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java @@ -48,7 +48,9 @@ public class RepairedSpawner extends SimpleSlimefunItem { * The provided {@link ItemStack} must be a {@link RepairedSpawner} item. * * @param item - * @return + * The {@link ItemStack} to extract the {@link EntityType} from + * + * @return An {@link Optional} describing the result */ public Optional getEntityType(ItemStack item) { for (String line : item.getItemMeta().getLore()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/package-info.java index 0b9f157f9..27d269c53 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/package-info.java @@ -1,5 +1,5 @@ /** * This package contains all the different implementations of - * {@link me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.MultiBlockMachine} + * {@link io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine} */ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; \ No newline at end of file