1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2020-05-21 18:51:53 +02:00
parent 04a7435f2b
commit 69d32bd6f2
2 changed files with 15 additions and 3 deletions

View File

@ -52,6 +52,7 @@
* Fixed some very weird SkullMeta serialization problems in 1.15 * Fixed some very weird SkullMeta serialization problems in 1.15
* Fixed #1914 * Fixed #1914
* Fixed file errors with PerWorldSettingsService * Fixed file errors with PerWorldSettingsService
* Fixed ChestTerminals deleting items from Cargo networks (TheBusyBiscuit/ChestTerminal#25)
## Release Candidate 11 (25 Apr 2020) ## Release Candidate 11 (25 Apr 2020)

View File

@ -29,6 +29,15 @@ final class CargoUtils {
private CargoUtils() {} private CargoUtils() {}
/**
* This is a performance-saving shortcut to quickly test whether a given
* {@link Block} might be an {@link InventoryHolder} or not.
*
* @param block
* The {@link Block} to check
*
* @return Whether this {@link Block} represents a {@link BlockState} that is an {@link InventoryHolder}
*/
static boolean hasInventory(Block block) { static boolean hasInventory(Block block) {
if (block == null) { if (block == null) {
return false; return false;
@ -79,6 +88,7 @@ final class CargoUtils {
return withdrawFromVanillaInventory(node, template, ((InventoryHolder) state).getInventory()); return withdrawFromVanillaInventory(node, template, ((InventoryHolder) state).getInventory());
} }
} }
return null; return null;
} }
@ -90,7 +100,7 @@ final class CargoUtils {
if (SlimefunUtils.isItemSimilar(is, wrapper, true) && matchesFilter(node, is, -1)) { if (SlimefunUtils.isItemSimilar(is, wrapper, true) && matchesFilter(node, is, -1)) {
if (is.getAmount() > template.getAmount()) { if (is.getAmount() > template.getAmount()) {
is.setAmount(is.getAmount() - template.getAmount()); is.setAmount(is.getAmount() - template.getAmount());
menu.replaceExistingItem(slot, is); menu.replaceExistingItem(slot, is.clone());
return template; return template;
} }
else { else {
@ -128,8 +138,9 @@ final class CargoUtils {
return template; return template;
} }
else { else {
itemInSlot.setAmount(itemInSlot.getAmount() - template.getAmount()); ItemStack clone = itemInSlot.clone();
return itemInSlot; itemInSlot.setAmount(0);
return clone;
} }
} }
} }