Skip to content
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

Implement a proper solution to stop the music when a jukebox is destroyed #5800

Open
wants to merge 6 commits into
base: minor-next
Choose a base branch
from

Conversation

IvanCraft623
Copy link
Member

Introduction

The current solution presents some problems as first of all Tiles should not handle the behavior of blocks, instead of using the jukebox API to eject the disc directly boradcasts RecordStopSound, which causes the loss of the disc by destroying the jukebox which at the same time does not match the Vanilla behavior.

This PR addresses the problems mentioned above by adding the Block::onDestroy() method, making the block not dependent on the Tile to manage this logic, which as a plus eliminates duplicate code in Block::onBreak() and Explosion::explodeB().

Copy link
Member

@dktapps dktapps left a comment

Choose a reason for hiding this comment

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

I agree that something like this is needed, but I'm not super happy with the "destroy" terminology. It feels too ambiguous.

src/block/Block.php Outdated Show resolved Hide resolved
@dktapps dktapps added Category: API Related to the plugin API Category: Core Related to internal functionality Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Jun 5, 2023
/**
* Called when this block is destroyed either when a player breaks it or is hit by an explosion.
*/
public function onDestroy() : void{
Copy link
Member

Choose a reason for hiding this comment

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

Like @dktapps I don't think that destroy terminology is appropriate in this case. Perhaps, as with the placement logic, an onPostBreak would be preferable? It would be less ambiguous and not so funny in the sense that the block would already have been destroyed.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that's desirable. If the block was already destroyed, contents of stuff like tiles wouldn't be accessible.

Personally I would lean towards an onExplode() method or something similar. We already have the likes of onIncinerate() for fire. The problem is that this would require multiple handlers to be implemented for dealing with tile drops.

if($tile !== null){
$tile->onBlockDestroyed();
}
$target->onDestroy();
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this function only be called if the onBreak returns true? There is a return value, but it's never used, and yet it would make sense in this case. If the broken action has been confirmed, then we can call this function, which is there to perform post-broken actions.

@dktapps
Copy link
Member

dktapps commented Jul 13, 2023

Has anyone considered using Block::onBreak() for this instead of adding an extra method? It does allow passing null for the player parameter.

I haven't thought much about the pros and cons of this approach, but I think it should be considered.

Joshy3282 added a commit to Joshy3282/PocketMine-MP that referenced this pull request Oct 2, 2024
@dktapps
Copy link
Member

dktapps commented Nov 14, 2024

Linking #4652 as I think these are two different solutions for essentially the same problem

Copy link

github-actions bot commented Dec 7, 2024

This PR has been marked as "Waiting on Author", but we haven't seen any activity in 7 days.

If there is no further activity, it will be closed in 28 days.

Note for maintainers: Adding an assignee to the PR will prevent it from being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: API Related to the plugin API Category: Core Related to internal functionality Stale Status: Waiting on Author 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