#Fix for on player left clicks block from misfiring.

29 messages · Page 1 of 1 (latest)

copper badge
#

https://paste.denizenscript.com/View/139012

I was running into issues while debugging something and checked the order the events seem to fire on paper/spigot.

Looks like we might be able to fix on player left clicks from misfiring this way. I was able to reduce the error rate to zero as far as I can tell for from dropping items and interacting with objects like doors.

noble finchBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

copper badge
#

Fix for on player left clicks block from misfiring.

#

Specifically I tried with block and air both seem fixed with this script.

#

!event on player clicks block

green cobaltBOT
copper badge
#

!event on player clicks block

green cobaltBOT
# copper badge !event on player clicks block
Group

Player

**WARNING**

this event may in some cases double-fire, requiring usage of the 'ratelimit' command (like 'ratelimit <player> 1t') to prevent doubling actions.

**WARNING**

this sometimes fires at unexpected times, eg when dropping an item.

Event Lines

player (right|left) clicks <block>

Switches

with:<item> to only process the event if a specified item was held.
using:hand/off_hand/either_hand to only process the event if the specified hand was used to click.
type:<material> to only run if the block clicked matches the material input.

Triggers

when a player clicks on a block or in the air.

Has Player

Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.item> returns the ItemTag the player is clicking with.
<context.location> returns the LocationTag the player is clicking on.
<context.relative> returns a LocationTag of the air block in front of the clicked block.
<context.click_type> returns an ElementTag of the Spigot API click type <@link url https://hub.spi...
<context.hand> returns an ElementTag of the used hand.

Has Known Location

True - this adds switches in:<area> + location_flagged:<flag name>.

Cancellable

True - this adds <context.cancelled> and determines cancelled + cancelled:false.

copper badge
#

"WARNING
this sometimes fires at unexpected times, eg when dropping an item."

is what I am referring towards, this script seems to help resolve that issue.

#

Would it be possible to make this a feature request

trail burrow
#

this could break other existing scripts that already account for that

copper badge
#

What do you mean?

#

I feel like "accounting for this" would simply be just not using it and doing if-else checks against the same things I'm checking for now.

I would have thought a fix like this would simplify using the event, rather than require the user to invent work-arounds.

#

I also don't know what the policy is on bug fixes that break old scripts so my bad on that one.

trail burrow
#

iirc someone already proposed this idea and it got cancelled

copper badge
#

Strange.

#

Curious why

echo oyster
#

Do you want to listen clicking into air with an item

#

or blocks specifically

copper badge
#

The goal is to only detect empty hand (air) left clicks. Air, or otherwise.

#

The script I provided up above fixes the "fires at unexpected times" part.

#

I was wondering if the way I solved it in the script itself, would be a good way to implement it in the codebase to make the underlying event more reliable.

cedar gull
#

!command ratelimit

green cobaltBOT
# cedar gull !command ratelimit
Group

queue

Syntax

ratelimit [<object>] [<duration>]

Short Description

Limits the rate that queues may process a script at.

Description

Limits the rate that queues may process a script at.
If another queue tries to run the same script faster than the duration, that second queue will be stopped.

Note that the rate limiting is tracked based on two unique factors: the object input, and the specific script line.
That is to say: if you have a 'ratelimit <player> 10s', and then a few lines down a 'ratelimit <player> 10s',
those are two separate rate limiters.
Additionally, if you have a 'ratelimit <player> 10s' and two different play...

cedar gull
#

you can also ratelimit instead of checking both <player.has_flag[dropped_item]> || <player.has_flag[right_clicked_block]>

#

you could also instead lean more on the switch:

using:hand/off_hand/either_hand to only process the event if the specified hand was used to click.

#

to see if that excludes the drop click type

#

i wouldn't say your script is necessarily doing it the wrong way
-# there's too many way to do everything in denizen
but if i had your script there i'd pick any of in this order:

  • pivot to the switch (if that solves it)
  • switch to ratelimit instead of flags (flags are good for cross-event communication but this is just true/false checks)
  • at least use the same flag name since theyre two events stopping one
copper badge
#

Same flag name is definitely a good idea.