From 0454b6420983dc37ff6c333adde1ce4aa6c36824 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 17 Feb 2023 01:37:53 +0100 Subject: Code cleanup. --- .../features/garden/GardenVisitorFeatures.kt | 29 +++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 513c91425..d2b860908 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -58,11 +58,11 @@ class GardenVisitorFeatures { if (line.isEmpty()) break val matcher = pattern.matcher(line) - if (matcher.matches()) { - val itemName = matcher.group(1).trim() - val amount = matcher.group(2).toInt() - visitor.items[itemName] = amount - } + if (!matcher.matches()) continue + + val itemName = matcher.group(1).trim() + val amount = matcher.group(2).toInt() + visitor.items[itemName] = amount } val visitorName = npcItem.name!! @@ -141,13 +141,8 @@ class GardenVisitorFeatures { !SkyHanniMod.feature.garden.visitorHelperHighlightReady && !SkyHanniMod.feature.garden.visitorHelperShowPrice ) return + if (tick++ % 60 != 0) return - if (tick++ % 60 == 0) { - check() - } - } - - private fun check() { nearby = LocationUtils.playerLocation().distance(LorenzVec(8.4, 72.0, -14.1)) < 10 if (nearby && SkyHanniMod.feature.garden.visitorHelperHighlightReady) { @@ -196,13 +191,13 @@ class GardenVisitorFeatures { @SubscribeEvent fun onSendEvent(event: PacketEvent.SendEvent) { val packet = event.packet - if (packet is C02PacketUseEntity) { - val theWorld = Minecraft.getMinecraft().theWorld - val entity = packet.getEntityFromWorld(theWorld) - val entityId = entity.entityId + if (packet !is C02PacketUseEntity) return - lastClickedNpc = entityId - } + val theWorld = Minecraft.getMinecraft().theWorld + val entity = packet.getEntityFromWorld(theWorld) + val entityId = entity.entityId + + lastClickedNpc = entityId } @SubscribeEvent -- cgit