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 beacon #4687

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

Conversation

ShockedPlot7560
Copy link
Member

Introduction

Beacons are currently available but completely useless as the functionality has not been added.

Changes

API changes

  • Added BeaconInventory and BeaconAction classes
  • Completion of the beacon classe

Tests

  • Build beacon structure as vanilla
  • Activate it with the ore of your choice
    image

@dktapps
Copy link
Member

dktapps commented Jan 16, 2022

a

@ghost
Copy link

ghost commented Jan 16, 2022

I'm not sure that dktapps will merged it.

@ShockedPlot7560
Copy link
Member Author

I am in the process of making changes to improve performance

@dktapps
Copy link
Member

dktapps commented Jan 16, 2022

I'm not sure that dktapps will merged it.

I haven't had time to review it yet.

@ghost
Copy link

ghost commented Jan 17, 2022

I'm not sure that dktapps will merged it.

I haven't had time to review it yet.

I've meant that it's useless for most users of PocketMine-MP. This functionality can be move to plugin.

I thought pmmp was following the way of minimalism. No?

@dktapps
Copy link
Member

dktapps commented Jan 17, 2022

If that were the case, we could strip almost all the code in the name of "minimalism"...

JavierLeon9966 and others added 10 commits January 17, 2022 10:12
@dktapps dktapps changed the base branch from stable to next-minor January 17, 2022 15:07
src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/inventory/Beaconinventory.php Outdated Show resolved Hide resolved
src/network/mcpe/convert/TypeConverter.php Outdated Show resolved Hide resolved
src/network/mcpe/handler/InGamePacketHandler.php Outdated Show resolved Hide resolved
@dktapps dktapps added Category: Gameplay Related to Minecraft gameplay experience Type: Contribution labels Jan 17, 2022
src/block/Beacon.php Outdated Show resolved Hide resolved
@dktapps
Copy link
Member

dktapps commented Jan 18, 2022

If the beacon level reduces the secondary effect should be removed. This is an unlikely case so it doesn't bear much thinking about.

@ShockedPlot7560
Copy link
Member Author

If the beacon level reduces the secondary effect should be removed. This is an unlikely case so it doesn't bear much thinking about.

good

Copy link
Contributor

@Crasher508 Crasher508 left a comment

Choose a reason for hiding this comment

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

Works nice, tested
idk. who need a event/PHPDoc seems a little bit old

src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/Beacon.php Outdated Show resolved Hide resolved
src/block/Beacon.php Outdated Show resolved Hide resolved
src/network/mcpe/handler/InGamePacketHandler.php Outdated Show resolved Hide resolved
@dktapps dktapps added Type: Enhancement Contributes features or other improvements to PocketMine-MP and removed Type: Contribution labels Nov 26, 2022
}

public function onScheduledUpdate() : void{
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, 20 * 3);
Copy link
Member

Choose a reason for hiding this comment

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

According to the wiki, updates are every 4 seconds

Comment on lines +41 to +42
public const MIN_LEVEL_BEACON = 1;
public const MAX_LEVEL_BEACON = 4;
Copy link
Member

Choose a reason for hiding this comment

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

Inclunding BEACON in the constant name seems redundant since it is on the Beacon class

ItemTypeIds::NETHERITE_INGOT => true
];

private const ALLOWED_BLOCK_IDS = [
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to allow plugins to be able to modify this

Copy link
Member

Choose a reason for hiding this comment

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

Type tags would be the best thing

if(!$this->viewSky()){
return;
}

Copy link
Member

Choose a reason for hiding this comment

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

We need some validation here, it is possible that players might destroy blocks on any level and some effects will be no longer avaible

}
}

public function isBeaconLevelValid(int $level) : bool{
Copy link
Member

Choose a reason for hiding this comment

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

Please document this function, i feel that the name isn't clear enough

return true;
}

public function viewSky() : bool{
Copy link
Member

Choose a reason for hiding this comment

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

The function name is not the most appropriate.

}

/** @return Effect[] */
public function getAllowedEffect(int $beaconLevel) : array {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function getAllowedEffect(int $beaconLevel) : array {
public function getAllowedEffects(int $beaconLevel) : array {

if(!in_array($this->primaryEffect, $allowedEffects, true)){
throw new TransactionValidationException("Primary effect provided is not allowed");
}
if($this->secondaryEffect !== null && !in_array($this->secondaryEffect, $allowedEffects, true)){
Copy link
Member

Choose a reason for hiding this comment

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

This validation is incomplete. Secondary effect can only be Regeneration or the same as primary effect. Current code allows that a hacked-cleint to send a primary effect as secondary.

}

$allowedEffects = $block->getAllowedEffect($block->getBeaconLevel());
if(!in_array($this->primaryEffect, $allowedEffects, true)){
Copy link
Member

Choose a reason for hiding this comment

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

Avoid using in_array when possible

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 stalled to review this because the performance will suck, but there currently isn't a great alternative way to detect changes in the pyramid.

for($z = -$level; $z <= $level; $z++){
$block = $world->getBlock($pos->add($x, 0, $z));
if(!isset(self::ALLOWED_BLOCK_IDS[$block->getTypeId()])){
return false;
Copy link
Member

Choose a reason for hiding this comment

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

I really don't like this. I know that's the most obvious way to do it, but it's going to lag like shit.

ItemTypeIds::NETHERITE_INGOT => true
];

private const ALLOWED_BLOCK_IDS = [
Copy link
Member

Choose a reason for hiding this comment

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

Type tags would be the best thing

@dktapps dktapps added Status: Blocked Depends on other changes which are yet to be completed Performance Status: Waiting on Author and removed Status: Waiting on Author labels Nov 14, 2024
@ShockedPlot7560 ShockedPlot7560 requested a review from a team as a code owner November 20, 2024 07:36
@dktapps
Copy link
Member

dktapps commented Nov 23, 2024

As discussed internally, it would be best to move forward with a ChunkListener-based system for triggering pyramid rechecks as per @Muqsit's beacons plugin.

@dktapps dktapps removed the Status: Blocked Depends on other changes which are yet to be completed label Nov 23, 2024
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: Gameplay Related to Minecraft gameplay experience Performance 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.

7 participants