1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

[CI skip] Merge pull request #3479 from FN-FAL113/fix/pedestal-bug

Fix pedestal item disappearing (fixes #3476)
This commit is contained in:
TheBusyBiscuit 2022-03-10 20:51:57 +01:00 committed by GitHub
commit c88b43717c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
@ -115,7 +116,7 @@ public class AncientAltarListener implements Listener {
return;
}
// Make altarinuse simply because that was the last block clicked.
// Make altar in use simply because that was the last block clicked.
altarsInUse.add(b.getLocation());
e.cancel();
@ -156,8 +157,18 @@ public class AncientAltarListener implements Listener {
Slimefun.runSync(() -> removedItems.remove(uuid), 30L);
entity.remove();
p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity));
p.playSound(pedestal.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1F, 1F);
/*
* Fixes #3476
* Drop the item instead if the player's inventory is full and
* no stack space left else add remaining items from the returned map value
*/
Map<Integer,ItemStack> remainingItemMap = p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity));
for (ItemStack item : remainingItemMap.values()) {
p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), item.clone());
}
}
}