Ability to make an item an instance of a java class.
th3impasta opened this issue ยท 10 comments
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
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.
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.
You would have to port this pr or find someone else willing to then.
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.
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