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

Add onEntityCollide function when entity are above a block #6347

Open
wants to merge 13 commits into
base: stable
Choose a base branch
from

Conversation

Dhaiven
Copy link
Contributor

@Dhaiven Dhaiven commented May 14, 2024

Introduction

PocketMine don't have function to detect if an entity are above a block.
So i add a function and fix the bug with magma block.
But there are other bug of this type (with top of cactus...), so i must to be fix in this pr or open an other pr to fix them ?

Relevant issues

Fix #2041

Changes

API changes

Add Block::onEntityCollide()

Follow-up

Tests

Add-Magma-Block-PMMP.mp4

@IvanCraft623
Copy link
Member

This does not really check if there is a collision so if there is a slab between the magma block and the player, the player will be burned.

@Dhaiven
Copy link
Contributor Author

Dhaiven commented May 15, 2024

This does not really check if there is a collision so if there is a slab between the magma block and the player, the player will be burned.

Thanks for the feedback, it's fixed

@jasonw4331 jasonw4331 added Category: Gameplay Related to Minecraft gameplay experience Type: Fix Bug fix, typo fix, or any other fix Status: Waiting on Author labels Jun 23, 2024
Copy link
Member

@IvanCraft623 IvanCraft623 left a comment

Choose a reason for hiding this comment

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

The current implementation only works for collsions on down side. An appropriate solution to the problem would be to detect when colliding with any face of the block, not just one.

src/block/Block.php Outdated Show resolved Hide resolved
@Dhaiven
Copy link
Contributor Author

Dhaiven commented Jun 29, 2024

The current implementation only works for collsions on down side. An appropriate solution to the problem would be to detect when colliding with any face of the block, not just one.

Fixed

src/block/Magma.php Outdated Show resolved Hide resolved
$block = $entityBlock->getSide($face);
foreach ($block->getCollisionBoxes() as $blockBox) {
if ($entityBox->intersectsWith($blockBox)) {
$block->onEntityCollide($this, Facing::opposite($face));
Copy link
Contributor

Choose a reason for hiding this comment

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

should this case add this?

$hasUpdate = true;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

May be but if i realy good understand, hasUpdate variable is set to true only if entity is update. However, in function onCollide, we are not sure that entity is update.
So, i don't realy sure

ShockedPlot7560
ShockedPlot7560 previously approved these changes Jul 5, 2024
Copy link
Member

@ShockedPlot7560 ShockedPlot7560 left a comment

Choose a reason for hiding this comment

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

Look OK to me

src/block/Block.php Show resolved Hide resolved
@Dhaiven Dhaiven requested a review from dries-c July 18, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Gameplay Related to Minecraft gameplay experience Type: Fix Bug fix, typo fix, or any other fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Magma blocks don't work any more
6 participants