-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added entity middle-click feature #5397
Conversation
I'd prefer this wasn't dependent on NBT. Bad enough that we have to deal with that for tiles already... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that this involves so much in the way of legacy hacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to merge this because entities currently predominantly use the Java entity NBT format, but items use the Bedrock format. This is already a disaster for tiles.
I'm OK with having the basic entity picking, but I think the NBT stuff should be removed for now until the internals handling can be cleaned up (and preferably find a way to deal with extra data that doesn't require NBT at all).
… value to `?Item`
The internal handling of this need to be cleaned up first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The separation between "spawn item" and "picked item" seems redundant.
@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 |
This looks basically fine as it is right now, minus a few nits. I will mention that we'll probably want to apply #4771 to |
Introduction
Added entity middle-click feature, this is a vanilla feature that it hasn't been implemented for so long.
Relevant issues
PlayerEntityPickEvent
#4766Changes
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