#Make a throwable item

30 messages · Page 1 of 1 (latest)

dusk hemlock
#

Is there a way to make an item throwable, like a trident? (or one which registers as a trident, atleast)

raw nymphBOT
#

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

vital nebula
#
const $TridentItem = Java.loadClass(`net.minecraft.world.item.TridentItem`)
const $ItemProperties = Java.loadClass(`net.minecraft.world.item.Item$Properties`)
StartupEvents.registry('item', event => {
    event.custom(`kubejs:my_trident`, new $TridentItem(new $ItemProperties().defaultDurability(600)))
})
#

Havent tested this but it should work I think

#

Oh wait you are on fabric

dusk hemlock
#

yeah lol; is there any reason that shouldn't work though?

vital nebula
#

Not sure, ive never written anything for fabric and those are regular minecraft classes I dont think they are forge specific. You can try

dusk hemlock
#

thank you so much!

#

just to check; that makes an item into a trident, it doesn't create an item right?

vital nebula
#

It would create a new item with the id kubejs:my_trident that works like a trident

#

It wont show up in JEI since we are using event.custom so you would need to add a client script for that

#
JEIEvents.addItems(event => {
    event.add('kubejs:my_trident')
});
dusk hemlock
vital nebula
#

The damage value comes from the .defaultDurability(600) method in the code above, the texture would be in kubejs\assets\kubejs\textures\item\my_trident.png

dusk hemlock
#

alrighty, thank you!

#

(not closing just yet, gonna test first lol)

vital nebula
#

Youre welcome, let me know if u run into any issues

dusk hemlock
#

Also, the thrown item has a trident texture ^^

vital nebula
#

Yeah I was thinking that may happen, you probably need a json model file as well since event.custom doesnt do it for you.

{
  "parent": "minecraft:item/generated",
  "textures": {
    "layer0": "kubejs:item/my_trident"
  }
}

assets/kubejs/models/item/my_trident.json

dusk hemlock
#

Is that inside of assets?

vital nebula
#

yep

dusk hemlock
#

cheers!

#

Awesome, the texture works! Unfortunately, throwing my custom trident creates a regular trident projectile. Is there any way to change this?

vital nebula
#

Ooh, yeah that would make sense. You would have to register a new trident entity and doing that in kubejs is a bit scary and janky. Heres an example of that but understand that it creates an arrow and it uses an already made arrow renderer class to work. I dont believe its possible to make an entirely new rendering class in KubeJS. If you wanted it to look different from a regular trident you would probably need to make a new renderer.

#

??notpossible

west carbonBOT
# vital nebula ??notpossible

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!

dusk hemlock
vital nebula
#

And even if you got the new trident entity working you would have to make it so that your custom trident spawns the custom trident entity, not the default one

dusk hemlock
#

auuugh alright