KubeJS

KubeJS

69M Downloads

"Ambiguous" call with very clear arguments

copygirl opened this issue ยท 0 comments

commented

I can't quite wrap my head around this one. It appears when calling the ItemBuilder.tool method, the resolver can't decide between a String and a ToolType when I pass it a ToolType. Not sure if this is an issue with KubeJS itself or Rhino.

[08:47:03] [ERR ] Error occurred while handling event 'item.registry': The choice of Java method dev.latvian.kubejs.item.ItemBuilder.tool matching JavaScript argument types (me.shedaniel.architectury.registry.ToolType,number) is ambiguous; candidate methods are: 
    class dev.latvian.kubejs.item.ItemBuilder tool(me.shedaniel.architectury.registry.ToolType,int)
    class dev.latvian.kubejs.item.ItemBuilder tool(java.lang.String,int) (startup_scripts:content/temp.js#4)

Here is the code that causes this error:

onEvent("item.registry", event => {
  event.create("scythe").displayName("Scythe")
    .tool(ToolType.create("scythe", () => null), 0)
    .maxDamage(500);
});

(The error can be avoided by just calling ToolType.create on its own and using the String overload instead.)