Skip to content

Implement Releaseable::getMinUseDuration()#6957

Open
remminiscent wants to merge 2 commits intopmmp:major-nextfrom
remminiscent:min-use-duration
Open

Implement Releaseable::getMinUseDuration()#6957
remminiscent wants to merge 2 commits intopmmp:major-nextfrom
remminiscent:min-use-duration

Conversation

@remminiscent
Copy link
Copy Markdown
Contributor

Implemented a new function getMinUseDuration in the Releaseable interface which will return the minimum needed ticks to use the item for an action to occur.

Also, regarding the Bow, should it be 5 ticks, or 0?

Related issues & PRs

Changes

API changes

  • Added Releaseable::getMinUseDuration

Backwards compatibility

Nope, It's BC Breaking. good for major-next branch

Tests

Works 👍
https://streamable.com/2l8zru

@remminiscent remminiscent requested a review from a team as a code owner December 23, 2025 08:33
Comment thread src/player/Player.php
public function consumeHeldItem() : bool{
$slot = $this->inventory->getItemInHand();
if($slot instanceof ConsumableItem){
if($this->getItemUseDuration() < $slot->getMinUseDuration()){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth moving this to PlayerItemConsumeEvent, similar to how hasItemCooldown is handled below.

@dktapps
Copy link
Copy Markdown
Member

dktapps commented Dec 23, 2025

I'm not sure how I want to handle this tbh. Interfaces like this have been a constant pain in the ass for BC breaks.

Considering we already have onReleaseUsing() in Item anyway, and #6928 is adding continueUsing() to Item directly for similar reasons, we should probably make sure the approaches for this are consistent.

@remminiscent
Copy link
Copy Markdown
Contributor Author

I'm not sure how I want to handle this tbh. Interfaces like this have been a constant pain in the ass for BC breaks.

Considering we already have onReleaseUsing() in Item anyway, and #6928 is adding continueUsing() to Item directly for similar reasons, we should probably make sure the approaches for this are consistent.

so do i /close this PR? ☹️

or, in my opinion, we have a parent ChargeableItem class for food, bows, crossbows, trident, etc. no need for bunch of interfaces like Chargeable & Releaseable

@dktapps
Copy link
Copy Markdown
Member

dktapps commented Dec 23, 2025

Bow would have to extend both Durable and Chargeable, that's not gonna work

@remminiscent
Copy link
Copy Markdown
Contributor Author

Bow would have to extend both Durable and Chargeable, that's not gonna work

You're right. well, i'll move onto making other PR's until this gets a plan

@dktapps dktapps added Category: API Related to the plugin API BC break Breaks API compatibility Type: Enhancement Contributes features or other improvements to PocketMine-MP Status: Blocked Depends on other changes which are yet to be completed labels Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BC break Breaks API compatibility Category: API Related to the plugin API Status: Blocked Depends on other changes which are yet to be completed Type: Enhancement Contributes features or other improvements to PocketMine-MP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants