Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.

Nukkit and the inexistent InventoryClickEvent #24

Open
MrPowerGamerBR opened this issue Oct 7, 2016 · 8 comments
Open

Nukkit and the inexistent InventoryClickEvent #24

MrPowerGamerBR opened this issue Oct 7, 2016 · 8 comments

Comments

@MrPowerGamerBR
Copy link
Collaborator

Nukkit doesn't have a event to get if a player clicked on a item (InventoryClickEvent), however...

ContainerSetSlotPacket is sent from the client everytime he clicks on a item, at least Nukkit has a DataPacketReceiveEvent so we can intercept the click event.

However, there are issues with this:

  • We need to cache the last open inventory, since Nukkit doesn't have a API to get the current open inventory.
  • We need a way to convert Inventory (Nukkit) to InventoryView (Bukkit) because Bukkit needs a InventoryView.

But now I'm stuck, I tried doing this but I couldn't convert a Inventory (Nukkit) to a InventoryView (Bukkit).

@rutgerkok
Copy link
Owner

I will take a look at this tomorrow.

Inventories will be difficult to translate. In Pocket Edition, you can send an ItemStack from one inventory to the other in one go. We can maybe simulate this as two clicks (item pickup and item place).

Storing the open inventory can be done by creating another field in PokkitPlayer. If we know the open inventory and the player inventory, that should be enough information to create an InventoryView.

@rutgerkok
Copy link
Owner

I found InventoryTransactionEvent, which notifies when a transaction is completed.

In the Windows 10 edition, if you move an item (let's say: stone) to another slot, you get an InventoryTransactionEvent after the move is done. The event consists of two transactions: one that sets the old slot from stone to air, and one transaction that sets the new slot from air to stone.

In the Windows 10 edition, the hotbar occupies inventory slot 0 to 8. In Pocket Edition, the hotbar can occupy any inventory slot: place 3 in the hotbar can represent the item on slot 12 in the inventory. It is likely that a lot of Bukkit plugins expect the hotbar to always be in inventory slot 0 to 8.

@MrPowerGamerBR
Copy link
Collaborator Author

@rutgerkok at first we shouldn't care about the hotbar slots, not a lot of plugins care if a item is at a specific slot in a hotbar (on inventories? yes, but hotbars? probably not)

@ghost
Copy link

ghost commented Oct 8, 2016

@MrPowerGamerBR Tell to magicdroid for implement to nukkit

@ghost ghost added the Fixing label Oct 13, 2016
@Creeperface01
Copy link

so we can handle when windows 10 client click on item?

@MrPowerGamerBR
Copy link
Collaborator Author

@Creeperface01 I tested a little bit with the Minecraft Windows 10 client and yes, the ContainerSetSlotPacket is sent when the client clicks on a item.

@Snake1999
Copy link

Nukkit have implemented an event for inventory clicking. Works in classical UI or default UI in Windows 10. Looking forward to your work guys :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants