KubeJS

KubeJS

61M Downloads

Right click event doesnt cancel things it should

ChiefArug opened this issue ยท 3 comments

commented

Minecraft Version

1.19.2

KubeJS Version

kubejs-forge-1902.6.1-build.9999 (same as build.236 with #646 applied)

Rhino Version

rhino-forge-1902.2.2-build.268.jar

Architectury Version

architectury-6.5.85-forge.jar

Forge/Fabric Version

43.2.14

Describe your issue

ItemEvents.rightClicked('create:wrench', event => {
  event.cancel()
})

This should prevent all create wrench interactions, but it does nothing.
The forge event version

ForgeEvents.onEvent('net.minecraftforge.event.entity.player.PlayerInteractEvent$RightClickBlock', event => {
  if (event.itemStack.id == 'create:wrench'))
    event.setCanceled(true)
})

works fine

Crash report/logs

No response

commented

Use:

BlockEvents.rightClicked(event => {
    event.cancel()
})

instead.

ItemEvents.rightClicked is when the player right-clicks with the item in hand but is selecting no block or entities.

commented

Previously ItemEvents.rightClicked triggered on both block right click and empty right click, and BlockEvents.rightClicked triggered after ItemEvents.rightClicked only if ItemEvents.rightClicked wasnt cancelled.

commented

I think this is a Forge code change, Arch's right click event directly reflects the Forge's implementation, causing the right click event changed here.

From Forge's javadoc you can see that it only fires for clicking without targeting anything.