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 firework rocket & firework star #5455

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

Conversation

IvanCraft623
Copy link
Member

Introduction

Implement items: Firework Rocket, Firework Star and entity: Firework Rocket.

Follow-up

Requires translations:

Name Value in eng.ini
death.attack.fireworks {%0} went off with a bang

Tests

https://youtu.be/kHs_nBmLRhs

@dktapps dktapps added Category: Gameplay Related to Minecraft gameplay experience Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Dec 22, 2022
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.

The implementation looks mostly OK. I haven't tested it yet.

My main sore point on this PR is the woefully inadequate documentation and ambiguous method names.

src/entity/object/FireworkRocket.php Outdated Show resolved Hide resolved
src/entity/object/FireworkRocket.php Outdated Show resolved Hide resolved
src/item/FireworkRocketExplosion.php Outdated Show resolved Hide resolved
src/item/FireworkRocketExplosion.php Outdated Show resolved Hide resolved
src/item/FireworkRocketExplosion.php Outdated Show resolved Hide resolved
src/item/FireworkStar.php Show resolved Hide resolved
src/world/sound/FireworkTwinkleSound.php Outdated Show resolved Hide resolved
src/item/FireworkRocketExplosion.php Outdated Show resolved Hide resolved
src/entity/animation/FireworkParticlesAnimation.php Outdated Show resolved Hide resolved
@IvanCraft623
Copy link
Member Author

Missing features:

  • Fireworks can ring bells
  • Fireworks can be directed in any direction (can be observed when flying with elytras, or using a dispenser).

@JavierLeon9966
Copy link
Contributor

Missing features:

  • Fireworks can ring bells
  • Fireworks can be directed in any direction (can be observed when flying with elytras, or using a dispenser).

Also with crossbows, but it can wait until those are implemented first.

@ShockedPlot7560
Copy link
Member

A PR doesn't have to be all in one, I think the current features are sufficient, the remaining ones are not critical.

@IvanCraft623 IvanCraft623 requested a review from a team August 18, 2024 15:58
github-actions[bot]
github-actions bot previously approved these changes Sep 1, 2024
github-actions[bot]
github-actions bot previously approved these changes Sep 1, 2024
@ipad54
Copy link
Member

ipad54 commented Sep 1, 2024

For posterity: firework rocket entity also has a long metadata property ATTACHED_ENTITY_ID with ID 18 (Bedrock also has MINECART_HAS_DISPLAY boolean property with the same id, but it's inconsistency in the game itself). This property is used for elytra boosting: the firework rocket will start to follow the attached entity and give it a movement boost if it glides.

We don't have elytras implemented right now so I think we don't have to bother about this and the PR looks finished for me.

Joshy3282 added a commit to Joshy3282/PocketMine-MP that referenced this pull request Oct 2, 2024

/**
* TODO: The entity should be saved and loaded, but this is not possible.
* @see https://bugs.mojang.com/browse/MCPE-165230
Copy link
Member

Choose a reason for hiding this comment

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

Not liking this. We should still save & restore them in PM, regardless of vanilla bugs that don't store them.

/**
* Returns maximum number of ticks this will live for.
*/
public function getLifeTicks() : int{
Copy link
Member

Choose a reason for hiding this comment

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

getMaxAgeTicks() would be more clear IMO

*
* @return $this
*/
public function setLifeTicks(int $lifeTicks) : self{
Copy link
Member

Choose a reason for hiding this comment

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

ditto here

Comment on lines +100 to +108
$position = match($face){
Facing::DOWN => $position->add(0, -$correction, 0),
Facing::UP => $position->add(0, $correction, 0),
Facing::NORTH => $position->add(0, 0, -$correction),
Facing::SOUTH => $position->add(0, 0, $correction),
Facing::WEST => $position->add(-$correction, 0, 0),
Facing::EAST => $position->add($correction, 0, 0),
default => throw new AssumptionFailedError("Invalid facing $face")
};
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
$position = match($face){
Facing::DOWN => $position->add(0, -$correction, 0),
Facing::UP => $position->add(0, $correction, 0),
Facing::NORTH => $position->add(0, 0, -$correction),
Facing::SOUTH => $position->add(0, 0, $correction),
Facing::WEST => $position->add(-$correction, 0, 0),
Facing::EAST => $position->add($correction, 0, 0),
default => throw new AssumptionFailedError("Invalid facing $face")
};
$position = $position->add(Vector3::zero()->getSide($face)->multiply($correction));

If we allowed getSide() to accept float values, this would be even simpler.

Copy link
Member

Choose a reason for hiding this comment

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

Related to pmmp/Math#86

default => throw new AssumptionFailedError("Invalid facing $face")
};

$randomDuration = (($this->flightDurationMultiplier + 1) * 10) + mt_rand(0, 12);
Copy link
Member

Choose a reason for hiding this comment

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

Prefer if these magic numbers were moved to constants.

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 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.

5 participants