Skip to content

Commit

Permalink
More engima parsing fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Jan 7, 2025
1 parent fa7ea94 commit f803eaa
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

/**
* Enigma mappings file implementation.
* <p>
* Specification: <a href="https://wiki.fabricmc.net/documentation:enigma_mappings">enigma_mappings</a>
*
* @author Matt Coley
*/
Expand Down Expand Up @@ -71,28 +73,40 @@ public IntermediateMappings parse(@Nonnull String mappingText) {
break;
case "FIELD":
// Check if no longer within inner-class scope
if (strIndent < currentClass.size()) {
if (strIndent < currentClass.size())
currentClass.pop();
}

// Parse field
if (currentClass.empty())
throw new IllegalArgumentException(FAIL + "could not map field, no class context");

// Skip if there aren't enough arguments to pull the necessary items
if (args.length < 4)
continue;

String currentField = removeNonePackage(args[1]);
String renamedField = removeNonePackage(args[2]);
String currentFieldDesc = removeNonePackage(args[3]);
mappings.addField(currentClass.peek(), currentFieldDesc, currentField, renamedField);
break;
case "METHOD":
// Check if no longer within inner-class scope
if (strIndent < currentClass.size()) {
if (strIndent < currentClass.size())
currentClass.pop();
}

// Parse method
if (currentClass.empty())
throw new IllegalArgumentException(FAIL + "could not map method, no class context");

// Skip if there aren't enough arguments to pull the necessary items
if (args.length < 4)
continue;

// Skip constructors/initializers
String currentMethod = args[1];
if (currentMethod.equals("<init>"))
if (currentMethod.startsWith("<"))
continue;

// Not all methods need to be renamed if they have child arg elements that are renamed
if (args.length >= 4) {
String renamedMethod = args[2];
Expand Down

0 comments on commit f803eaa

Please sign in to comment.