Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Expose power on fireballs

Open TonytheMacaroni opened this issue 2 years ago • 1 comments

Fixes #10186.

~~Patch previously modified the power of the projectile, which actually controls how fast it accelerates. It now uses AbstractHurtingProjectile#setDirection, which also sets the power, but uses the default magnitude of 0.1.~~

~~Considered also directly exposing the power, but was unsure exactly on the best approach of implementing it. AbstractHurtingProjectile#setDirection assumes a magnitude of 0.1, which would need changing if power could be changed. Could either calculate the magnitude from the current power on setting direction, which would need some consideration for when the projectile is created, or including a field for it that's set when the power is modified.~~

Now entirely reverts the original patch, and adds a javadoc comment to Fireball#setVelocity to note that fireballs accelerate in the direction of their power. Also added Fireball#setPower and Fireball#getPower to control the power of the projectile. Currently Fireball#getDirection and Fireball#getPower do the same thing - should I remove Fireball#getPower or deprecate Fireball#getDirection for its misleading name?

TonytheMacaroni avatar Mar 06 '24 00:03 TonytheMacaroni

~~On second thought, is setting the direction when you set the velocity even a sensible thing to do? Perhaps just a javadoc note on Fireball#setVelocity is necessary to clarify that setting the velocity does not change the direction the fireball accelerates?~~ Ended up doing this.

TonytheMacaroni avatar Mar 06 '24 01:03 TonytheMacaroni