#ForgeEvents.onEvent but on fabric

17 messages · Page 1 of 1 (latest)

rustic smelt
#

I need equal but on fabric

ForgeEvents.onEvent('net.minecraftforge.event.entity.player.PlayerInteractEvent$RightClickBlock', event => {
    if (event.entity.player &&
        event.getHand() == 'off_hand' &&
        event.entity.offHandItem == "minecraft:torch" &&
        (event.player.mainHandItem.hasTag('forge:tools/pickaxes') || event.player.mainHandItem.hasTag('forge:tools/paxels') || event.player.mainHandItem.hasTag('c:pickaxes'))) {
        event.setCanceled(true)
    }
})

don't suggest BlockEvents.rightClicked, it work totally different.

sweet sailBOT
#

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

wooden orchid
#

What was wrong with the fabric rightClick event?

#

I assume this is to avoid torches being placed in off hand when holding tools?

rustic smelt
wooden orchid
magic dove
#

are you sure it's really gone? it just becomes a desync between client and server and triggering a dirty inventory update usually fixes it (player.sendInventoryUpdate())

wooden orchid
#

I believe what’s happening Enigma is that two of their scripts for separate events are triggering at once

#

Aka an item and block event

#

Which results in them placing twice

magic dove
#

I briefly glanced through, I thought the original issue was cancelling the event caused the desync

rustic smelt
ornate roostBOT
#

Paste version of torch_by_pixaxe.js from @rustic smelt

rustic smelt
#

@magic dove

            event.cancel()
            event.server.scheduleInTicks(20, callback => {
                event.player.sendInventoryUpdate()
            })

also haven't fixed

rustic smelt
#

Fixed. Found a way to update the item. It became disgusting from this shit code, but what can I do, I will wait for a fix in kubejs.

        if (event.hand == 'off_hand') {
            event.cancel()
            event.player.offHandItem.setHoverName("Update!") //The workaround that fixes the kubejs mod visual bug. This is necessary so that the item is updated and the display starts working correctly again.
            event.server.scheduleInTicks(1, callback => {
                event.player.offHandItem.resetHoverName()
            })
        }
sweet sailBOT
#

@rustic smelt Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!