Skip to content

Commit a6f8537

Browse files
authored
Fix SOE from ResourceKey#compareTo (#4238)
* fix ResourceKey#compareTo SOE * overwrite ResourceLocation#compareTo to use adventure comparator * overwrite synthetic ResourceLocation#compareTo(Object)
1 parent 5ff032c commit a6f8537

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/mixins/java/org/spongepowered/common/mixin/api/minecraft/resources/ResourceLocationMixin_API.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.spongepowered.asm.mixin.Interface;
3232
import org.spongepowered.asm.mixin.Interface.Remap;
3333
import org.spongepowered.asm.mixin.Mixin;
34+
import org.spongepowered.asm.mixin.Overwrite;
3435
import org.spongepowered.asm.mixin.Shadow;
3536

3637
@Mixin(ResourceLocation.class)
@@ -45,15 +46,20 @@ public abstract class ResourceLocationMixin_API {
4546
@Shadow public abstract String shadow$getPath();
4647
// @formatter:on
4748

49+
/**
50+
* @author MrHell228 - October 6th, 2025
51+
* @reason Delegate synthetic method to #compareTo(Key) to avoid CCE in case Key is not a ResourceLocation
52+
*/
53+
@Overwrite
54+
public int compareTo(final Object obj) {
55+
return ((Key) this).compareTo((Key) obj);
56+
}
57+
4858
public String adventure$namespace() {
4959
return this.shadow$getNamespace();
5060
}
5161

5262
public String adventure$value() {
5363
return this.shadow$getPath();
5464
}
55-
56-
public int adventure$compareTo(Key o) {
57-
return -o.compareTo((Key) this);
58-
}
5965
}

0 commit comments

Comments
 (0)