craftbukkit/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch

103 lines
3.8 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/projectile/EntityShulkerBullet.java
+++ b/net/minecraft/world/entity/projectile/EntityShulkerBullet.java
2024-06-14 01:05:00 +10:00
@@ -32,6 +32,10 @@
import net.minecraft.world.phys.MovingObjectPositionEntity;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityShulkerBullet extends IProjectile {
private static final double SPEED = 0.15D;
2024-06-14 01:05:00 +10:00
@@ -60,8 +64,21 @@
2021-06-11 15:00:00 +10:00
this.finalTarget = entity;
this.currentMoveDirection = EnumDirection.UP;
2021-11-22 09:00:00 +11:00
this.selectNextMoveDirection(enumdirection_enumaxis);
2016-03-01 08:32:46 +11:00
+ projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
2023-09-22 02:57:13 +10:00
+ }
+
+ // CraftBukkit start
+ public Entity getTarget() {
2021-06-11 15:00:00 +10:00
+ return this.finalTarget;
}
+ public void setTarget(Entity e) {
2021-06-11 15:00:00 +10:00
+ this.finalTarget = e;
+ this.currentMoveDirection = EnumDirection.UP;
2021-11-22 09:00:00 +11:00
+ this.selectNextMoveDirection(EnumDirection.EnumAxis.X);
+ }
+ // CraftBukkit end
+
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public SoundCategory getSoundSource() {
return SoundCategory.HOSTILE;
2024-06-14 01:05:00 +10:00
@@ -194,7 +211,7 @@
@Override
public void checkDespawn() {
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
}
}
2024-06-14 01:05:00 +10:00
@@ -230,7 +247,7 @@
2023-06-08 01:30:00 +10:00
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
2024-04-24 01:15:00 +10:00
- this.hitTargetOrDeflectSelf(movingobjectposition);
+ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event
}
}
2024-06-14 01:05:00 +10:00
@@ -307,7 +324,7 @@
2020-06-25 10:00:00 +10:00
if (entity instanceof EntityLiving) {
2023-03-15 03:30:00 +11:00
EntityLiving entityliving1 = (EntityLiving) entity;
- entityliving1.addEffect(new MobEffect(MobEffects.LEVITATION, 200), (Entity) MoreObjects.firstNonNull(entity1, this));
+ entityliving1.addEffect(new MobEffect(MobEffects.LEVITATION, 200), (Entity) MoreObjects.firstNonNull(entity1, this), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
2020-06-25 10:00:00 +10:00
}
2024-06-14 01:05:00 +10:00
@@ -321,14 +338,20 @@
}
private void destroy() {
- this.discard();
+ // CraftBukkit start - add Bukkit remove cause
+ this.destroy(null);
+ }
+
+ private void destroy(EntityRemoveEvent.Cause cause) {
+ this.discard(cause);
+ // CraftBukkit end
2024-04-24 01:15:00 +10:00
this.level().gameEvent((Holder) GameEvent.ENTITY_DAMAGE, this.position(), GameEvent.a.of((Entity) this));
}
@Override
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
- this.destroy();
+ this.destroy(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
@Override
2024-06-14 01:05:00 +10:00
@@ -338,10 +361,15 @@
@Override
2021-11-22 09:00:00 +11:00
public boolean hurt(DamageSource damagesource, float f) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) {
+ return false;
+ }
+ // CraftBukkit end
2023-06-08 01:30:00 +10:00
if (!this.level().isClientSide) {
2021-06-11 15:00:00 +10:00
this.playSound(SoundEffects.SHULKER_BULLET_HURT, 1.0F, 1.0F);
2023-06-08 01:30:00 +10:00
((WorldServer) this.level()).sendParticles(Particles.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D);
- this.destroy();
+ this.destroy(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
}
return true;