From bf860a73e1206a132f446f23915f0ca0e3bbf615 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 10 May 2023 10:25:03 +0200 Subject: Npc prices will be loaded not during startup but once minecraft is fully loaded, to fix a bug with unloaded neu data --- .../at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index ef8a812e0..85267240e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -9,8 +9,10 @@ import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent class BazaarApi { + private var loadedNpcPriceData = false companion object { val holder = BazaarDataHolder() @@ -37,6 +39,17 @@ class BazaarApi { inBazaarInventory = checkIfInBazaar(event) } + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (event.phase != TickEvent.Phase.START) return + + if (!loadedNpcPriceData) { + loadedNpcPriceData = true + holder.start() + } + } + private fun checkIfInBazaar(event: InventoryOpenEvent): Boolean { val returnItem = event.inventorySize - 5 for ((slot, item) in event.inventoryItems) { @@ -68,8 +81,4 @@ class BazaarApi { fun onInventoryClose(event: InventoryCloseEvent) { inBazaarInventory = false } - - init { - holder.start() - } } \ No newline at end of file -- cgit