diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-24 19:47:08 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-24 19:47:08 +0100 |
commit | eb7f8ac4b8ddcb420e6e63cfda9d8db9941d1bf5 (patch) | |
tree | 3589b8f9826060925dd877be8294c4d411464a65 /src/main/java | |
parent | 1ebc88de808bcfa107f640cc2ea9e3cd17b5cedf (diff) | |
download | skyhanni-eb7f8ac4b8ddcb420e6e63cfda9d8db9941d1bf5.tar.gz skyhanni-eb7f8ac4b8ddcb420e6e63cfda9d8db9941d1bf5.tar.bz2 skyhanni-eb7f8ac4b8ddcb420e6e63cfda9d8db9941d1bf5.zip |
Using neu's isVanilla method.
Diffstat (limited to 'src/main/java')
5 files changed, 12 insertions, 56 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/VanillaItemManager.kt b/src/main/java/at/hannibal2/skyhanni/data/VanillaItemManager.kt deleted file mode 100644 index f2bcd51ca..000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/VanillaItemManager.kt +++ /dev/null @@ -1,51 +0,0 @@ -package at.hannibal2.skyhanni.data - -import com.google.gson.GsonBuilder -import com.google.gson.JsonObject -import java.io.BufferedReader -import java.io.File -import java.io.FileInputStream -import java.io.InputStreamReader -import java.nio.charset.StandardCharsets - -object VanillaItemManager { - private val gson = GsonBuilder().setPrettyPrinting().create() - - private val vanillaItems: MutableList<String> = ArrayList() - - fun isVanillaItem(internalName: String): Boolean { - return vanillaItems.contains(internalName) - } - - init { - load() - } - - private fun load() { - vanillaItems.clear() - val itemDirectory = File("config/notenoughupdates/repo/items") - if (!itemDirectory.isDirectory) return - val files = itemDirectory.listFiles() ?: return - for (file in files) { - val jsonObject = getJsonFromFile(file) - if (jsonObject != null) { - if (jsonObject.has("vanilla") && jsonObject["vanilla"].asBoolean) { - val name = file.name - val internalName = name.split(".")[0] - vanillaItems.add(internalName) - } - } - } - - } - - private fun getJsonFromFile(file: File): JsonObject? { - try { - BufferedReader( - InputStreamReader(FileInputStream(file), StandardCharsets.UTF_8) - ).use { reader -> return gson.fromJson(reader, JsonObject::class.java) } - } catch (e: Exception) { - return null - } - } -}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index 7afe83e2b..66cf289b7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -3,15 +3,15 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.borderLine -import at.hannibal2.skyhanni.data.VanillaItemManager import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.ItemUtils.cleanName -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted +import at.hannibal2.skyhanni.utils.ItemUtils.isVanilla import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.gson.JsonObject import net.minecraft.client.Minecraft @@ -330,8 +330,7 @@ class HideNotClickableItems { if (hideNpcSellFilter.match(name)) return false - val id = stack.getInternalName() - if (VanillaItemManager.isVanillaItem(id) && !stack.isItemEnchanted) { + if (stack.isVanilla() && !stack.isEnchanted()) { return false } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt index bd13a60fe..5161005a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.test.command import at.hannibal2.skyhanni.utils.EntityUtils.getSkinTexture import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture +import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -117,7 +118,7 @@ object CopyNearbyEntitiesCommand { val stackName = stack.name val stackDisplayName = stack.displayName val cleanName = stack.cleanName() - val itemEnchanted = stack.isItemEnchanted + val itemEnchanted = stack.isEnchanted() val itemDamage = stack.itemDamage val stackSize = stack.stackSize val maxStackSize = stack.maxStackSize diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 62546ee81..c22a72971 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -115,6 +115,10 @@ object ItemUtils { fun ItemStack.getInternalName() = NEUItems.getInternalName(this) + fun ItemStack.isVanilla() = NEUItems.isVanillaItem(this) + + fun ItemStack.isEnchanted() = isItemEnchanted + fun ItemStack.getSkullTexture(): String? { if (item != Items.skull) return null if (tagCompound == null) return null diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index dec6964e2..d22a82759 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import io.github.moulberry.notenoughupdates.NEUManager import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery @@ -39,6 +40,8 @@ object NEUItems { return itemStack.copy() } + fun isVanillaItem(item: ItemStack) = manager.auctionManager.isVanillaItem(item.getInternalName()) + fun ItemStack.renderOnScreen(x: Float, y: Float) { GlStateManager.pushMatrix() val isSkull = item === Items.skull |