#(the_lordnoob) Event: player brushes with<item> <block>
54 messages · Page 1 of 1 (latest)
(the_lordnoob) Event: player brushes with<item> <block>
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.
!event clicks block
Player
this event may in some cases double-fire, requiring usage of the 'ratelimit' command (like 'ratelimit <player> 1t') to prevent doubling actions.
player (right|left) clicks <block>
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.
when a player clicks on a block or in the air.
Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.
<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.
True - this adds switches in:<area> + location_flagged:<flag name>.
True - this adds <context.cancelled> and determines cancelled + cancelled:false.
yeah, but it triggers with air too
sadly that doesn't solves the issue of
My Aim is to track the overall time used a brush.
it would be awesome if there is a toggles brush option, so that it triggers on start and end of brushing
check whether the <context.location.material> is not air, or better yet, a brushable block.
that still not solves the toggel problem
~~You can also flag the player when they right click the block with the suspicious sand location (expire it after 6 seconds. It takes about 4.8seconds to brush something), then ~~use the block drops item from breaking event to check whether suspicious sand has dropped an item and use the location you flagged onto the player to check whether that suspicious sand dropped an item. If so, add 4.8 seconds to the total duration of brushing.
Theres no specific event for 'brushing'
spigot doesnt have one
(expire it after 6 seconds) why
If you keep it, and the player doesnt actually brush it imeddiately. They go away for 30 mins then come back to brush it, it will count as 30 minutes and 6 seconds
unless
oh wait no that was with my previous logic that I left out
Well ig it's not necessary seeing as the 4.8 seconds would be hardcoded, and it's not the duration between right clicking and getting the item
if they want just the time spent until the item is dropped can just use the blocks drops item event as the duration is hardcoded tbh
if they want brushing any block for any duration uh
id go for flagging w a really small expiration and slowly incrementing it
player clicks block fires 4 times a second (or every 5 ticks)
can have expiration be something >5t
on player clicks !air
or have a check inside the event if you want a specific list of mats *
Nah the problem is. I want to collect as a stat, the time used to brush in total.
The material should be !air ofc.
The problem is. I can track the start, but not the end of the brushing process. There for would be a toggle good
!t EntityTag.is_hand_raised
Returns whether the player's hand is currently raised. Valid for players and player-type NPCs.
A player's hand is raised when they are blocking with a shield, aiming a crossbow, looking through a spyglass, etc.
ElementTag(Boolean)
this might be true while brushing
if that's the case, then you can loop a few times after the click event to check if the player is still brushing
Alrady tried with the event (player raises/lowers item). Doesnt work for brushing. At least it didnt for me in 1.20.4
this is correct
you can use a while & that tag to slowly increment a flag by x every y
then do whatever you want with that value & make sure to remove the flag
eg
after player right clicks !*air with:brush:
- while <player.is_hand_raised>:
- wait 5t
- flag <player> brushing:+:5
#the below will fire only when the loop is over (ie when the player stops brushing)
- narrate "You brushed for <player.flag[brushing]> ticks!"
- flag <player> brushing:!```
note that you need to use after here instead of on in the event line
because you need the code to run after the player starts brushing, so the tag returns true
From a "Could Denizen recognize this event" standpoint, would this be considered a "Block Harvest" in Spigot? There's an event for PlayerHarvestBlockEvent, however I didn't see where Denizen was listening to it at the moment.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerHarvestBlockEvent.html
declaration: package: org.bukkit.event.player, class: PlayerHarvestBlockEvent
It still wouldn't give you exactly "how long did a player brush a block for", but if it triggered when the player finished brushing a block you'd know it was 4.8 seconds at that point I guess.
!e block drops item
Player
block drops item from breaking <block> drops <item> from breaking
when a items drop from a block due to a player breaking the block in survival mode.
Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.
<context.location> returns the LocationTag the block was broken at.
<context.material> returns the MaterialTag of the block that was broken.
<context.drop_entities> returns a ListTag of EntityTags of type DROPPED_ITEM. To get the list of I...
True - this adds switches in:<area> + location_flagged:<flag name>.
True - this adds <context.cancelled> and determines cancelled + cancelled:false.
this fires when a suspicious block drops an item
Oh, does it? Didn't realize. I thought since the block isn't broken it wouldn't fire.
yeah initally i thought the same
i only know that because i played around with them when they were added
Ahhh gotcha. If that's the case there's the start and end of the "brushing" event at least already.
suggested this because I got the impression they want to track any and all brushing (even if they don't fully extract the buried item or arent brushing a suspicious block)
imo the end of the while there acts as a switch for when they stop brushing so we'll see if that's what they needed c:
thats interesting that this is true, but the world event doesn't triggers
But yeah thats a way to get this working thanks