@@ -24,6 +24,7 @@ import gg.skytils.skytilsmod.Skytils.Companion.mc
2424import gg.skytils.skytilsmod.core.SoundQueue
2525import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent
2626import gg.skytils.skytilsmod.events.impl.PacketEvent
27+ import gg.skytils.skytilsmod.features.impl.events.GriffinBurrows.BurrowEstimation.otherGrassData
2728import gg.skytils.skytilsmod.utils.*
2829import net.minecraft.client.renderer.GlStateManager
2930import net.minecraft.entity.item.EntityArmorStand
@@ -70,6 +71,10 @@ object GriffinBurrows {
7071 this ::class .java.getResource(" /assets/skytils/grassdata.txt" )!! .readBytes()
7172 }
7273
74+ val otherGrassData by lazy {
75+ this ::class .java.getResource(" /assets/skytils/hub_grass_heights.bin" )!! .readBytes()
76+ }
77+
7378 class Arrow (val directionVector : Vec3 , val pos : Vec3 )
7479 }
7580
@@ -131,18 +136,13 @@ object GriffinBurrows {
131136 }
132137 } " )
133138
134- var y: Int
135- var x = guessPos.x.toInt()
136- var z = guessPos.z.toInt()
137139 // offset of 300 blocks for both x and z
138140 // x ranges from 195 to -281
139141 // z ranges from 207 to -233
140142
141- // TODO: this y thing is wrong and puts them in the air sometimes
142- do {
143- y = BurrowEstimation .grassData.getOrNull((x++ % 507 ) * 507 + (z++ % 495 ))?.toInt() ? : 0
144- } while (y < 2 )
145- val guess = BurrowGuess (guessPos.x.toInt(), y, guessPos.z.toInt())
143+ fun getIndex (x : Int , z : Int ) = (x - - 281 ) + (z - - 233 ) * (195 - - 281 + 1 )
144+
145+ val guess = BurrowGuess (guessPos.x.toInt(), otherGrassData.getOrNull(getIndex(guessPos.x.toInt(), guessPos.z.toInt()))?.toInt() ? : 0 , guessPos.z.toInt())
146146 BurrowEstimation .guesses[guess] = Instant .now()
147147
148148 BurrowEstimation .lastTrail.clear()
@@ -264,14 +264,10 @@ object GriffinBurrows {
264264 val pos = BlockPos (x, y, z).down()
265265 if (recentlyDugParticleBurrows.contains(pos)) return
266266 BurrowEstimation .guesses.keys.associateWith { guess ->
267- pos.distanceSq(
268- guess.x.toDouble(),
269- guess.y.toDouble(),
270- guess.z.toDouble()
271- )
267+ (pos.x - guess.x) * (pos.x - guess.x) + (pos.z - guess.z) * (pos.z - guess.z)
272268 }.minByOrNull { it.value }?.let { (guess, distance) ->
273269 // printDevMessage("Nearest guess is $distance blocks^2 away", "griffin", "griffinguess")
274- if (distance <= 625 ) {
270+ if (distance <= 25 * 25 ) {
275271 BurrowEstimation .guesses.remove(guess)
276272 }
277273 }
0 commit comments