PocketMine-MP
PocketMine-MP copied to clipboard
Added entity middle-click feature
Introduction
Added entity middle-click feature, this is a vanilla feature that it hasn't been implemented for so long.
Relevant issues
- Closes #4766
Changes
API changes
Added the following methods in Entity
:
-
Entity->getCleanedNBT()
: Returns a cleaned NBT from the entity, removing tags such as position, motion, etc. -
Entity->copyDataFromItem()
: Copies the entity NBT from the item into the entity (internal). -
Entity->getSpawnItem()
: Returns the item that can be used to spawn the entity, by default it returns air if there isn't one. -
Entity->getPickedItem()
: Returns an item that is able to spawn said entity, with a parameter$addUserData
to include the entity's NBT.
Added the following methods in Item
:
-
Item->clearCustomEntityData()
: Clears the NBT from the picked (middle-clicked) entity. -
Item->setCustomEntityData()
: Sets the NBT of the picked (middle-clicked) entity. -
Item->getCustomEntityData()
: Returns the NBT of the picked (middle-clicked) entity.
Added the following method in Player
:
-
Player->pickEntity()
: Equips the middle-clicked (picked) entity in the player's hand with added NBT if requested.
Added the following event:
-
PlayerEntityPickEvent
Tests
https://clipchamp.com/watch/nrP09ZXooey
I'd prefer this wasn't dependent on NBT. Bad enough that we have to deal with that for tiles already...
@JavierLeon9966 any updates for this PR? If not it will be closed when API 5 releases
Oh, whoops, I forgot about it, but I think I have the changes in my local