KubeJS

KubeJS

69M Downloads

Ability to make an item an instance of a java class.

th3impasta opened this issue ยท 10 comments

commented

Describe the feature

So I use the reflection feature to import a class from Hexcasting. I've looked through the docs and there seems to be no way to make an item an instance of this class.

Additional info

No response

commented

There is in 1.19+, using event.custom(String name, T object) where name is the id and object is the instance of the the thing registry event (ie an instance of a class that extends Item).
https://github.com/KubeJS-Mods/KubeJS/blob/1.19/main/common/src/main/java/dev/latvian/mods/kubejs/RegistryObjectBuilderTypes.java#L87

This exists for all registries.
Examples can be found on the discord in the #example-scripts channel. They will probably be added to the wiki at some point.
https://discord.com/channels/303440391124942858/1059783507100041296/1059783507100041296

Note that using event.custom disables all json generation (like models, the display name in a lang file and loot tables) that might otherwise happen automatically, and also doesnt allow you to use other methods you might normally be able to use on it, such as .property for blocks.

commented

could this be done in 1.18?
this would be very helpful for me

commented

Someone did try to port the feature to 1.18, but it did not work out. I believe it could still be done, but I (as the one who PRed this feature originally) am not willing to do it.

commented

i probably should've had to specify that im on 1.18.2. 3:

commented

You would have to port this pr or find someone else willing to then.

commented

why do you mention 1.18 in the pr

commented

Because I tested it on there, as that is the latest version tinkers construct is on and one of my goals with it was to make custom tinkers tools possible. I ran out of motivation to properly port it though.

commented

do you have the unfinished port?
and how hard would it be to port it

commented

If you do not know java concepts like generics and functional interfaces: quite hard. If you know those, less than an hour, maybe half an hour if you are very familiar with kubejs, mc modding and java.
I probably do have the 1.18 build, but i am not going to dig it out

commented

1.18.2 has been confirmed as not getting new features, so closing this