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 Trident #4547

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

Implement Trident #4547

wants to merge 8 commits into from

Conversation

IvanCraft623
Copy link
Member

@IvanCraft623 IvanCraft623 commented Nov 5, 2021

Introduction

Implements item and trident projectile.

Changes

API changes

Projectile::onHit() now returns Vector3 representing the new projectile motion.

Behavioural changes

Projectile::onHitEntity() no longer flags the projectile for despawn, child classes decide whether the entity should be despawned.

Follow-up

Implement enchantments
Implement custom death attack message for thrown tridents

Requires translations:

TODO

Name Value in eng.ini
death.attack.thrownTrident {%0} was impaled to death by {%1}

Tests

https://youtu.be/y__tfdHA3FE

@ghost
Copy link

ghost commented Nov 6, 2021

Trident enchantments?

@ghost
Copy link

ghost commented Dec 3, 2021

@dktapps When you merged it? It's really good implementation.

I thought that it must be in PocketMine-MP

@dktapps dktapps changed the base branch from master to next-major December 29, 2021 21:56
@IvanCraft623
Copy link
Member Author

oh no!

@dktapps
Copy link
Member

dktapps commented Jan 3, 2022

That's a github bug, don't worry about it.

@dktapps dktapps added Category: Gameplay Related to Minecraft gameplay experience Type: Contribution labels Jan 18, 2022
@IvanCraft623
Copy link
Member Author

I will take up this PR when I have time.

@IvanCraft623 IvanCraft623 reopened this Oct 29, 2022
@IvanCraft623 IvanCraft623 changed the base branch from next-major to next-minor October 29, 2022 18:11
@IvanCraft623 IvanCraft623 changed the base branch from next-minor to next-major October 29, 2022 20:06
@IvanCraft623
Copy link
Member Author

Trident enchantments?

Enchantments will be implemented in a separate PR:

@dktapps dktapps added Type: Enhancement Contributes features or other improvements to PocketMine-MP and removed Type: Contribution labels Nov 26, 2022
@IvanCraft623 IvanCraft623 changed the title Trident implementation Implement Trident Dec 18, 2022
NhanAZ
NhanAZ previously approved these changes Mar 17, 2023
@dktapps
Copy link
Member

dktapps commented Feb 20, 2024

I don't love that we're breaking BC to implement this. Is there a way to do it while retaining BC?

@Gewinum

This comment was marked as off-topic.

@Gewinum

This comment was marked as off-topic.

@IvanCraft623

This comment was marked as off-topic.

@IvanCraft623
Copy link
Member Author

I don't love that we're breaking BC to implement this. Is there a way to do it while retaining BC?

The BC Break is to be able to modify the motion that the projectile will have when impacting a target, previously it was simply set to zero, but the trident has the fature of "bouncing" when hitting an entity. I thought of an alternative of something like getMotionOnHit(ProjectileHitEvent), but I disliked it and we already had onHit which does not have a return value.

@IvanCraft623
Copy link
Member Author

In its beginnings this PR did not contain BCBreak, this was done by creating a new trident inside onHitEntity() with the desired motion. But I discarded that because it felt hacky.

@dktapps
Copy link
Member

dktapps commented Feb 22, 2024

Seems to me like we should enable the use of setMotion in onHit, as that's the conventional way to set motion.

There's also a behavioural BC break wrt. the despawn behaviour when hitting objects. I'm not sure how we could make that non-BC-breaking.

@dktapps
Copy link
Member

dktapps commented Nov 14, 2024

I think we can avoid BC breaks:

  • For the post-hit velocity, either add a getPostHitVelocity(ProjectileHitEvent) : ?Vector3, or permit the use of setMotion() inside the onHit* handlers
  • For post-hit despawning, add despawnsOnHit() : bool or perhaps an onPostHit() : void that can be overridden by subclasses.

However, the branch will need to be rebased if we retarget this back to minor-next, since there's been stuff merged into it from major-next.

@IvanCraft623 IvanCraft623 changed the base branch from major-next to minor-next December 1, 2024 19:56
@IvanCraft623 IvanCraft623 requested a review from a team as a code owner December 1, 2024 19:56
@IvanCraft623 IvanCraft623 changed the base branch from minor-next to major-next December 1, 2024 20:25
pmmp-admin-bot[bot]
pmmp-admin-bot bot previously approved these changes Dec 2, 2024
@IvanCraft623 IvanCraft623 changed the base branch from major-next to minor-next December 2, 2024 01:38
@IvanCraft623 IvanCraft623 dismissed pmmp-admin-bot[bot]’s stale review December 2, 2024 01:38

The base branch was changed.

pmmp-admin-bot[bot]
pmmp-admin-bot bot previously approved these changes Dec 2, 2024
}

$item = Item::nbtDeserialize($itemTag);
if($item->isNull() || !$item instanceof TridentItem){
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to require this to be a TridentItem? It doesn't look like it needs any specific methods.

Copy link
Member Author

Choose a reason for hiding this comment

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

Consistency, if I do TridentEntity->getItem() I would expect a TridentItem.

src/entity/projectile/Projectile.php Outdated Show resolved Hide resolved
src/entity/projectile/Projectile.php Outdated Show resolved Hide resolved
src/item/Trident.php Show resolved Hide resolved
src/world/sound/TridentHitSound.php Outdated Show resolved Hide resolved
pmmp-admin-bot[bot]
pmmp-admin-bot bot previously approved these changes Dec 4, 2024
@@ -69,7 +69,6 @@ public function onReleaseUsing(Player $player, array &$returnedItems) : ItemUseR
$item = $entity->getItem();
$item->applyDamage(1);
Copy link
Member

Choose a reason for hiding this comment

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

I feel like it would make more sense to damage the item before passing it to TridentEntity constructor instead of having to get/set it here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC break Breaks API compatibility Category: Gameplay Related to Minecraft gameplay experience 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