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

Refactored talisman grabbing method

This commit is contained in:
TheBusyBiscuit 2020-10-30 23:03:44 +01:00 committed by GitHub
parent 6f39ef5b41
commit e953eb1c81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -180,14 +180,14 @@ public class Talisman extends SlimefunItem {
return null; return null;
} }
ItemStack possibleTalisman = retrieveTalismanFromInventory(p.getInventory(), talisman); ItemStack possibleTalisman = retrieveTalismanFromInventory(p.getInventory(), talisman.getItem());
if (possibleTalisman != null && Slimefun.hasUnlocked(p, talisman, true)) { if (possibleTalisman != null && Slimefun.hasUnlocked(p, talisman, true)) {
activateTalisman(e, p, p.getInventory(), talisman, possibleTalisman); activateTalisman(e, p, p.getInventory(), talisman, possibleTalisman);
return possibleTalisman; return possibleTalisman;
} }
possibleTalisman = retrieveTalismanFromInventory(p.getEnderChest(), talisman); possibleTalisman = retrieveTalismanFromInventory(p.getEnderChest(), talisman.getEnderVariant());
if (possibleTalisman != null && Slimefun.hasUnlocked(p, talisman, true)) { if (possibleTalisman != null && Slimefun.hasUnlocked(p, talisman, true)) {
activateTalisman(e, p, p.getEnderChest(), talisman, possibleTalisman); activateTalisman(e, p, p.getEnderChest(), talisman, possibleTalisman);
@ -198,13 +198,9 @@ public class Talisman extends SlimefunItem {
} }
@Nullable @Nullable
private static ItemStack retrieveTalismanFromInventory(@Nonnull Inventory inv, @Nonnull Talisman talisman) { private static ItemStack retrieveTalismanFromInventory(@Nonnull Inventory inv, @Nonnull ItemStack talismanItem) {
ItemStack[] contents = inv.getContents(); for (ItemStack item : inv) {
if (SlimefunUtils.isItemSimilar(item, talismanItem, false, false) {
for (int i = 0; i < contents.length; i++) {
ItemStack item = contents[i];
if (talisman.isItem(item)) {
return item; return item;
} }
} }