diff options
author | dragon99z <dragon99@online.de> | 2023-07-24 15:35:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-24 15:35:36 +0200 |
commit | a2a4a8e3662a412121ee5802706f64f8433d7b24 (patch) | |
tree | 5c77e49fd06335d362e2a4adc4885c6ac330ba25 /src/main/java/at/hannibal2/skyhanni | |
parent | be556926ed942c826389acf38add01c1486a9e08 (diff) | |
download | skyhanni-a2a4a8e3662a412121ee5802706f64f8433d7b24.tar.gz skyhanni-a2a4a8e3662a412121ee5802706f64f8433d7b24.tar.bz2 skyhanni-a2a4a8e3662a412121ee5802706f64f8433d7b24.zip |
Merge pull request #330
* +added Eman slayer beacon highlight and beacon beam
* +added Eman slayer beacon warning toggle
* Merge remote-tracking branch 'origin/beta' into beta
* +added Patcher sendcoords like command
* formatting (Strg + Alt + L in IntelliJ)
* using regex to grab coordinates from chat
* Merge branch 'hannibal002:beta' into beta
* Merge remote-tracking branch 'origin/beta' into beta
* +Added a PatcherBeacon class to store the location,name and creation …
* Formatting
* using "for iterator" instead of index, using "removeIf" and removed l…
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 26 insertions, 29 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java index a630f3c7f..b40821da0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java @@ -661,9 +661,9 @@ public class MiscConfig { public boolean restorePieceOfWizardPortalLore = true; @Expose - @ConfigOption(name = "Patcher Coords Highlight", desc = "Highlight the the coords sended form patcher.") + @ConfigOption(name = "Patcher Coords Waypoint", desc = "Highlight the the coords sended form patcher.") @ConfigEditorBoolean - public boolean patcherSendCoordHighlight = false; + public boolean patcherSendCoordWaypoint = false; @Expose @ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.") diff --git a/src/main/java/at/hannibal2/skyhanni/data/PatcherCoordinatesClass.kt b/src/main/java/at/hannibal2/skyhanni/data/PatcherCoordinatesClass.kt new file mode 100644 index 000000000..d90600df8 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/PatcherCoordinatesClass.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.utils.LorenzVec + +data class PatcherBeacon(val location: LorenzVec, val name: String, val time: Long)
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinatesHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinatesHighlight.kt index b9ac03626..5e82e51f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinatesHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinatesHighlight.kt @@ -1,8 +1,11 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.PatcherBeacon import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzVec @@ -10,23 +13,21 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawColor import at.hannibal2.skyhanni.utils.RenderUtils.drawString import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class PatcherSendCoordinatesHighlight { - private val patcherBeacon = mutableListOf<LorenzVec>() - private val patcherName = mutableListOf<String>() + private val patcherBeacon = mutableListOf<PatcherBeacon>() private val logger = LorenzLogger("misc/patchercoords") private val pattern = "(?<playerName>.*): x: (?<x>.*), y: (?<y>.*), z: (?<z>.*)".toPattern() + @SubscribeEvent fun onPatcherCoordinates(event: LorenzChatEvent) { - if (!SkyHanniMod.feature.misc.patcherSendCoordHighlight) return + if (!SkyHanniMod.feature.misc.patcherSendCoordWaypoint) return val message = event.message.removeColor() pattern.matchMatcher(message) { @@ -34,47 +35,38 @@ class PatcherSendCoordinatesHighlight { val x = group("x").toInt() val y = group("y").toInt() val z = group("z").toInt() - - patcherBeacon.add(LorenzVec(x, y, z)) - patcherName.add(playerName) + patcherBeacon.add(PatcherBeacon(LorenzVec(x, y, z), playerName, System.currentTimeMillis() / 1000)) logger.log("got patcher coords and username") } } @SubscribeEvent(priority = EventPriority.HIGH) fun onWorldRender(event: RenderWorldLastEvent) { - if (!SkyHanniMod.feature.misc.patcherSendCoordHighlight) return + if (!SkyHanniMod.feature.misc.patcherSendCoordWaypoint) return - for (i in 0 until patcherBeacon.size) { - val location = patcherBeacon[i] + for (beacon in patcherBeacon) { + val location = beacon.location event.drawColor(location, LorenzColor.DARK_GREEN, alpha = 1f) event.drawWaypointFilled(location, LorenzColor.GREEN.toColor(), true, true) - event.drawString(location.add(0.5, 0.5, 0.5), patcherName[i], true, LorenzColor.DARK_BLUE.toColor()) - logger.log("added patcher beacon!") + event.drawString(location.add(0.5, 0.5, 0.5), beacon.name, true, LorenzColor.DARK_BLUE.toColor()) } } @SubscribeEvent - fun onEnterWaypoint(event: TickEvent.PlayerTickEvent) { - if (!SkyHanniMod.feature.misc.patcherSendCoordHighlight) return + fun onEnterWaypoint(event: LorenzTickEvent) { + if (!event.isMod(10)) return - val player = event.player - if (player.motionX > 0 || player.motionZ > 0) { - val location = player.getLorenzVec() - for (i in 0 until patcherBeacon.size) { - if (location.distanceIgnoreY(patcherBeacon[i]) < 5) { - patcherBeacon.removeAt(i) - patcherName.removeAt(i) - logger.log("removed patcher beacon!") - } - } - } + val location = LocationUtils.playerLocation() + // removed patcher beacon! + patcherBeacon.removeIf { System.currentTimeMillis() / 1000 > it.time + 5 && location.distanceIgnoreY(it.location) < 5 } + + // removed patcher beacon after time! + patcherBeacon.removeIf { System.currentTimeMillis() / 1000 > it.time + 60 } } @SubscribeEvent fun onWorldChange(event: WorldEvent.Load) { patcherBeacon.clear() - patcherName.clear() logger.log("Reset everything (world change)") } }
\ No newline at end of file |