Skip to content

Commit

Permalink
fix: wait for locraw before computing visible waypoints
Browse files Browse the repository at this point in the history
fixes #358

adds a new LocrawReceievedEvent
  • Loading branch information
My-Name-Is-Jeff committed Mar 24, 2023
1 parent 1cd3f84 commit 53e1c74
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Skytils - Hypixel Skyblock Quality of Life Mod
* Copyright (C) 2020-2023 Skytils
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package gg.skytils.skytilsmod.events.impl

import gg.skytils.skytilsmod.events.SkytilsEvent
import gg.skytils.skytilsmod.utils.LocrawObject

data class LocrawReceivedEvent(val loc: LocrawObject) : SkytilsEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import gg.essential.universal.UMatrixStack
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.core.PersistentSave
import gg.skytils.skytilsmod.core.TickTask
import gg.skytils.skytilsmod.events.impl.LocrawReceivedEvent
import gg.skytils.skytilsmod.utils.*
import kotlinx.serialization.*
import kotlinx.serialization.json.*
Expand Down Expand Up @@ -134,6 +135,10 @@ object Waypoints : PersistentSave(File(Skytils.modDir, "waypoints.json")) {
@SubscribeEvent
fun onWorldChange(event: WorldEvent.Load) {
visibleWaypoints = emptyList()
}

@SubscribeEvent
fun onLocraw(event: LocrawReceivedEvent) {
TickTask(20, ::computeVisibleWaypoints)
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/gg/skytils/skytilsmod/utils/SBInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package gg.skytils.skytilsmod.utils
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.Skytils.Companion.json
import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.events.impl.LocrawReceivedEvent
import gg.skytils.skytilsmod.events.impl.PacketEvent
import gg.skytils.skytilsmod.events.impl.SendChatMessageEvent
import kotlinx.serialization.KSerializer
Expand Down Expand Up @@ -110,6 +111,7 @@ object SBInfo {
}
locraw = obj
mode = obj.mode
LocrawReceivedEvent(obj).postAndCatch()
} catch (e: SerializationException) {
e.printStackTrace()
}
Expand Down

0 comments on commit 53e1c74

Please sign in to comment.