2025-03-26 03:05:00 +11:00

112 lines
4.4 KiB
Diff

--- a/net/minecraft/world/entity/projectile/EntityShulkerBullet.java
+++ b/net/minecraft/world/entity/projectile/EntityShulkerBullet.java
@@ -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;
@@ -60,7 +64,20 @@
this.finalTarget = entity;
this.currentMoveDirection = EnumDirection.UP;
this.selectNextMoveDirection(enumdirection_enumaxis);
+ projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
+ }
+
+ // CraftBukkit start
+ public Entity getTarget() {
+ return this.finalTarget;
+ }
+
+ public void setTarget(Entity e) {
+ this.finalTarget = e;
+ this.currentMoveDirection = EnumDirection.UP;
+ this.selectNextMoveDirection(EnumDirection.EnumAxis.X);
}
+ // CraftBukkit end
@Override
public SoundCategory getSoundSource() {
@@ -88,8 +105,8 @@
this.targetDeltaX = nbttagcompound.getDoubleOr("TXD", 0.0D);
this.targetDeltaY = nbttagcompound.getDoubleOr("TYD", 0.0D);
this.targetDeltaZ = nbttagcompound.getDoubleOr("TZD", 0.0D);
- this.currentMoveDirection = (EnumDirection) nbttagcompound.read("Dir", EnumDirection.LEGACY_ID_CODEC).orElse((Object) null);
- this.targetId = (UUID) nbttagcompound.read("Target", UUIDUtil.CODEC).orElse((Object) null);
+ this.currentMoveDirection = (EnumDirection) nbttagcompound.read("Dir", EnumDirection.LEGACY_ID_CODEC).orElse(null); // CraftBukkit - decompile error
+ this.targetId = (UUID) nbttagcompound.read("Target", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error
}
@Override
@@ -185,7 +202,7 @@
@Override
public void checkDespawn() {
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
}
}
@@ -231,7 +248,7 @@
}
if (movingobjectposition != null && this.isAlive() && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
- this.hitTargetOrDeflectSelf(movingobjectposition);
+ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event
}
ProjectileHelper.rotateTowardsMovement(this, 0.5F);
@@ -309,7 +326,7 @@
if (entity instanceof EntityLiving) {
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
}
}
@@ -323,14 +340,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
this.level().gameEvent(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
@@ -345,9 +368,14 @@
@Override
public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) {
+ return false;
+ }
+ // CraftBukkit end
this.playSound(SoundEffects.SHULKER_BULLET_HURT, 1.0F, 1.0F);
worldserver.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;
}