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,11 +1,12 @@
--- a/net/minecraft/world/entity/EntityExperienceOrb.java
+++ b/net/minecraft/world/entity/EntityExperienceOrb.java
@@ -21,6 +21,13 @@
@@ -21,6 +21,14 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.player.PlayerExpCooldownChangeEvent;
@@ -14,7 +15,7 @@
public class EntityExperienceOrb extends Entity {
private static final int LIFETIME = 6000;
@@ -59,6 +66,7 @@
@@ -59,6 +67,7 @@
@Override
public void tick() {
super.tick();
@@ -22,7 +23,7 @@
this.xo = this.getX();
this.yo = this.getY();
this.zo = this.getZ();
@@ -84,7 +92,22 @@
@@ -84,7 +93,22 @@
this.followingPlayer = null;
}
@@ -46,7 +47,34 @@
Vec3D vec3d = new Vec3D(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ());
double d0 = vec3d.lengthSqr();
@@ -227,12 +250,12 @@
@@ -109,7 +133,7 @@
++this.age;
if (this.age >= 6000) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
}
}
@@ -178,7 +202,7 @@
private void merge(EntityExperienceOrb entityexperienceorb) {
this.count += entityexperienceorb.count;
this.age = Math.min(this.age, entityexperienceorb.age);
- entityexperienceorb.discard();
+ entityexperienceorb.discard(EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause
}
private void setUnderwaterMovement() {
@@ -200,7 +224,7 @@
this.markHurt();
this.health = (int) ((float) this.health - f);
if (this.health <= 0) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
}
return true;
@@ -227,17 +251,17 @@
public void playerTouch(EntityHuman entityhuman) {
if (!this.level().isClientSide) {
if (entityhuman.takeXpDelay == 0) {
@@ -61,7 +89,13 @@
}
--this.count;
@@ -250,9 +273,17 @@
if (this.count == 0) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
}
}
@@ -250,9 +274,17 @@
if (entry != null) {
ItemStack itemstack = (ItemStack) entry.getValue();
int j = Math.min(this.xpToDurability(i), itemstack.getDamageValue());
@@ -79,7 +113,7 @@
return k > 0 ? this.repairPlayerItems(entityhuman, k) : 0;
} else {
@@ -277,6 +308,24 @@
@@ -277,6 +309,24 @@
}
public static int getExperienceValue(int i) {