Comments (15)
Spigot always throws TWO click events - one with main hand and one with off hand... Due to that, I need to manually check which hand event should be used.
from skript.
Further research, when looking through EvtClick. Keep in mind I don't know Java/plugins, as I said before, but it's readable to me.
I see this line:
if (((PlayerInteractEntityEvent) e).getHand() == EquipmentSlot.OFF_HAND && (mainHand == null || mainHand.getType() == Material.AIR))
return false;
By the look of it, this is basically saying to dive out of the event if the event is triggered from the offhand and the main hand is empty, and if it's an entity interaction event. This probably isn't the best, it should trigger an entity interact event as if they player used the offhand item - e.g. if them main hand is empty and diamonds are in my offhand, and I right click on a zombie, it should trigger an "on right click on zombie with diamonds".
Additionally, there's the huge "checkOffHandUse" function. I don't entirely know the reason this exists, or why all these extra checks are being done to dive out of events:
if ((useOffHand && clickEvent.getHand() == EquipmentSlot.HAND) || (!useOffHand && clickEvent.getHand() == EquipmentSlot.OFF_HAND)) {
return false;
}
It shouldn't really matter what the situation is in regards to the main hands and off hand and what's in them and what isn't, the event should always trigger like it did in 1.8. I don't know for sure if checkOffHandUse is really needed. As I understand it, within the PlayerInteractEvent and PlayerInteractEntityEvent, you can do event.getHand() to check which hand it is. Then based on which hand it was, it should trigger an event based on that, maybe allow the hand to be checked via "on right click on zombie with diamonds with offhand". This could add "with mainhand", or just be ommitted to trigger no matter which hand did it.
Obviously I don't really know how Spigot's interact events work. If you right click on a creeper with a sword in the main hand and a flint and steel in the off hand, in theory the event should trigger as being triggered by the off hand with the tool as flint and steel. But I imagine Spigot doesn't always work as you'd like :')
from skript.
Hopefully this will help some:
http://minecraft.gamepedia.com/Tutorials/Dual_wielding
You can check how the logic is supposed to work from there. It will probably take a moment to implement properly.
from skript.
I can confirm that having an offhand item but no mainhand item bypasses on rightclick in dev7b still, if that helps at all. I'm going through and testing lots of interact things as my server relies heavily on skript, I'll let you know if I come up with any more info :x
from skript.
Soo, I figured out that Vanilla client won't send any packets if off hand doesn't have usable item and main hand is empty while clicking air. Other things I'm trying to fix currently.
from skript.
I believe that has always been the case - unless you are trying to use something like a button for example.
from skript.
Before, right clicking air with anything in hand, even non-usable item, would send a packet. Bensku is saying that having the non-usable in the offhand sends no packet. So you can't have an empty mainhand and non-usable offhand and detect generic right clicks, unfortunately.
from skript.
That's... completely unacceptable, actually. I almost can't believe it. What the hell are they doing over there...?
from skript.
This seems quite serious. You can effectively dismiss all right click cancel events at the moment with this.
Dev8:
on right click on chest or trapped chest:
cancel event
send " This chest is locked!" to player
- Hold a torch
- Right click chest -> This chest is locked!
- Switch torch to offhand
- Right click chest -> The chest opens :-(
from skript.
Mojang has now been doing this for some time. They've been optimising Minecraft and removing, for example, what they deem as unnecessary packet sending (and extra damage values, etc). I mean, why send a packet when clicking with something that's not supposed to do anything, right?
from skript.
This seems less like an issue with Mojang/Minecraft and more like an issue with Skript. The fact that you're opening the chest at all means the packet is being sent. The problem is that Skript isn't triggering the "on right click on chest or trapped chest" event in that situation - empty mainhand, usable item in offhand. That's one of the issues I said in the original post, actually.
Empty mainhand, usable item in offhand: doesn't trigger click events when using interactable blocks. Example: shield in offhand, right click on a lever - event doesn't trigger.
from skript.
Hmm, very interesting. I checked the code, and if player has empty main hand, it makes only off hand click event to appear. The thing is... Does Spigot ALWAYS throw off hand click event at all? It seems that there are few exceptions where it doesn't, like opening chests...
Edit: That's the case, and I fixed incorrect handling of it. Chest locking code seems to work, at least.
from skript.
Canceling off-hand events now works in dev8b, off-hand handling is still not bug free:
- Hold torch in off-hand.
- Hold nothing in main hand.
- Right click to place torch.
And it fails to place the torch. But definitely a step in the right direction.
EDIT:
- Hold air in main hand.
- Hold exploding potion in off-hand.
- Right click to throw potion.
And it fails to throw the potion (on the other hand, pardon the pun, if you hold a torch in main hand and click air, it throws the potion)
IIRC, TheBukor mentioned that he made a pull request for nfells version of Skript where he had fixed off-hand expression. I wonder if that would be of some help in getting this thing finally wrapper up?
from skript.
Ah ... dev8b still bypassing cancel event if you hold torch in main hand + sneak and right click.
from skript.
Everything mentioned here is now fixed. Please open new issues if something is still bugging.
from skript.
Related Issues (20)
- NoClassDefFound Error HOT 3
- Legacy Code Tracker
- unexpected repair/damage behaviour HOT 4
- Add recently added attributes HOT 2
- Searching Feature
- Add experience class into accept change on ExprTotalExperience
- Add skript-reflect (or at least some features) into Skript HOT 1
- Expose required variable changes for save as a config option
- SimpleLiterals pass "constant" backing array to other syntax.
- Stop referencing the old Converter class in PropertyExpression HOT 2
- Wither HOT 2
- Allow `armour stand` as `armor stand` HOT 2
- Entities despawning when target is set HOT 1
- bStats syntax for Skript HOT 14
- Remove skript: from commands created in skript (config option) HOT 8
- New beta: not setting canceled event-block to bedrock
- Error HOT 1
- Tadpoles cannot spawn HOT 5
- Release Channel / Update Checker logic not handling betas properly HOT 1
- Streams HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skript.