CraftHumanEntity#openInventory(Inventory inventory) never called?

Discussion in 'Plugin Development' started by Flyverse, Jul 22, 2014.

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

    Flyverse

    Hi!

    For a recent project I need to know which packet opens inventories. To find it I wrote a little program to track down specific keywords in a file system recursively, but I'm stuck somehow...

    I started to search where the InventoryOpenEvent is called and ended up (through multiple steps, but they aren't important) with the method CraftHumanEntity#openInventory(Inventoryinventory)

    I then tried to track down where this method is called - But it is apparently called nowhere? Anyone knows why, or how to continue my search? Where is the "start" of the opening of an inventory? (Be it a custom inventory, a chest, a players inventory...)

    Greetings
     
  2. Offline

    Geekhellmc

    You must create an inventory to open it other wise I don't know what will happen.
     
  3. Offline

    Flyverse

    Geekhellmc
    ... Wut?

    I'm not speaking about making a plugin here (I know, this section is called Plugin Development, but I think coding in general should fit here, as long as it has something to do with bukkit.). I'm trying to track down where inventories are opened/handled in the bukkit/nms source code. I found the method CraftHumandEntity#openInventory(Inventory inventory), but this method does not seems to be called anywhere.

    Excuse my bad english.
     
  4. Offline

    Flyverse

    AdamQpzm
    Thanks for the link! But my problem still remains. I need to find where the packet is handled/received in the bukkit/nms source, not how to send one. Or maybe I'm just being stupid right now :eek:
     
  5. Offline

    Necrodoom

    What do you need packets for inventory opening though? What exactly are you planning to do?
     
    AdamQpzm likes this.
  6. Offline

    Traks

    As you can see here, net.minecraft.server (NMS) methods such as this, this and this are being called. These in turn send the PacketPlayOutOpenWindow packet to the client. Not quite sure why you need this though...
     
  7. Flyverse It's a client-bound particle. Like Necrodoom says, why do you need to know what NMS does to send?
     
  8. Offline

    fireblast709

    Flyverse there is no client->server packet for opening inventories afaik (at least not that I can see in the PlayerConnection)
     
  9. fireblast709 I would be surprised if there was considering the server sends the packet, and consider the server doesn't know when a Player opens their own inventory - would be strange to have essentially a duplicate packet and miss out some information as well.
     
  10. Offline

    Flyverse

    Necrodoom
    Traks
    AdamQpzm
    Two reasons.
    1. Learning purposes
    2. Learning purposes - I want to build a program on top of minecraft (I think I don't even know myself what I will end up with. But I want to be prepared.), and I'm not sure if I'm going to use bukkit. But even if I do, I want to understand how all those packets are handled, where, when, etc...

    fireblast709 But how does the server then even know if I rightclicked a chest or pressed E? There has to be a packet who tells the server... Or not?
     
  11. Offline

    fireblast709

    Flyverse right clicking a chest sends an interact packet (block place packet iirc) which opens the inventory serverside, resulting in an inventory open packet being sent from server to client. If they press e and click an item, the server would know you don't have any other inventory open, so it has to be the player inventory
     
  12. Offline

    Flyverse

    fireblast709 Thank you! I tried to experiment with it for fun, and managed to open the inventory - But closing it and moving items still seems impossible, and I have no idea why. To close an inventory, I send a C0DPacketCloseWindow - It takes an integer "windowId" as argument, but nothing happens. The packet is sent, and it IS the right packet - I added a debugger in the NetHandlerPlayClient.class; If I press E, a C0DPacketCloseWindow is sent, and has an incrementing number as windowId; But the packet I send myself does not do anything... Same with C0EPacketClickWindow... (Yeah, I know that it's stupid to try to move items with your keyboard, but as I said above, I wanted to play around with this and I absolutly want to solve it...)

    Greetings!
     
  13. Offline

    Garris0n

    It's a part of the API implementation, it's only meant to be called by plugins.

    Look at what it calls.
     
Thread Status:
Not open for further replies.

Share This Page