Carpet

Carpet

2M Downloads

Adding an event for player middle click?

mwappner opened this issue ยท 7 comments

commented

Just a simple request to add an event __on_player_middle_clicks(), or __on_player_picks_block(). That would fit in nicely with right and left click events.

commented

middle click event is a mess to be honest.
If the result is switching something in the hotbar - the event never reaches the server apart from the default event of updating selected slot.
In creative its triggered for no reason multiple times if you just open inventory
In survival it only triggers if you are actually pulling the item from the inventory, and not hotbar, and if you don't have anything to switch to or pointing into the air - nothing happens.

There are two events that are consistent I found with that - selecting a recipe in crafting window, and switching the hotbar slot - will add events for these ones.

Lets keep this one open - I will dabble on this one - maybe there is a way with some extra logic to clean up middleclick actions but I doubt it.

commented

Glad something useful came out of this :)

commented

it might be purely client event. Need to check. There will be some item changed in the inventory type of events anways, since these are tracked server side.

commented

Actualy I was interested in that event to be able to highjack the middleclick action to do stuff, so we have three options, instead of two (right and left click). On the same note, I haven't found a way to detect the event of a player simply swinging a tool or wapon, without hitting anything. Again, it'd be useful to be able to left click in the air.

commented

you could have it so that if the player is not facing anything there is a marker that hover before the player so that when he clicks it will be attacekd, and you can detect it, and it will be killed once the player has a new target. But it would require query(player,'trace') every tick, which may not be effieicnt

commented

Yeah but the problem with datapacks is that they don't form a coherent language. Scarpet was built to fill in the gap left by datapacks, but even then there are times in which we have to resort to this sorta stuff. But overall it shouldn't be too much trouble

commented

Yeah, I did it even worse with an invisible, invulnerable, no AI slime. That's how bling edit solvet the issue in vanilla a few years ago, but it'd be cool to have those events.