Skip to content

Conversation

@emyfops
Copy link
Collaborator

@emyfops emyfops commented Apr 17, 2025

This pull requests implements a brand new dynamic class remapping that uses the existing dynamic reflection serializer
It allows reflection of obfuscated minecraft members for the packet logger module

Mappings are downloaded from our cloudflare bucket at mappings.lambda-client.org and are stored loosely in the cache folder

Before:

net.minecraft.class_2672
  field_12236: -10
  field_12235: -4
  field_34870: net.minecraft.class_6603@721373fb
    net.minecraft.class_6603
      field_34862: 2097152
      field_34863: {MOTION_BLOCKING:[L;3086490446775277226L,3122730762615747244L,3104504914273194157L,3339185846487446187L,3104540029253932717L,3519681675303147692L,3104399154733218493L,3519470292041816236L,3050427429879123655L,3411242338997591207L,3411595972921364163L,3140639401982644921L,3591915948460571321L,3140639607472093891L,3591739268801584302L,3266845471266932423L,3411242545290239149L,3086984267357324989L,3194753034973702833L,3339185846487446191L,3104504846089803442L,3339184675971488428L,3032729277053101234L,3086490446640796329L,3248902058093139627L,3050355889943694515L,3230605634851133098L,2996242119247620788L,3086490446640533671L,2960143917570156202L,3068440725916568229L,3230887659449177258L,3014256517618681506L,3050391143438701737L,2942093163902356648L,3050391143303957669L,22189789353L],WORLD_SURFACE:[L;3086490446775277227L,3122730762615747244L,3104504914273194157L,3339185846487446187L,3122554427763414701L,3519681675303147692L,3104399154733218493L,3519470292041816236L,3050427429879123655L,3411242338997591207L,3411595972921364163L,3140639401982644921L,3591915948460571321L,3140639607472093891L,3591739268801584303L,3266845471266932423L,3411242545290239149L,3086984267357324989L,3194753035108182705L,3339185846487446191L,3104504846089803442L,3339184676105706156L,3032729277053101234L,3086490446640796329L,3248902058093139627L,3050355889943694515L,3230605634851133098L,2996242119247620788L,3086490446640533671L,2960143917570156202L,3068440725916568229L,3230887659449177258L,3014256517618681506L,3050391143438701737L,2942093163902356648L,3050391143303957669L,22189789353L]}
      field_34864: [B@62e634ff
      field_34865: []
  field_34871: net.minecraft.class_6606@703b0ecd
    net.minecraft.class_6606
      field_34873: {2, 3, 4, 11, 12, 13, 14}
      field_34874: {2, 3, 4, 9, 11}
      field_34875: {0, 1, 5, 6, 7, 8, 9, 10}
      field_34876: {0, 1, 5, 6, 7, 8, 10, 12, 13, 14}
      field_34877: [[B@5ebc4893, [B@d2ece77, [B@92524f5, [B@21c01e7a, [B@1d843201, [B@66220ab0, [B@4680880d]
      field_34878: [[B@67926d69, [B@5b3a5fa0, [B@2d3ba9fd, [B@6f398cb7, [B@1bb44d1c]

After:

ChunkDataS2CPacket
  chunkX: -10
  chunkZ: -8
  chunkData: ChunkData@349c0420
    ChunkData
      MAX_SECTIONS_DATA_SIZE: 2097152
      heightmap: {MOTION_BLOCKING:[L;2797696018872349336L,2761561462444734620L,2797660766991106717L,2743582454868686491L,2942234244450431640L,2779716873588913827L,3121884685859631257L,2797696501120061101L,2761562013141382299L,2924079110605333144L,2888049830799423138L,3122730831997644960L,2941987128944969383L,3212836218723190435L,2779646918238493361L,2743547614632689824L,2779928462473126577L,2743829089607038106L,2942234246602109080L,2815745464315232416L,2942234243778031772L,2815675577414271651L,2941705447942471324L,2887979531044733603L,2815745877438445722L,2924078765392867996L,2815851223858102433L,2905993859626253983L,2815675165097411234L,2887838656116899484L,2779857886762058400L,2924078765123384474L,2887944277684468381L,2869894419118109850L,2924043374593916578L,2815675164291579554L,21382381212L],WORLD_SURFACE:[L;2797696018872349336L,2761561462444734620L,2797660766991106717L,2761596853378168475L,2942234244450431641L,2779716873723393699L,3121884685859631770L,2797696501120061101L,2761562013141382299L,2924079110605333144L,2888049830799423138L,3122730831997907104L,2941987128944969383L,3212836218723190435L,2779682102610582193L,2743547614632689824L,2779928462473126577L,2761843488116520090L,2942234246602109080L,2815745533034709152L,2942234243778032284L,2815675577414271651L,2941740632314560156L,2887979531044733603L,2815745877438445722L,2924078765392867996L,2815851223858364577L,2905993859760471711L,2815675165097411234L,2887838656116899484L,2779857886762058400L,2924078765123384986L,2887944277684468381L,2869894419118109850L,2924043374593916578L,2815745670474710690L,21382381212L]}
      sectionsData: [B@1acfdb99
      blockEntities: []
  lightData: LightData@37f330be
    LightData
      initedSky: {2, 10, 11, 12, 13}
      initedBlock: {2, 3, 4, 10}
      uninitedSky: {0, 1, 3, 4, 5, 6, 7, 8, 9}
      uninitedBlock: {0, 1, 5, 6, 7, 8, 9, 11, 12, 13}
      skyNibbles: [[B@5e55fb7b, [B@3aa2f03b, [B@37a46db0, [B@197ccd3a, [B@6803634d]
      blockNibbles: [[B@458d755e, [B@51d059b2, [B@2e3a4baf, [B@5dd05c2e]

This pull request also revamps the file utilities with a more streamlined and functional approach
Examples:

File("...")
    .downloadCompare(url = "...", 1) // Download if remote is larger than local
    
File("...")
    .downloadIfNotPresent(url = "...") { header("key", "value") } // Create the file and download the content to it; Modify the http request before posting

@emyfops emyfops requested review from Avanatiker and Copilot and removed request for Copilot April 17, 2025 19:27
@github-actions github-actions bot added triage Requires labelling or review 1.20 feature Suggests or adds a new feature labels Apr 17, 2025
@emyfops emyfops removed the triage Requires labelling or review label Apr 17, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements dynamic class remapping using existing dynamic reflection serialization while refactoring several file utilities and network endpoints to improve consistency and functionality.

  • Removed deprecated contracts and unused file utility functions from various extensions.
  • Integrated asynchronous mapping downloads with dynamic remapping support and updated endpoint documentation.
  • Updated file path handling in modules to use a new relativeMCPath extension and improved download handling in the HTTP client.

Reviewed Changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
common/src/main/kotlin/com/lambda/util/extension/Other.kt Removed experimental contracts imports.
common/src/main/kotlin/com/lambda/util/FolderRegister.kt Removed deprecated file utility functions and added a relativeMCPath extension.
common/src/main/kotlin/com/lambda/util/FileUtils.kt Introduced streamlined file download and utility functions.
common/src/main/kotlin/com/lambda/util/DynamicReflectionSerializer.kt Added dynamic remapping support using asynchronously downloaded mappings and a configurable remap flag.
common/src/main/kotlin/com/lambda/util/DynamicException.kt Implemented DynamicException to remap stack traces based on deobfuscated names.
common/src/main/kotlin/com/lambda/network/api/v1/endpoints/*.kt Updated endpoint documentation to clarify return types.
common/src/main/kotlin/com/lambda/network/LambdaHttp.kt Enhanced download functions with response status checks before writing content.
common/src/main/kotlin/com/lambda/module/modules/* Adjusted file path references from relativePath to relativeMCPath for improved file handling.
common/src/main/java/com/lambda/mixin/CrashReportMixin.java Added mixin modifications to adjust crash reporting and inject dynamic exception handling.
Files not reviewed (1)
  • common/src/main/resources/lambda.mixins.common.json: Language not supported

Comment on lines 73 to 84
private val mappings = runBlocking {
"${Network.mappings}/${Network.gameVersion}"
.downloadIfNotPresent(cache.resolveFile(Network.gameVersion))
.map { file ->
file.readLines()
.map { it.split(' ') }
.associate { it[0].split('$').last() to it[1] }
}
.getOrElse {
LOG.error("Unable to download deobfuscated qualifiers", it)
emptyMap()
}
Copy link

Copilot AI Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using runBlocking in the object initializer for mapping downloads can lead to performance issues during startup. Consider lazy initialization or an asynchronous approach to avoid blocking the main thread.

Suggested change
private val mappings = runBlocking {
"${Network.mappings}/${Network.gameVersion}"
.downloadIfNotPresent(cache.resolveFile(Network.gameVersion))
.map { file ->
file.readLines()
.map { it.split(' ') }
.associate { it[0].split('$').last() to it[1] }
}
.getOrElse {
LOG.error("Unable to download deobfuscated qualifiers", it)
emptyMap()
}
private val mappings by lazy {
runCatching {
"${Network.mappings}/${Network.gameVersion}"
.downloadIfNotPresent(cache.resolveFile(Network.gameVersion))
.map { file ->
file.readLines()
.map { it.split(' ') }
.associate { it[0].split('$').last() to it[1] }
}
.getOrElse {
LOG.error("Unable to download deobfuscated qualifiers", it)
emptyMap()
}
}.getOrElse {
LOG.error("Error initializing mappings", it)
emptyMap()
}

Copilot uses AI. Check for mistakes.
@Avanatiker Avanatiker merged commit 8281bff into master Apr 17, 2025
1 check passed
@emyfops emyfops deleted the feat/dynamic-remapping branch April 17, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Suggests or adds a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants