Skip to content

Commit

Permalink
feat(Catlas): More optimized core scanning
Browse files Browse the repository at this point in the history
Harry282/FunnyMap@44a1958

Co-authored-by: Harry282 <48564154+Harry282@users.noreply.github.com>
  • Loading branch information
My-Name-Is-Jeff and Harry282 committed Feb 11, 2025
1 parent 1225f52 commit 8169842
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,25 @@ object ScanUtils {

fun getCore(x: Int, z: Int): Int {
val sb = StringBuilder(150)
val chunk = mc.theWorld.getChunkFromBlockCoords(BlockPos(x, 0, z))
for (y in 140 downTo 12) {
val id = Block.blockRegistry.getIDForObject(chunk.getBlock(BlockPos(x, y, z)))
if (!Utils.equalsOneOf(id, 5, 54, 146)) {
sb.append(id)
val chunk = mc.theWorld.getChunkFromChunkCoords(x shr 4, z shr 4)
val height = chunk.getHeightValue(x and 15, z and 15).coerceIn(11..140)
sb.append(CharArray(140 - height) { '0' })
var bedrock = 0
for (y in height downTo 12) {
val id = Block.getIdFromBlock(chunk.getBlock(BlockPos(x, y, z)))
if (id == 0 && bedrock >= 2 && y < 69) {
sb.append(CharArray(y - 11) { '0' })
break
}

if (id == 7) {
bedrock++
} else {
bedrock = 0
if (!Utils.equalsOneOf(id, 5, 54, 146)) continue
}

sb.append(id)
}
return sb.toString().hashCode()
}
Expand Down

0 comments on commit 8169842

Please sign in to comment.