Skip to content

Commit fe50ae8

Browse files
committed
get actual tool tier origin class
1 parent bdb8227 commit fe50ae8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/mixin/java/mcp/mobius/waila/mixin/ToolMaterialMixin.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ public class ToolMaterialMixin {
1818
@Inject(method = "<init>", at = @At("TAIL"))
1919
private void wthit_init(CallbackInfo ci) {
2020
if (wthit_stackWalker == null) wthit_stackWalker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
21-
IMixinService.INSTANCE.addToolMaterialInstance((ToolMaterial) (Object) this, wthit_stackWalker.getCallerClass());
21+
22+
var caller = wthit_stackWalker.walk(s -> s
23+
.skip(2)
24+
.map(StackWalker.StackFrame::getDeclaringClass)
25+
.findFirst()
26+
.orElse(null));
27+
if (caller == null) caller = wthit_stackWalker.getCallerClass();
28+
29+
IMixinService.INSTANCE.addToolMaterialInstance((ToolMaterial) (Object) this, caller);
2230
}
2331

2432
}

0 commit comments

Comments
 (0)