Correctly launch WindCharges (#11418)

The launch API on LivingEntity only respected the WindCharge type, not
its near-clone BreezeWindCharge.

This commit correctly accounts for BreezeWindCharge in
CraftLivingEntity.
This commit is contained in:
Bjarne Koll 2024-09-21 20:08:31 +02:00 committed by GitHub
parent d61175421d
commit 5bcb2ff9e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 37 additions and 16 deletions

View file

@ -515,7 +515,7 @@ index 6e2f91423371ead9890095cf4b1e2299c4dcba28..9d8f4b7176e60180565e3134a14ecf19
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 097f03c83a90f476b74834407d2dcd0e98fe010a..3210d7c9405a1a335ef92debf4d85957087bfcf3 100644
index 097f03c83a90f476b74834407d2dcd0e98fe010a..741cc56304005c48b26966f617d282bae7a87ee6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -596,7 +596,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@ -527,7 +527,28 @@ index 097f03c83a90f476b74834407d2dcd0e98fe010a..3210d7c9405a1a335ef92debf4d85957
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
if (LingeringPotion.class.isAssignableFrom(projectile)) {
launch = new net.minecraft.world.entity.projectile.ThrownPotion(world, this.getHandle());
@@ -650,7 +650,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@@ -622,10 +622,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
launch = new net.minecraft.world.entity.projectile.WitherSkull(world, this.getHandle(), vec);
} else if (DragonFireball.class.isAssignableFrom(projectile)) {
launch = new net.minecraft.world.entity.projectile.DragonFireball(world, this.getHandle(), vec);
- } else if (WindCharge.class.isAssignableFrom(projectile)) {
- launch = EntityType.WIND_CHARGE.create(world);
- ((net.minecraft.world.entity.projectile.windcharge.WindCharge) launch).setOwner(this.getHandle());
- ((net.minecraft.world.entity.projectile.windcharge.WindCharge) launch).assignDirectionalMovement(vec, 0.1D);
+ // Paper start - more projectile API - correctly launch wind charges
+ } else if (org.bukkit.entity.AbstractWindCharge.class.isAssignableFrom(projectile)) {
+ if (org.bukkit.entity.BreezeWindCharge.class.isAssignableFrom(projectile)) {
+ launch = EntityType.BREEZE_WIND_CHARGE.create(world);
+ } else {
+ launch = EntityType.WIND_CHARGE.create(world);
+ }
+ ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).setOwner(this.getHandle());
+ ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // Paper - copied from net.minecraft.world.item.WindChargeItem.use
+ // Paper end - more projectile API - correctly launch wind charges
} else {
launch = new LargeFireball(world, this.getHandle(), vec, 1);
}
@@ -650,7 +656,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} else if (Firework.class.isAssignableFrom(projectile)) {
Location location = this.getEyeLocation();