#ServerSide LeftClick Detection

24 messages · Page 1 of 1 (latest)

shadow needle
#

Wonky way to detect left click from serverside, it can't detect while you are spamming drop key.

PlayerEvents.tick(event => {
let p = event.player
  if(p.swingTime==1 && p.persistentData.swinging != 1) {
    p.tell(`leftClicked!`)
    //Some functions goes here...
  }
})

//Item Dropping causes Swinging
//Temporarily disalbe swinging detection
ItemEvents.dropped(event=>{
  let p = event.player
  p.persistentData.swinging = 1
  event.server.scheduleInTicks(2, event => {
    p.persistentData.swinging = 0
  })
})

It was kinda simple lol, actually it is similar as how plugin(bukkit) detect left click
Removing ItemEvents.dropped event block will cause dropping event also detected as leftclicked.

Related fields:swinging, swingingArm

frosty badger
#

why 1 and 0?

#

bools exist

solemn olive
obsidian karma
#

the problem here being that it doesn't detect cooldowns so you're better off using packets, because what if you're right-clicking a BE or swinging a fishing rod, or hell, even making other scripts that swing your arm?

shadow needle
#

Thats true

#

But kube can do smth with packet stuff?

#

I didnt touched packet area yet

obsidian karma
#

yeah it can

shadow needle
#

👀

silver radish
#

is PlayerEvents.leftClicked not a thing

manic citrusBOT
#

This is a list of all the events. Choose your version.

silver radish
zinc furnace
slow field
lucid spruce
#

(in nbt anyway)

shadow needle
shadow needle
#

Its for only serversides and light weight, vanilla-ish servers

frosty badger
silver radish
shadow needle
#

I used that few times but it doesnt work

#

Maybe that is different with normal click events