GithubHelp home page GithubHelp logo

Comments (15)

bensku avatar bensku commented on May 25, 2024 1

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.

TheBentoBox avatar TheBentoBox commented on May 25, 2024

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.

Pilvinen avatar Pilvinen commented on May 25, 2024

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.

UltraFaceguy avatar UltraFaceguy commented on May 25, 2024

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.

bensku avatar bensku commented on May 25, 2024

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.

Pilvinen avatar Pilvinen commented on May 25, 2024

I believe that has always been the case - unless you are trying to use something like a button for example.

from skript.

TheBentoBox avatar TheBentoBox commented on May 25, 2024

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.

UltraFaceguy avatar UltraFaceguy commented on May 25, 2024

That's... completely unacceptable, actually. I almost can't believe it. What the hell are they doing over there...?

from skript.

Pilvinen avatar Pilvinen commented on May 25, 2024

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
  1. Hold a torch
  2. Right click chest -> This chest is locked!
  3. Switch torch to offhand
  4. Right click chest -> The chest opens :-(

from skript.

Pilvinen avatar Pilvinen commented on May 25, 2024

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.

TheBentoBox avatar TheBentoBox commented on May 25, 2024

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.

bensku avatar bensku commented on May 25, 2024

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.

Pilvinen avatar Pilvinen commented on May 25, 2024

Canceling off-hand events now works in dev8b, off-hand handling is still not bug free:

  1. Hold torch in off-hand.
  2. Hold nothing in main hand.
  3. Right click to place torch.

And it fails to place the torch. But definitely a step in the right direction.

EDIT:

  1. Hold air in main hand.
  2. Hold exploding potion in off-hand.
  3. 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.

Pilvinen avatar Pilvinen commented on May 25, 2024

Ah ... dev8b still bypassing cancel event if you hold torch in main hand + sneak and right click.

from skript.

bensku avatar bensku commented on May 25, 2024

Everything mentioned here is now fixed. Please open new issues if something is still bugging.

from skript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.