diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b77fa83a..0ec701cbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ * Fixed #1985 * Fixed a missing texture in the Android Script Editor * Fixed #1992 +* Possibly fixed #1951 ## Release Candidate 12 (27 May 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#12 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java index 18eec6da5..0d24f71e6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java @@ -1,8 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.LinkedList; import java.util.List; import org.bukkit.Material; @@ -56,12 +56,20 @@ public abstract class ElectricSmeltery extends AContainer { @Override public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportFlow flow, ItemStack item) { - if (flow == ItemTransportFlow.WITHDRAW) return getOutputSlots(); + if (flow == ItemTransportFlow.WITHDRAW) { + return getOutputSlots(); + } - List slots = new ArrayList<>(); + int fullSlots = 0; + List slots = new LinkedList<>(); for (int slot : getInputSlots()) { - if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), item, true)) { + ItemStack stack = menu.getItemInSlot(slot); + if (stack != null && SlimefunUtils.isItemSimilar(stack, item, true)) { + if (stack.getAmount() < stack.getMaxStackSize()) { + fullSlots++; + } + slots.add(slot); } } @@ -69,6 +77,10 @@ public abstract class ElectricSmeltery extends AContainer { if (slots.isEmpty()) { return getInputSlots(); } + else if (fullSlots == slots.size()) { + // All slots with that item are already full + return new int[0]; + } else { Collections.sort(slots, compareSlots(menu)); int[] array = new int[slots.size()];