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

Wind Charge Implementation #6427

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

Conversation

CJMustard1452
Copy link

Introduction

Implementation for the 1.21.0 Wind Charge

Relevant issues

N/A

Details

  • Non-iron doors and trapdoors are flipped.
  • Fence gates are flipped.
  • Buttons are pressed.
  • Levers are flipped.
  • Bells are rung and swung.
  • Chorus flowers and pointed dripstone blocks break, dropping in item form.
  • Lit candles (both standalone and on cake) are extinguished.

Wind charges can be deflected if hit with another projectile or a melee attack, similar to ghast fireballs.
Wind charges are distance attenuated by liquids such as water and lava. They also appear to fly in a straight line, similar to fireballs
Wind charges are set to despawn after five minuets due to the gravity less nature of the entity.

https://minecraft.wiki/w/Wind_Charge

Changes

One method has been added to pocketmine\block\Block:

	/**
	 * Called when this block is updated by a state altering projectile in the world.
	 *
	 * @param pocketmine\entity\projectile\Projectile $projectile The projectile affecting the block.
	 */
	public function onProjectileInteraction(pocketmine\entity\projectile\Projectile $projectile) : void {

	}

Both class' for the Wind Charge item and Projectile have been created:

  • pocketmine\entity\projectile\WindCharge.php
  • pocketmine\item\WindCharge.php

One class has been created to handle the wind charge explode particle:

  • pocketmine\world\particle\WindExplosionParticle.php

One class has been added to handle wind charge burst sound:

  • pocketmine/world/sound/WindChargeBurstSound.php

The Wind Charge has been implemented as a vanilla item.
The Wind Charge Entity has been implemented as an Entity.

API changes

N/A

Behavioural changes

N/A

Backwards compatibility

N/A

Follow-up

N/A

Tests

I tested this PR by doing the following (tick all that apply):

  • Writing PHPUnit tests (commit these in the tests/phpunit folder)
  • Playtesting using a Minecraft client (provide screenshots or a video)
  • Writing a test plugin (provide the code and sample output)
  • Other (provide details)

Behavior With Other Blocks

Behavior.mp4

Behavior With Players (shows less effective under water.)

minecraft-2024-06-26-02-45-54-online-video-cuttercom-1_T9Woq9fd.mp4

Behavior Multi Hit

Minecraft.2024-06-26.03-18-39.mp4

Copy link
Author

@CJMustard1452 CJMustard1452 left a comment

Choose a reason for hiding this comment

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

Newly re-based PR...

Copy link

@dadodasyra dadodasyra left a comment

Choose a reason for hiding this comment

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

Except this it looks good to me, I don't understand why does Github web preview looks like indentation is off but it seems not to.

src/world/sound/WindChargeBurstSound.php Show resolved Hide resolved
src/block/ChorusFlower.php Outdated Show resolved Hide resolved
src/entity/projectile/WindCharge.php Outdated Show resolved Hide resolved
src/item/WindCharge.php Outdated Show resolved Hide resolved
src/block/Candle.php Outdated Show resolved Hide resolved
@ipad54
Copy link
Member

ipad54 commented Aug 17, 2024

It's seems like fall distance compensation is missing.

In vanilla, a player launched by wind charges shot by a player accumulates fall damage only when falling below the Y level where the wind burst hit.

src/block/Candle.php Outdated Show resolved Hide resolved
src/block/CakeWithCandle.php Outdated Show resolved Hide resolved
@@ -91,4 +89,19 @@ public function onNearbyBlockChange() : void{
private function canBeSupportedAt(Block $block, int $face) : bool{
return $block->getAdjacentSupportType(Facing::opposite($face))->hasCenterSupport();
}

public function onProjectileInteraction(Projectile $projectile) : void{
if($projectile instanceof WindCharge) {
Copy link
Member

Choose a reason for hiding this comment

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

need to check if its not pressed

Copy link
Author

Choose a reason for hiding this comment

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

$this->pressed(); in this context, thereby extending the pushed duration if already down, I do not see a need to change this, thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

by checking that it is not activated, you will avoid extra sound.

Comment on lines +178 to +179
// This is to avoid calling Door::onProjectileInteraction() twice due to two tiles.
if($this->top) {
Copy link
Member

Choose a reason for hiding this comment

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

So, if the projectile hit the upper one, no toggle will be happened ?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, this is my best attempt at handling this issue, if it hits both blocks the door hits, (open, close)

Copy link
Member

Choose a reason for hiding this comment

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

Can be useful before toggling to check the other state. If its not the same as ours when projectile hits, we can ignore ? Just a theory

Copy link
Author

Choose a reason for hiding this comment

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

feels a little hacky to be honest

Copy link
Member

Choose a reason for hiding this comment

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

Maybe hacky but can avoid to have unexpected side effect if only the top block is hitten by the effect area.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, only checking the one half will cause bugs. It's the same as if a player were clicking the top or bottom half, so the logic should be basically the same.

Comment on lines 97 to 99
if($this->getTypeId() === BlockTypeIds::IRON_TRAPDOOR) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Would be better to moove it into the condition above?

@ShockedPlot7560
Copy link
Member

An additional comment: isn't it better to check whether it's a windcharge by the typeId rather than the instance?

@ShockedPlot7560 ShockedPlot7560 added Category: API Related to the plugin API Category: Gameplay Related to Minecraft gameplay experience Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Aug 19, 2024
}

public function onProjectileInteraction(Projectile $projectile) : void{
if($projectile instanceof WindCharge && $this->getTypeId() !== BlockTypeIds::IRON_TRAPDOOR){
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 the iron trapdoor check hardcoded in here.

}
}

public function toggle() : void {
Copy link
Member

Choose a reason for hiding this comment

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

This should be private or protected, making it public has implications beyond this PR's scope

}
}

public function toggle() : void {
Copy link
Member

Choose a reason for hiding this comment

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

This should be private or protected, making it public has implications beyond this PR's scope

}
}

public function toggle() : void {
Copy link
Member

Choose a reason for hiding this comment

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

This should be private or protected, making it public has implications beyond this PR's scope


public function onProjectileInteraction(Projectile $projectile) : void{
if($projectile instanceof WindCharge) {
if($this->getTypeId() === BlockTypeIds::IRON_DOOR) {
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 check, same as before with trapdoors

}
}

public function press() : void {
Copy link
Member

Choose a reason for hiding this comment

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

This should be private or protected, making it public has implications beyond this PR's scope

@@ -513,6 +513,15 @@ public function onScheduledUpdate() : void{

}

/**
* Called when this block is updated by a state altering projectile in the world.
Copy link
Member

Choose a reason for hiding this comment

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

This sentence doesn't mean anything to me. It doesn't tell me why an update was triggered, nor what kind of state alterations should take place.

The function is trying to look and sound generic, but it's not.
"interaction" is also too vague.

Copy link

github-actions bot commented Dec 6, 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.

@github-actions github-actions bot added the Stale label Dec 6, 2024
@dktapps dktapps self-assigned this Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: API Related to the plugin API Category: Gameplay Related to Minecraft gameplay experience 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.

5 participants