diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-15 12:12:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 12:12:10 +0200 |
commit | 63d3eba33cb5de8ada4a78d52d245a3d1494ca64 (patch) | |
tree | c5391a47cd0aae34308e7481246a04e691dbcc24 /src/main/java/at/hannibal2 | |
parent | f670fb96f9709f5249c1606ca77fcdf816c71058 (diff) | |
download | skyhanni-63d3eba33cb5de8ada4a78d52d245a3d1494ca64.tar.gz skyhanni-63d3eba33cb5de8ada4a78d52d245a3d1494ca64.tar.bz2 skyhanni-63d3eba33cb5de8ada4a78d52d245a3d1494ca64.zip |
Fix: Griffin Spots (#1797)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt | 4 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt | 104 |
2 files changed, 91 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index a914e0c59..bd8604a40 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -425,6 +425,10 @@ object Commands { "shtestsackapi", "Get the amount of an item in sacks according to internal feature SackAPI" ) { SackAPI.testSackAPI(it) } + registerCommand( + "shtestgriffinspots", + "Show potential griffin spots around you." + ) { GriffinBurrowHelper.testGriffinSpots() } } private fun developersCodingHelp() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt index 7fd5cde54..29936f586 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt +import at.hannibal2.skyhanni.utils.BlockUtils.isInLoadedChunk import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.DelayedRun @@ -35,6 +36,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.client.Minecraft import net.minecraft.init.Blocks import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -45,12 +47,27 @@ object GriffinBurrowHelper { private val config get() = SkyHanniMod.feature.event.diana + private val allowedBlocksAboveGround = + listOf( + Blocks.air, + Blocks.leaves, + Blocks.leaves2, + Blocks.tallgrass, + Blocks.double_plant, + Blocks.red_flower, + Blocks.yellow_flower, + Blocks.spruce_fence + ) + var targetLocation: LorenzVec? = null private var guessLocation: LorenzVec? = null private var particleBurrows = mapOf<LorenzVec, BurrowType>() var lastTitleSentTime = SimpleTimeMark.farPast() private var shouldFocusOnInquis = false + private var testList = listOf<LorenzVec>() + private var testGriffinSpots = false + @SubscribeEvent fun onDebugDataCollect(event: DebugDataCollectEvent) { event.title("Griffin Burrow Helper") @@ -76,6 +93,26 @@ object GriffinBurrowHelper { if (!event.repeatSeconds(1)) return update() + + loadTestGriffinSpots() + } + + fun testGriffinSpots() { + testGriffinSpots = !testGriffinSpots + val state = if (testGriffinSpots) "§aenabled" else "§cdisabled" + ChatUtils.chat("Test Griffin Spots $state§e.") + } + + private fun loadTestGriffinSpots() { + if (!testGriffinSpots) return + val center = LocationUtils.playerLocation().toBlockPos().toLorenzVec() + val list = mutableListOf<LorenzVec>() + for (x in -5 until 5) { + for (z in -5 until 5) { + list.add(findBlock(center.add(x, 0, z))) + } + } + testList = list } fun update() { @@ -175,31 +212,57 @@ object GriffinBurrowHelper { } private fun findBlock(point: LorenzVec): LorenzVec { - var gY = 131.0 - - var searchGrass = true - while ((if (searchGrass) LorenzVec(point.x, gY, point.z).getBlockAt() != Blocks.grass else LorenzVec( - point.x, - gY, - point.z - ).getBlockAt() == Blocks.air) - ) { + if (!point.isInLoadedChunk()) { + return point.copy(y = LocationUtils.playerLocation().y) + } + findGround(point)?.let { + return it + } + + return findBlockBelowAir(point) + } + + private fun findGround(point: LorenzVec): LorenzVec? { + fun isValidGround(y: Double): Boolean { + val isGround = point.copy(y = y).getBlockAt() == Blocks.grass + val isValidBlockAbove = point.copy(y = y + 1).getBlockAt() in allowedBlocksAboveGround + return isGround && isValidBlockAbove + } + + var gY = 140.0 + while (!isValidGround(gY)) { gY-- - if (gY < 70) { - if (!searchGrass) { - break - } else { - searchGrass = false - gY = 131.0 - } + if (gY < 65) { + // no ground detected, find lowest block below air + return null + } + } + return point.copy(y = gY) + } + + private fun findBlockBelowAir(point: LorenzVec): LorenzVec { + val start = 65.0 + var gY = start + while (point.copy(y = gY).getBlockAt() != Blocks.air) { + gY++ + if (gY > 140) { + // no blocks at this spot, assuming outside of island + return point.copy(y = LocationUtils.playerLocation().y) } } - return LorenzVec(point.x, gY, point.z) + + if (gY == start) { + return point.copy(y = LocationUtils.playerLocation().y) + } + return point.copy(y = gY - 1) } @SubscribeEvent fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return + + showTestLocations(event) + showWarpSuggestions() val playerLocation = LocationUtils.playerLocation() @@ -279,6 +342,13 @@ object GriffinBurrowHelper { } } + private fun showTestLocations(event: LorenzRenderWorldEvent) { + if (!testGriffinSpots) return + for (location in testList) { + event.drawColor(location, LorenzColor.WHITE) + } + } + @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(2, "diana", "event.diana") |