diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt | 1 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt index 57b727791..8a8088c34 100644 --- a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt @@ -121,6 +121,7 @@ class HideNotClickableItems { val stack = event.itemStack if (ItemUtils.getItemsInOpenChest().contains(stack)) return + if (!ItemUtils.getItemsInInventory().contains(stack)) return if (hide(chestName, stack)) { val first = event.toolTip[0] diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index d97148242..8a822d7b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -7,6 +7,7 @@ import com.google.gson.JsonObject import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.item.ItemStack +import java.util.LinkedList object ItemUtils { @@ -54,6 +55,30 @@ object ItemUtils { fun maxPetLevel(name: String) = if (name.contains("Golden Dragon")) 200 else 100 + fun getItemsInInventory(withCursorItem: Boolean = false): List<ItemStack> { + val list: LinkedList<ItemStack> = LinkedList() + val player = Minecraft.getMinecraft().thePlayer + if (player == null) { + LorenzUtils.warning("getItemsInInventoryWithSlots: player is null!") + return list + } + for (slot in player.openContainer.inventorySlots) { + if (slot.hasStack) { + list.add(slot.stack) + } + } + + if (withCursorItem) { + if (player.inventory != null) { + if (player.inventory.itemStack != null) { + list.add(player.inventory.itemStack) + } + } + } + + return list + } + fun getItemsInInventoryWithSlots(withCursorItem: Boolean = false): Map<ItemStack, Int> { val map: LinkedHashMap<ItemStack, Int> = LinkedHashMap() val player = Minecraft.getMinecraft().thePlayer |