SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, #1008: Add EntityRemoveEvent

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2024-02-21 20:55:34 +11:00
parent 6dc11b5d28
commit 64cd2b148a
81 changed files with 2037 additions and 475 deletions

View File

@@ -1,19 +1,20 @@
--- a/net/minecraft/world/entity/projectile/EntityArrow.java
+++ b/net/minecraft/world/entity/projectile/EntityArrow.java
@@ -47,6 +47,12 @@
@@ -47,6 +47,13 @@
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.phys.shapes.VoxelShape;
+// CraftBukkit start
+import net.minecraft.world.entity.item.EntityItem;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.player.PlayerPickupArrowEvent;
+// CraftBukkit end
+
public abstract class EntityArrow extends IProjectile {
private static final double ARROW_BASE_DAMAGE = 2.0D;
@@ -219,7 +225,7 @@
@@ -219,7 +226,7 @@
}
if (object != null && !flag) {
@@ -22,7 +23,25 @@
this.hasImpulse = true;
}
@@ -367,7 +373,13 @@
@@ -304,7 +311,7 @@
protected void tickDespawn() {
++this.life;
if (this.life >= 1200) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
}
}
@@ -337,7 +344,7 @@
}
if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
return;
}
@@ -367,7 +374,13 @@
boolean flag1 = entity.getType().is(TagsEntity.DEFLECTS_ARROWS);
if (this.isOnFire() && !flag && !flag1) {
@@ -37,7 +56,25 @@
}
if (entity.hurt(damagesource, (float) i)) {
@@ -545,7 +557,22 @@
@@ -418,7 +431,7 @@
this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
if (this.getPierceLevel() <= 0) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
} else if (flag1) {
this.deflect();
@@ -432,7 +445,7 @@
this.spawnAtLocation(this.getPickupItem(), 0.1F);
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}
@@ -545,9 +558,24 @@
@Override
public void playerTouch(EntityHuman entityhuman) {
if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) {
@@ -59,5 +96,8 @@
+ if ((this.pickup == EntityArrow.PickupStatus.ALLOWED && entityhuman.getInventory().add(itemstack)) || (this.pickup == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.getAbilities().instabuild)) {
+ // CraftBukkit end
entityhuman.take(this, 1);
this.discard();
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
}
}

View File

@@ -0,0 +1,22 @@
--- a/net/minecraft/world/entity/projectile/EntityDragonFireball.java
+++ b/net/minecraft/world/entity/projectile/EntityDragonFireball.java
@@ -15,6 +15,10 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityDragonFireball extends EntityFireball {
public static final float SPLASH_RANGE = 4.0F;
@@ -61,7 +65,7 @@
this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
this.level().addFreshEntity(entityareaeffectcloud);
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityEgg.java
+++ b/net/minecraft/world/entity/projectile/EntityEgg.java
@@ -11,6 +11,15 @@
@@ -11,6 +11,16 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
@@ -10,13 +10,14 @@
+import org.bukkit.entity.Ageable;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.player.PlayerEggThrowEvent;
+// CraftBukkit end
+
public class EntityEgg extends EntityProjectileThrowable {
public EntityEgg(EntityTypes<? extends EntityEgg> entitytypes, World world) {
@@ -47,20 +56,47 @@
@@ -47,26 +57,53 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {
@@ -69,3 +70,10 @@
}
}
}
this.level().broadcastEntityEvent(this, (byte) 3);
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java
+++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java
@@ -18,6 +18,13 @@
@@ -18,6 +18,14 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
@@ -8,13 +8,14 @@
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
+
public class EntityEnderPearl extends EntityProjectileThrowable {
public EntityEnderPearl(EntityTypes<? extends EntityEnderPearl> entitytypes, World world) {
@@ -54,23 +61,34 @@
@@ -54,23 +62,34 @@
EntityPlayer entityplayer = (EntityPlayer) entity;
if (entityplayer.connection.isAcceptingMessages() && entityplayer.level() == this.level() && !entityplayer.isSleeping()) {
@@ -62,7 +63,25 @@
this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_TELEPORT, SoundCategory.PLAYERS);
}
} else if (entity != null) {
@@ -100,7 +118,7 @@
@@ -78,7 +97,7 @@
entity.resetFallDistance();
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}
@@ -88,7 +107,7 @@
Entity entity = this.getOwner();
if (entity instanceof EntityPlayer && !entity.isAlive() && this.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else {
super.tick();
}
@@ -100,7 +119,7 @@
public Entity changeDimension(WorldServer worldserver) {
Entity entity = this.getOwner();

View File

@@ -1,6 +1,17 @@
--- a/net/minecraft/world/entity/projectile/EntityEnderSignal.java
+++ b/net/minecraft/world/entity/projectile/EntityEnderSignal.java
@@ -35,7 +35,7 @@
@@ -16,6 +16,10 @@
import net.minecraft.world.level.World;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityEnderSignal extends Entity implements ItemSupplier {
private static final DataWatcherObject<ItemStack> DATA_ITEM_STACK = DataWatcher.defineId(EntityEnderSignal.class, DataWatcherRegistry.ITEM_STACK);
@@ -35,7 +39,7 @@
}
public void setItem(ItemStack itemstack) {
@@ -9,7 +20,16 @@
this.getEntityData().set(EntityEnderSignal.DATA_ITEM_STACK, itemstack.copyWithCount(1));
}
@@ -177,7 +177,7 @@
@@ -150,7 +154,7 @@
++this.life;
if (this.life > 80 && !this.level().isClientSide) {
this.playSound(SoundEffects.ENDER_EYE_DEATH, 1.0F, 1.0F);
- this.discard();
+ this.discard(this.surviveAfterDeath ? EntityRemoveEvent.Cause.DROP : EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
if (this.surviveAfterDeath) {
this.level().addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), this.getItem()));
} else {
@@ -177,7 +181,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("Item"));

View File

@@ -1,6 +1,26 @@
--- a/net/minecraft/world/entity/projectile/EntityEvokerFangs.java
+++ b/net/minecraft/world/entity/projectile/EntityEvokerFangs.java
@@ -129,7 +129,7 @@
@@ -14,6 +14,10 @@
import net.minecraft.world.entity.TraceableEntity;
import net.minecraft.world.level.World;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityEvokerFangs extends Entity implements TraceableEntity {
public static final int ATTACK_DURATION = 20;
@@ -118,7 +122,7 @@
}
if (--this.lifeTicks < 0) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
}
}
@@ -129,7 +133,7 @@
if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) {
if (entityliving1 == null) {

View File

@@ -1,10 +1,13 @@
--- a/net/minecraft/world/entity/projectile/EntityFireball.java
+++ b/net/minecraft/world/entity/projectile/EntityFireball.java
@@ -17,11 +17,15 @@
@@ -17,11 +17,18 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public abstract class EntityFireball extends IProjectile {
@@ -16,7 +19,7 @@
protected EntityFireball(EntityTypes<? extends EntityFireball> entitytypes, World world) {
super(entitytypes, world);
@@ -36,6 +40,12 @@
@@ -36,6 +43,12 @@
this(entitytypes, world);
this.moveTo(d0, d1, d2, this.getYRot(), this.getXRot());
this.reapplyPosition();
@@ -29,7 +32,16 @@
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
if (d6 != 0.0D) {
@@ -86,7 +96,13 @@
@@ -76,7 +89,7 @@
Entity entity = this.getOwner();
if (!this.level().isClientSide && (entity != null && entity.isRemoved() || !this.level().hasChunkAt(this.blockPosition()))) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else {
super.tick();
if (this.shouldBurn()) {
@@ -86,7 +99,13 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType());
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
@@ -44,7 +56,7 @@
}
this.checkInsideBlocks();
@@ -184,6 +200,11 @@
@@ -184,6 +203,11 @@
if (entity != null) {
if (!this.level().isClientSide) {

View File

@@ -1,6 +1,17 @@
--- a/net/minecraft/world/entity/projectile/EntityFireworks.java
+++ b/net/minecraft/world/entity/projectile/EntityFireworks.java
@@ -143,7 +143,7 @@
@@ -28,6 +28,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 EntityFireworks extends IProjectile implements ItemSupplier {
public static final DataWatcherObject<ItemStack> DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK);
@@ -143,7 +147,7 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
if (!this.noPhysics) {
@@ -9,7 +20,7 @@
this.hasImpulse = true;
}
@@ -158,7 +158,11 @@
@@ -158,7 +162,11 @@
}
if (!this.level().isClientSide && this.life > this.lifetime) {
@@ -22,7 +33,15 @@
}
}
@@ -174,7 +178,11 @@
@@ -167,14 +175,18 @@
this.level().broadcastEntityEvent(this, (byte) 17);
this.gameEvent(GameEvent.EXPLODE, this.getOwner());
this.dealExplosionDamage();
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
}
@Override
protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {
super.onHitEntity(movingobjectpositionentity);
if (!this.level().isClientSide) {
@@ -35,7 +54,7 @@
}
}
@@ -184,7 +192,11 @@
@@ -184,7 +196,11 @@
this.level().getBlockState(blockposition).entityInside(this.level(), blockposition, this);
if (!this.level().isClientSide() && this.hasExplosion()) {

View File

@@ -1,19 +1,20 @@
--- a/net/minecraft/world/entity/projectile/EntityFishingHook.java
+++ b/net/minecraft/world/entity/projectile/EntityFishingHook.java
@@ -46,6 +46,12 @@
@@ -46,6 +46,13 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.entity.FishHook;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.player.PlayerFishEvent;
+// CraftBukkit end
+
public class EntityFishingHook extends IProjectile {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -67,6 +73,18 @@
@@ -67,6 +74,18 @@
private final int luck;
private final int lureSpeed;
@@ -32,7 +33,31 @@
private EntityFishingHook(EntityTypes<? extends EntityFishingHook> entitytypes, World world, int i, int j) {
super(entitytypes, world);
this.syncronizedRandom = RandomSource.create();
@@ -261,7 +279,7 @@
@@ -147,12 +166,12 @@
EntityHuman entityhuman = this.getPlayerOwner();
if (entityhuman == null) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else if (this.level().isClientSide || !this.shouldStopFishing(entityhuman)) {
if (this.onGround()) {
++this.life;
if (this.life >= 1200) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
} else {
@@ -253,7 +272,7 @@
if (!entityhuman.isRemoved() && entityhuman.isAlive() && (flag || flag1) && this.distanceToSqr((Entity) entityhuman) <= 1024.0D) {
return false;
} else {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return true;
}
}
@@ -261,7 +280,7 @@
private void checkCollision() {
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
@@ -41,7 +66,7 @@
}
@Override
@@ -294,11 +312,11 @@
@@ -294,11 +313,11 @@
int i = 1;
BlockPosition blockposition1 = blockposition.above();
@@ -55,7 +80,7 @@
--i;
}
@@ -308,6 +326,10 @@
@@ -308,6 +327,10 @@
this.timeUntilLured = 0;
this.timeUntilHooked = 0;
this.getEntityData().set(EntityFishingHook.DATA_BITING, false);
@@ -66,7 +91,7 @@
}
} else {
float f;
@@ -341,6 +363,13 @@
@@ -341,6 +364,13 @@
worldserver.sendParticles(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D);
}
} else {
@@ -80,7 +105,7 @@
this.playSound(SoundEffects.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
double d3 = this.getY() + 0.5D;
@@ -373,12 +402,16 @@
@@ -373,12 +403,16 @@
}
if (this.timeUntilLured <= 0) {
@@ -101,7 +126,7 @@
}
}
@@ -445,6 +478,14 @@
@@ -445,6 +479,14 @@
int i = 0;
if (this.hookedIn != null) {
@@ -116,7 +141,7 @@
this.pullEntity(this.hookedIn);
CriterionTriggers.FISHING_ROD_HOOKED.trigger((EntityPlayer) entityhuman, itemstack, this, Collections.emptyList());
this.level().broadcastEntityEvent(this, (byte) 31);
@@ -460,6 +501,15 @@
@@ -460,6 +502,15 @@
while (iterator.hasNext()) {
ItemStack itemstack1 = (ItemStack) iterator.next();
EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1);
@@ -132,7 +157,7 @@
double d0 = entityhuman.getX() - this.getX();
double d1 = entityhuman.getY() - this.getY();
double d2 = entityhuman.getZ() - this.getZ();
@@ -467,7 +517,11 @@
@@ -467,7 +518,11 @@
entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
this.level().addFreshEntity(entityitem);
@@ -145,7 +170,7 @@
if (itemstack1.is(TagsItem.FISHES)) {
entityhuman.awardStat(StatisticList.FISH_CAUGHT, 1);
}
@@ -477,8 +531,25 @@
@@ -477,10 +532,27 @@
}
if (this.onGround()) {
@@ -169,5 +194,25 @@
+ }
+ // CraftBukkit end
this.discard();
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return i;
} else {
return 0;
@@ -513,8 +585,15 @@
@Override
public void remove(Entity.RemovalReason entity_removalreason) {
+ // CraftBukkit start - add Bukkit remove cause
+ this.remove(entity_removalreason, null);
+ }
+
+ @Override
+ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
+ // CraftBukkit end
this.updateOwnerInfo((EntityFishingHook) null);
- super.remove(entity_removalreason);
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
}
@Override

View File

@@ -1,10 +1,13 @@
--- a/net/minecraft/world/entity/projectile/EntityLargeFireball.java
+++ b/net/minecraft/world/entity/projectile/EntityLargeFireball.java
@@ -9,17 +9,21 @@
@@ -9,17 +9,24 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityLargeFireball extends EntityFireballFireball {
@@ -22,11 +25,12 @@
}
@Override
@@ -28,7 +32,15 @@
@@ -28,8 +35,16 @@
if (!this.level().isClientSide) {
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionPower, flag, World.a.MOB);
- this.discard();
+ // CraftBukkit start - fire ExplosionPrimeEvent
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
+ this.level().getCraftServer().getPluginManager().callEvent(event);
@@ -36,10 +40,11 @@
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ }
+ // CraftBukkit end
this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
@@ -59,7 +71,8 @@
}
@@ -59,7 +74,8 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("ExplosionPower", 99)) {

View File

@@ -1,6 +1,17 @@
--- a/net/minecraft/world/entity/projectile/EntityLlamaSpit.java
+++ b/net/minecraft/world/entity/projectile/EntityLlamaSpit.java
@@ -32,7 +32,7 @@
@@ -14,6 +14,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 EntityLlamaSpit extends IProjectile {
public EntityLlamaSpit(EntityTypes<? extends EntityLlamaSpit> entitytypes, World world) {
@@ -32,7 +36,7 @@
Vec3D vec3d = this.getDeltaMovement();
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
@@ -9,3 +20,24 @@
double d0 = this.getX() + vec3d.x;
double d1 = this.getY() + vec3d.y;
double d2 = this.getZ() + vec3d.z;
@@ -42,9 +46,9 @@
float f1 = 0.06F;
if (this.level().getBlockStates(this.getBoundingBox()).noneMatch(BlockBase.BlockData::isAir)) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else if (this.isInWaterOrBubble()) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else {
this.setDeltaMovement(vec3d.scale(0.9900000095367432D));
if (!this.isNoGravity()) {
@@ -72,7 +76,7 @@
protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) {
super.onHitBlock(movingobjectpositionblock);
if (!this.level().isClientSide) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityPotion.java
+++ b/net/minecraft/world/entity/projectile/EntityPotion.java
@@ -31,6 +31,17 @@
@@ -31,6 +31,18 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.MovingObjectPositionEntity;
@@ -13,12 +13,13 @@
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityPotion extends EntityProjectileThrowable implements ItemSupplier {
public static final double SPLASH_RANGE = 4.0D;
@@ -99,11 +110,11 @@
@@ -99,18 +111,18 @@
if (flag) {
this.applyWater();
@@ -33,7 +34,15 @@
}
}
@@ -145,9 +156,10 @@
int i = potionregistry.hasInstantEffects() ? 2007 : 2002;
this.level().levelEvent(i, this.blockPosition(), PotionUtil.getColor(itemstack));
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}
@@ -145,9 +157,10 @@
}
@@ -45,7 +54,7 @@
if (!list1.isEmpty()) {
Entity entity1 = this.getEffectSource();
@@ -168,24 +180,49 @@
@@ -168,24 +181,49 @@
d1 = 1.0D - Math.sqrt(d0) / 4.0D;
}
@@ -110,7 +119,7 @@
}
}
}
@@ -194,7 +231,7 @@
@@ -194,7 +232,7 @@
}
@@ -119,7 +128,7 @@
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
Entity entity = this.getOwner();
@@ -221,7 +258,14 @@
@@ -221,7 +259,14 @@
entityareaeffectcloud.setFixedColor(nbttagcompound.getInt("CustomPotionColor"));
}
@@ -129,13 +138,13 @@
+ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) {
+ this.level().addFreshEntity(entityareaeffectcloud);
+ } else {
+ entityareaeffectcloud.discard();
+ entityareaeffectcloud.discard(null); // CraftBukkit - add Bukkit remove cause
+ }
+ // CraftBukkit end
}
public boolean isLingering() {
@@ -232,13 +276,25 @@
@@ -232,13 +277,25 @@
IBlockData iblockdata = this.level().getBlockState(blockposition);
if (iblockdata.is(TagsBlock.FIRE)) {

View File

@@ -1,6 +1,17 @@
--- a/net/minecraft/world/entity/projectile/EntityShulkerBullet.java
+++ b/net/minecraft/world/entity/projectile/EntityShulkerBullet.java
@@ -60,7 +60,20 @@
@@ -29,6 +29,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,8 +64,21 @@
this.finalTarget = entity;
this.currentMoveDirection = EnumDirection.UP;
this.selectNextMoveDirection(enumdirection_enumaxis);
@@ -10,18 +21,28 @@
+ // 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() {
@@ -225,7 +238,7 @@
return SoundCategory.HOSTILE;
@@ -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
}
}
@@ -225,7 +242,7 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
@@ -30,7 +51,7 @@
}
}
@@ -294,7 +307,7 @@
@@ -294,7 +311,7 @@
if (entity instanceof EntityLiving) {
EntityLiving entityliving1 = (EntityLiving) entity;
@@ -39,7 +60,30 @@
}
}
@@ -325,6 +338,11 @@
@@ -308,14 +325,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
@@ -325,10 +348,15 @@
@Override
public boolean hurt(DamageSource damagesource, float f) {
@@ -51,3 +95,8 @@
if (!this.level().isClientSide) {
this.playSound(SoundEffects.SHULKER_BULLET_HURT, 1.0F, 1.0F);
((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;

View File

@@ -1,15 +1,18 @@
--- a/net/minecraft/world/entity/projectile/EntitySmallFireball.java
+++ b/net/minecraft/world/entity/projectile/EntitySmallFireball.java
@@ -13,6 +13,8 @@
@@ -13,6 +13,11 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.MovingObjectPositionEntity;
+import org.bukkit.event.entity.EntityCombustByEntityEvent; // CraftBukkit
+// CraftBukkit start
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntitySmallFireball extends EntityFireballFireball {
public EntitySmallFireball(EntityTypes<? extends EntitySmallFireball> entitytypes, World world) {
@@ -21,6 +23,11 @@
@@ -21,6 +26,11 @@
public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world);
@@ -21,7 +24,7 @@
}
public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) {
@@ -35,7 +42,14 @@
@@ -35,7 +45,14 @@
Entity entity1 = this.getOwner();
int i = entity.getRemainingFireTicks();
@@ -37,7 +40,7 @@
if (!entity.hurt(this.damageSources().fireball(this, entity1), 5.0F)) {
entity.setRemainingFireTicks(i);
} else if (entity1 instanceof EntityLiving) {
@@ -51,10 +65,10 @@
@@ -51,10 +68,10 @@
if (!this.level().isClientSide) {
Entity entity = this.getOwner();
@@ -50,3 +53,12 @@
this.level().setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level(), blockposition));
}
}
@@ -66,7 +83,7 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}

View File

@@ -0,0 +1,22 @@
--- a/net/minecraft/world/entity/projectile/EntitySnowball.java
+++ b/net/minecraft/world/entity/projectile/EntitySnowball.java
@@ -14,6 +14,10 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntitySnowball extends EntityProjectileThrowable {
public EntitySnowball(EntityTypes<? extends EntitySnowball> entitytypes, World world) {
@@ -65,7 +69,7 @@
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {
this.level().broadcastEntityEvent(this, (byte) 3);
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}

View File

@@ -1,6 +1,17 @@
--- a/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java
+++ b/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java
@@ -39,9 +39,18 @@
@@ -11,6 +11,10 @@
import net.minecraft.world.level.World;
import net.minecraft.world.phys.MovingObjectPosition;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityThrownExpBottle extends EntityProjectileThrowable {
public EntityThrownExpBottle(EntityTypes<? extends EntityThrownExpBottle> entitytypes, World world) {
@@ -39,11 +43,20 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (this.level() instanceof WorldServer) {
@@ -18,5 +29,8 @@
+ // CraftBukkit end
+
EntityExperienceOrb.award((WorldServer) this.level(), this.position(), i);
this.discard();
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}

View File

@@ -1,6 +1,26 @@
--- a/net/minecraft/world/entity/projectile/EntityThrownTrident.java
+++ b/net/minecraft/world/entity/projectile/EntityThrownTrident.java
@@ -153,7 +153,7 @@
@@ -24,6 +24,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 EntityThrownTrident extends EntityArrow {
private static final DataWatcherObject<Byte> ID_LOYALTY = DataWatcher.defineId(EntityThrownTrident.class, DataWatcherRegistry.BYTE);
@@ -64,7 +68,7 @@
this.spawnAtLocation(this.getPickupItem(), 0.1F);
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
} else {
this.setNoPhysics(true);
Vec3D vec3d = entity.getEyePosition().subtract(this.position());
@@ -153,7 +157,7 @@
if (entitylightning != null) {
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
entitylightning.setCause(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null);

View File

@@ -1,17 +1,18 @@
--- a/net/minecraft/world/entity/projectile/EntityWitherSkull.java
+++ b/net/minecraft/world/entity/projectile/EntityWitherSkull.java
@@ -21,6 +21,10 @@
@@ -21,6 +21,11 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityWitherSkull extends EntityFireball {
private static final DataWatcherObject<Boolean> DATA_DANGEROUS = DataWatcher.defineId(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN);
@@ -64,7 +68,7 @@
@@ -64,7 +69,7 @@
if (entity.isAlive()) {
this.doEnchantDamageEffects(entityliving, entity);
} else {
@@ -20,7 +21,7 @@
}
}
} else {
@@ -82,7 +86,7 @@
@@ -82,7 +87,7 @@
}
if (b0 > 0) {
@@ -29,11 +30,12 @@
}
}
@@ -93,7 +97,15 @@
@@ -93,8 +98,16 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, World.a.MOB);
- this.discard();
+ // CraftBukkit start
+ // this.level().explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, World.a.MOB);
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false);
@@ -43,6 +45,7 @@
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ }
+ // CraftBukkit end
this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}

View File

@@ -1,6 +1,17 @@
--- a/net/minecraft/world/entity/projectile/WindCharge.java
+++ b/net/minecraft/world/entity/projectile/WindCharge.java
@@ -81,7 +81,7 @@
@@ -22,6 +22,10 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.MovingObjectPositionEntity;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class WindCharge extends EntityFireball implements ItemSupplier {
public static final WindCharge.a EXPLOSION_DAMAGE_CALCULATOR = new WindCharge.a();
@@ -81,7 +85,7 @@
}
}
@@ -9,3 +20,20 @@
this.level().explode(this, (DamageSource) null, WindCharge.EXPLOSION_DAMAGE_CALCULATOR, this.getX(), this.getY(), this.getZ(), (float) (3.0D + this.random.nextDouble()), false, World.a.BLOW, Particles.GUST, Particles.GUST_EMITTER, SoundEffects.WIND_BURST);
}
@@ -89,14 +93,14 @@
protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) {
super.onHitBlock(movingobjectpositionblock);
this.explode();
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
@Override
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}