-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implement a proper solution to stop the music when a jukebox is destroyed #5800
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
base: minor-next
Are you sure you want to change the base?
Changes from 4 commits
d43fb73
c87bc6b
d581c58
a588225
b4e17fa
a573060
9cedacc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -427,14 +427,20 @@ public function getBreakInfo() : BlockBreakInfo{ | |
| * @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped, if full) | ||
| */ | ||
| public function onBreak(Item $item, ?Player $player = null, array &$returnedItems = []) : bool{ | ||
| $world = $this->position->getWorld(); | ||
| if(($t = $world->getTile($this->position)) !== null){ | ||
| $t->onBlockDestroyed(); | ||
| } | ||
| $world->setBlock($this->position, VanillaBlocks::AIR()); | ||
| $this->onDestroy(); | ||
| $this->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noting this is probably BC breaking, since the behaviour is now changed for non-core consumers of |
||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Called when this block is destroyed either when a player breaks it or is hit by an explosion. | ||
| */ | ||
| public function onDestroy() : void{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like @dktapps I don't think that There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| if(($t = $this->position->getWorld()->getTile($this->position)) !== null){ | ||
| $t->onBlockDestroyed(); //needed to create drops for inventories | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Called when this block or a block immediately adjacent to it changes state. | ||
| */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.