-
-
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
Implemented a proper way to handle items cooldown #6405
Conversation
pocketmine in server-side is applying the cooldown to the items with the same This means for example that for example when using a goat horn, the server is applying cooldown to an specific variant of the item, while the client is applying cooldown for all goat horns. So we have a mismatch here. |
Also i'm not sure if vanilla sends |
From my tests in BDS vanilla sends |
It looks like vanilla bothers only about item type. Would it be correct to change the logic in pocketmine to use |
There's no direct link between PM item types and Minecraft item IDs. In some cases multiple IDs are flattened under the same item in PM, and in other cases a single ID is split into several PM-side items. Basically you can't rely on either typeID or stateID for this. Possibly a better approach might be to introduce a "cooldown tag". PM would start a cooldown using the item's cooldown tag if it has one. Then any other items with the same cooldown tag can't be used until the cooldown expires. |
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.
Looks ok to me
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.
See review comments.
…to item-cooldown-sync
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.
LGTM, thanks for your constribution!
Introduction
This PR implements a proper way to handle item coodowns. These changes are necessary to make goat horns PR (and later shields) work correctly.
Changes
API changes
Added
Item::getCooldownTag() : ?string
to identify item cooldown groupAdded
ItemCooldownTags
that stores a list of vanilla cooldown groups.Behaviour changes
Item cooldowns are now synchronized with client via
PlayerStartItemCooldownPacket
.Item cooldown tags are now used to store item cooldowns. If item doesn't have such, stateId will be used.
Relevant issues
#5232
Tests
Tested with goat horns PR.