Skip to content

Commit

Permalink
Fix: Reset Unique field counters on Mixin application. (#136)
Browse files Browse the repository at this point in the history
They previously caused hotswaps to fail due to the number increasing on each application.
  • Loading branch information
LlamaLad7 authored Apr 11, 2024
1 parent a209179 commit 320b74c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public MethodMapper(MixinEnvironment env, ClassInfo info) {
public ClassInfo getClassInfo() {
return this.info;
}

/**
* Resets the counters to prepare for application, which can happen multiple times due to hotswap.
*/
public void reset() {
this.nextUniqueMethodIndex = 0;
this.nextUniqueFieldIndex = 0;
}

/**
* Conforms an injector handler method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,10 @@ void applyMixins() {
}

/**
* Run extensions before apply
* Run extensions before apply and clean up any global state in case this is a hotswap
*/
private void preApply() {
this.getClassInfo().getMethodMapper().reset();
this.extensions.preApply(this);
}

Expand Down

0 comments on commit 320b74c

Please sign in to comment.