#does javaAdapter from rhino work?

18 messages · Page 1 of 1 (latest)

drifting walrus
#

i am trying to see if i can have my custom item implement IAugmentItem from COFH and i have the following code

const $ResourceLocation =       Java.loadClass("net.minecraft.resources.ResourceLocation");
/* const BetterInputComponent = new $MappingComponent ($ItemComponents.INPUT,item => {
  j = item.ingredient.toJson();
  if(!j.isJsonObject()){ 
    throw new Error("Error In Schema item should be a json object");
  }
  j = j.getAsJsonObject;
  j.addProperty("count",item.count);
  return j;
}, json => inputItem.ofJson(json));*/

const $ItemBuilder = Java.loadClass('dev.latvian.mods.kubejs.item.ItemBuilder');

const test = new JavaAdapter($ItemBuilder,{
  getRegistryType: () => null,
  createObject: () => null
},$ResourceLocation("kubejs","fake"));
``` however i get an unexpected error from my log i was expecting to get a Null something exception i instead get a NoSuchMethodException thanks in advance
robust thornBOT
#

Paste version of startup.log from @drifting walrus

rustic wadiBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

quasi umbra
#

ResourceLocation is already a native bind, you don't need to load/import, just use directly with new ResourceLocation("kubejs", "fake")

and I'm not sure someone managed to make something implement something at runtime, but be the first 😛

robust thornBOT
#

Just because someone said it isn't possible doesn't mean it actually is. Instead they meant that no one has successfully done it yet.

Be the first!

quasi umbra
#

try to see the methods with getDeclaredMethods() of the java adapter

drifting walrus
#

i tried loading the JavaAdapter class and it didn't work?

#

neither did calling JavaAdapter.class how do i get the class object to call getDeclaredFields?

quasi umbra
#

let me launch my instance to check which one works

#
const $JavaAdapter = Java.loadClass("dev.latvian.mods.rhino.JavaAdapter")
const $Java = Java.loadClass("java.lang.Class")
const $JavaAdapterRawClass = $Java.forName("dev.latvian.mods.rhino.JavaAdapter")

StartupEvents.init(event => {
  console.printClass("dev.latvian.mods.rhino.JavaAdapter")
  console.log($JavaAdapterRawClass.getDeclaredMethods())
  console.log($JavaAdapterRawClass.getDeclaredFields())
})
drifting walrus
#

ok it is actually looks possible but we are getting really close to the point that i feel it would be better/easier to make a KJS addon to deal with this stuff

quasi umbra
#

I think KubeJS Thermal exists @drifting walrus

#

did you take a look?

drifting walrus
#

does it allow adding thermal augments? i saw only recipes, would adding augments be in scope?

quasi umbra
#

absolutely should be in the scope

#

if it still doesn't, just PR

#

who is the maintainer? Max?

drifting walrus
#

i think it is a first party addon?