#Another person trying to make a custom sapling/tree, is it possible to extend an abstract class?

3 messages · Page 1 of 1 (latest)

old kestrelBOT
#

You didn't select a Minecraft version or ModLoader tag! Please select both and re-submit your post!

drifting shoalBOT
#

[➤](#1411948946397593631 message) What would a script for turning a custom sapling into a custom tree look like within .randomTick()

[➤](#1291268149244723272 message)
...So, I discovered a new alternative method to define the saplings and leaves, but it was almost immediately shut down due to creating two new massive problems
The new method in question is doing this:

const $LeavesBlockType = Java.loadClass("net.minecraft.world.level.block.LeavesBlock")
const $SpruceTreeGrower = Java.loadClass("net.minecraft.world.level.block.grower.SpruceTreeGrower")
const $BlockBehaviorProperties = Java.loadClass("net.minecraft.world.level.block.state.BlockBehaviour$Properties")

StartupEvents.registry('block', event => {
    event.createCustom('kubejs:pine_leaves', () => new $LeavesBlockType(new $BlockBehaviorProperties()))
    event.createCustom('kubejs:pine_sapling', () => new $SaplingBlockType(new $SpruceTreeGrower(), new $BlockBehaviorProperties()))
})```
This causes both blocks to utilize the correct properties for their types (meaning the leaves will decay when not near a log, and the sapling can be bone-mealed to grow into a tree), but it comes with two major caveats:
* The sapling and leaves no longer come with an auto-generated item, and manually defining an item with the item registry doesn't give me the option to link the items to a block, making placing the leaves or the sapling impossible
* The sapling grows up into a vanilla spruce tree, as a result of me using the `SpruceTreeGrower`. Unless KubeJS has a way to define new types of `Abstract(Mega)TreeGrower`s, I don't think there's any way around this
* (Also, on a tangentially-related note, this does not fix the issue of the leaves being white, and in fact makes the block below the leaves invisible for some reason)
If anyone has any level of familiarity with `event.createCustom()` and knows of any way to solve any of these issues I'd be very grateful! This approach seems way more promising than the normal way of defining blocks, but I basically can't use it as it is

[➤](#1453346756711419954 message) Ive seen in one modpack that you could just make a sapling_overrides folder in the data/kubejs folder, but that doesn't seem to work for me

[➤](#1468650192898363635 message)
At most you can:

  • implement an interface
  • extend an abstract class (?) via JavaWrapper

[➤](#1460401218001047592 message)
There have been posts about this topic before but I haven't found a concrete answer anywhere. I am trying to create a completely custom tool type for a specific use for crystal blocks in my modpack. I went looking at how other mods achieve this (such as Farmers Delight with knives) but it doesn't seem like I can do it in KubeJS. This is what I was experimenting with but realized that this isn't the right class for this but can't find anything better. There isn't a way to get the Tier class in startup scripts which seems to be required to make tool types. Any help would be appreciated.

const $DiggerItem = Java.loadClass('net.minecraft.world.item.DiggerItem')
StartupEvents.registry('item', event => {
    event.createCustom('diamond_chisel', () => new $DiggerItem(1, 1, ))
})
old kestrelBOT
#

You didn't select a Minecraft version or ModLoader tag! Please select both and re-submit your post!