#How to switch right click function on a custom KubeJS tool

12 messages · Page 1 of 1 (latest)

viscid spoke
#

Heyo, somewhat new to KubeJS, and I made some custom flint tools for a modpack I'm tinkering with, but I want to switch the pathing function of the shovel into a tilling function on right click. Not entirely sure how to start going about this.

onEvent('item.registry.tool_tiers', event => {
  event.add('flint', tier => { //custom tier for flint items
    tier.uses = 32
    tier.speed = 3
    tier.attackDamageBonus = 2.0
    tier.level = 0
    tier.enchantmentValue = 14
    tier.repairIngredient = 'minecraft:flint'
  })
})

onEvent('item.registry', event => {
  //flint trowel
  event.create('flint_trowel', 'shovel')
    .displayName('Flint Trowel').unstackable().tier('flint')
    //TODO: add ability to become farmvile incarnate
})

Any pointers on where to start for this type of thing?

pearl minnowBOT
#

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

austere herald
#

use the right click event

#
onEvent('block.right_clicked', event => {
  if (event.item.id == 'kubejs:flint_trowel' && event.block.hasTag('dirt')) {
    event.cancel()
    event.block.set('farmland')
    event.player.swingArm(event.hand)
    event.player.damageHeldItem(event.hand, 1)
  }
})

iirc

viscid spoke
#

hoh, neato, let me give it a shot

weary pivot
austere herald
#

huh

#

in 1.19 it swapped to past tense then

weary pivot
#

yep

viscid spoke
#

works like charm

#

thanks a ton lads, youre real ones

pearl minnowBOT
#

Ticket re-opened!