[NMS HELP] Pick Block

Discussion in 'Plugin Development' started by BlueMustache, Apr 15, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    BlueMustache

    Hello Everyone!
    I need help with packets. This may use NMS (which I'm fine with), or maybe just the api.
    Can someone tell me how I can tell when someone middle clicks (pick block), and have a way to cancel it. Also, I am am essentially trying to when someone middle clicks in survival mode, I will run some code on the block their looking at.

    Bottom Line: I need a way to detect when a survival player middle clicks (and maybe even a way to cancel it).

    This may help

    Thanks so much!
    - Blue

    Bump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    BillyGalbreath

  3. Offline

    BlueMustache

  4. Offline

    idontcare1025

    Did you properly import everything?
     
  5. Offline

    BlueMustache

    I did.
    I even tried manually importing ClickType.
    Eclipse does not recognize that import.
    When I decompiled the source for craftbukkit, I found everything was in the right place.
    Also, InventoryClickEvent only recognizes maybe 3 at most methods.
    WHat am I doing wrong? :(
     
  6. Offline

    Konkz

    Outdated perhaps? I mostly have that problem. ;-; BlueMustache
     
  7. Offline

    BlueMustache


    Maybe so, but the current and even new api show it up.
    I dont know, ill do a little digging.

    Try it for yourself

    @EventHandler
    public void onMiddle(InventoryClickEvent e) {
    Player p = (Player) e.getWhoClicked();
    }

    It doesn't show up.
     
  8. Offline

    Maurdekye

    BlueMustache InventoryClickEvent only listens to clicks while players have an inventory open (ie. their own, a chest, or a crafting table.). If you wanted to listen to a player clicking normally, you'd need to use PlayerInteractEvent. Unfortunately, that doesn't listen or report middle clicks, so you're out of luck. You are right in that you will have to use NMS in order to solve this problem. Unfortunately, I don't know enough about NMS to help you with it.
     
  9. Offline

    BlueMustache


    You were right. :/
    I am trying to use this on 1.4.7, but I can't do it because its too old.


    I thought so,
    Anyone know how to do this in 1.7 or in 1.4.7 using NMS?

    Bump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
    Konkz likes this.
  10. Offline

    Garris0n

    Pretty sure it only tells the server "hey, I spawned an item!" via this event.

    Unfortunately, you can't tell the difference between that and spawning an item from the creative menu.
     
  11. Offline

    BlueMustache

    Garris0n
    That might work for creative, but I need this for survival.
    I know there has to be somewhere in the bukkit code that listens for the pick block function, so It can give the stuff server side, bypassing the give command, using only the bukkit api.

    all
    If anyone is very familiar with the bukkit source, please help.
    This will most likely need to be done with NMS.
    I know for a fact that the client will send a packet that says "I middle Clicked" to the server, and it will check if they're in creative, and if so, they get the item they're looking at.
    What I'm trying to do is call my home made PlayerPickEvent, so I can essentially make a pick block interface for survival. I know I could do this other ways, but middle click is what I need.
    Thanks
     
  12. Offline

    Garris0n

    I'm pretty sure the client just sends a slot change packet in survival.
     
  13. Offline

    BlueMustache

    Garris0n
    It has to be server side.
    Or else, I could make a hacked client that allowed me to send a packet that let me pick block.
    There has to be something it has to process.
     
  14. Offline

    xTigerRebornx

    BlueMustache Pick block is client side, all its calculations are done client side, and as Garris0n said, doing it in survival will simply send a slot change packet.
    If you feel the need to continue to deny this, point out how it is sent from client to server, look through the protocol, try and find out if it is or not yourself
     
    Garris0n likes this.
  15. Offline

    Garris0n

    The pick block key either
    1. Sends a creative "spawn item" packet, which calls the aforementioned event. In this case it might also send a slot change packet.
    or 2. In survival, just sends a slot change packet.

    That is how I understand it. You could make a hacked client that allowed you to spawn items, but only in creative. You could make a hacked client that allows you to select a different slot, or you could just use the key selected in the settings menu...
     
  16. Offline

    BlueMustache

    Ill try some stuff.
    Any ideas for an event that detects a slot change?
     
  17. Offline

    Garris0n

  18. Offline

    BlueMustache

    thanks.
    ill do some fiddling.
     
Thread Status:
Not open for further replies.

Share This Page