-
-
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 6 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,19 @@ 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->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR()); | ||
| 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. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2012,11 +2012,7 @@ private function destroyBlockInternal(Block $target, Item $item, ?Player $player | |
| } | ||
|
|
||
| $target->onBreak($item, $player, $returnedItems); | ||
|
|
||
| $tile = $this->getTile($target->getPosition()); | ||
| if($tile !== null){ | ||
| $tile->onBlockDestroyed(); | ||
| } | ||
| $target->onDestroy(); | ||
|
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. 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. |
||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
Noting this is probably BC breaking, since the behaviour is now changed for non-core consumers of
onBreak()