SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, #1008: Add EntityRemoveEvent
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/player/EntityHuman.java
|
||||
+++ b/net/minecraft/world/entity/player/EntityHuman.java
|
||||
@@ -112,6 +112,21 @@
|
||||
@@ -112,6 +112,22 @@
|
||||
import net.minecraft.world.scores.ScoreboardTeam;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityExhaustionEvent;
|
||||
+import org.bukkit.event.entity.EntityKnockbackEvent;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
+import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
+// CraftBukkit end
|
||||
@@ -22,7 +23,7 @@
|
||||
public abstract class EntityHuman extends EntityLiving {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -127,7 +142,8 @@
|
||||
@@ -127,7 +143,8 @@
|
||||
public static final float SWIMMING_BB_HEIGHT = 0.6F;
|
||||
public static final float DEFAULT_EYE_HEIGHT = 1.62F;
|
||||
public static final EntitySize STANDING_DIMENSIONS = EntitySize.scalable(0.6F, 1.8F);
|
||||
@@ -32,7 +33,7 @@
|
||||
private static final DataWatcherObject<Float> DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT);
|
||||
private static final DataWatcherObject<Integer> DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT);
|
||||
protected static final DataWatcherObject<Byte> DATA_PLAYER_MODE_CUSTOMISATION = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.BYTE);
|
||||
@@ -136,10 +152,10 @@
|
||||
@@ -136,10 +153,10 @@
|
||||
protected static final DataWatcherObject<NBTTagCompound> DATA_SHOULDER_RIGHT = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG);
|
||||
private long timeEntitySatOnShoulder;
|
||||
private final PlayerInventory inventory = new PlayerInventory(this);
|
||||
@@ -45,7 +46,7 @@
|
||||
protected int jumpTriggerTime;
|
||||
public float oBob;
|
||||
public float bob;
|
||||
@@ -168,6 +184,16 @@
|
||||
@@ -168,6 +185,16 @@
|
||||
public EntityFishingHook fishing;
|
||||
protected float hurtDir;
|
||||
|
||||
@@ -62,7 +63,7 @@
|
||||
public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) {
|
||||
super(EntityTypes.PLAYER, world);
|
||||
this.lastItemInMainHand = ItemStack.EMPTY;
|
||||
@@ -312,7 +338,7 @@
|
||||
@@ -312,7 +339,7 @@
|
||||
ItemStack itemstack = this.getItemBySlot(EnumItemSlot.HEAD);
|
||||
|
||||
if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(TagsFluid.WATER)) {
|
||||
@@ -71,7 +72,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -482,8 +508,14 @@
|
||||
@@ -482,8 +509,14 @@
|
||||
public void rideTick() {
|
||||
if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) {
|
||||
this.stopRiding();
|
||||
@@ -88,7 +89,7 @@
|
||||
super.rideTick();
|
||||
this.oBob = this.bob;
|
||||
this.bob = 0.0F;
|
||||
@@ -505,7 +537,8 @@
|
||||
@@ -505,7 +538,8 @@
|
||||
|
||||
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) {
|
||||
@@ -98,7 +99,7 @@
|
||||
}
|
||||
|
||||
if (this.foodData.needsFood() && this.tickCount % 10 == 0) {
|
||||
@@ -665,6 +698,13 @@
|
||||
@@ -665,6 +699,13 @@
|
||||
|
||||
@Nullable
|
||||
public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) {
|
||||
@@ -112,7 +113,7 @@
|
||||
if (itemstack.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -699,6 +739,33 @@
|
||||
@@ -699,6 +740,33 @@
|
||||
entityitem.setDeltaMovement((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6);
|
||||
}
|
||||
|
||||
@@ -146,7 +147,7 @@
|
||||
return entityitem;
|
||||
}
|
||||
}
|
||||
@@ -789,7 +856,7 @@
|
||||
@@ -789,7 +857,7 @@
|
||||
}
|
||||
|
||||
if (nbttagcompound.contains("LastDeathLocation", 10)) {
|
||||
@@ -155,7 +156,7 @@
|
||||
Logger logger = EntityHuman.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -822,7 +889,7 @@
|
||||
@@ -822,7 +890,7 @@
|
||||
}
|
||||
|
||||
this.getLastDeathLocation().flatMap((globalpos) -> {
|
||||
@@ -164,7 +165,7 @@
|
||||
Logger logger = EntityHuman.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -849,12 +916,12 @@
|
||||
@@ -849,12 +917,12 @@
|
||||
return false;
|
||||
} else {
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -179,7 +180,7 @@
|
||||
}
|
||||
|
||||
if (this.level().getDifficulty() == EnumDifficulty.EASY) {
|
||||
@@ -866,7 +933,13 @@
|
||||
@@ -866,7 +934,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +195,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -886,10 +959,29 @@
|
||||
@@ -886,10 +960,29 @@
|
||||
}
|
||||
|
||||
public boolean canHarmPlayer(EntityHuman entityhuman) {
|
||||
@@ -227,7 +228,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -931,8 +1023,13 @@
|
||||
@@ -931,8 +1024,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +243,7 @@
|
||||
if (!this.isInvulnerableTo(damagesource)) {
|
||||
f = this.getDamageAfterArmorAbsorb(damagesource, f);
|
||||
f = this.getDamageAfterMagicAbsorb(damagesource, f);
|
||||
@@ -947,7 +1044,7 @@
|
||||
@@ -947,7 +1045,7 @@
|
||||
}
|
||||
|
||||
if (f != 0.0F) {
|
||||
@@ -251,7 +252,7 @@
|
||||
this.getCombatTracker().recordDamage(damagesource, f);
|
||||
this.setHealth(this.getHealth() - f);
|
||||
if (f < 3.4028235E37F) {
|
||||
@@ -957,6 +1054,7 @@
|
||||
@@ -957,6 +1055,7 @@
|
||||
this.gameEvent(GameEvent.ENTITY_DAMAGE);
|
||||
}
|
||||
}
|
||||
@@ -259,7 +260,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1121,7 +1219,7 @@
|
||||
@@ -1121,7 +1220,7 @@
|
||||
|
||||
f *= 0.2F + f2 * f2 * 0.8F;
|
||||
f1 *= f2;
|
||||
@@ -268,7 +269,7 @@
|
||||
if (f > 0.0F || f1 > 0.0F) {
|
||||
boolean flag = f2 > 0.9F;
|
||||
boolean flag1 = false;
|
||||
@@ -1160,8 +1258,15 @@
|
||||
@@ -1160,8 +1259,15 @@
|
||||
if (entity instanceof EntityLiving) {
|
||||
f3 = ((EntityLiving) entity).getHealth();
|
||||
if (j > 0 && !entity.isOnFire()) {
|
||||
@@ -286,7 +287,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1171,7 +1276,7 @@
|
||||
@@ -1171,7 +1277,7 @@
|
||||
if (flag5) {
|
||||
if (i > 0) {
|
||||
if (entity instanceof EntityLiving) {
|
||||
@@ -295,7 +296,7 @@
|
||||
} else {
|
||||
entity.push((double) (-MathHelper.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F));
|
||||
}
|
||||
@@ -1189,8 +1294,11 @@
|
||||
@@ -1189,8 +1295,11 @@
|
||||
EntityLiving entityliving = (EntityLiving) iterator.next();
|
||||
|
||||
if (entityliving != this && entityliving != entity && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
|
||||
@@ -309,7 +310,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1199,9 +1307,26 @@
|
||||
@@ -1199,9 +1308,26 @@
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPlayer && entity.hurtMarked) {
|
||||
@@ -336,7 +337,7 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
@@ -1246,7 +1371,14 @@
|
||||
@@ -1246,7 +1372,14 @@
|
||||
|
||||
this.awardStat(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
|
||||
if (j > 0) {
|
||||
@@ -352,7 +353,7 @@
|
||||
}
|
||||
|
||||
if (this.level() instanceof WorldServer && f5 > 2.0F) {
|
||||
@@ -1256,12 +1388,17 @@
|
||||
@@ -1256,12 +1389,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +372,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1338,6 +1475,12 @@
|
||||
@@ -1307,7 +1445,14 @@
|
||||
|
||||
@Override
|
||||
public void remove(Entity.RemovalReason entity_removalreason) {
|
||||
- super.remove(entity_removalreason);
|
||||
+ // CraftBukkit start - add Bukkit remove cause
|
||||
+ this.remove(entity_removalreason, null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
|
||||
+ super.remove(entity_removalreason, cause);
|
||||
+ // CraftBukkit end
|
||||
this.inventoryMenu.removed(this);
|
||||
if (this.containerMenu != null && this.hasContainerOpen()) {
|
||||
this.doCloseContainer();
|
||||
@@ -1338,6 +1483,12 @@
|
||||
}
|
||||
|
||||
public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition) {
|
||||
@@ -384,7 +401,7 @@
|
||||
this.startSleeping(blockposition);
|
||||
this.sleepCounter = 0;
|
||||
return Either.right(Unit.INSTANCE);
|
||||
@@ -1425,9 +1568,9 @@
|
||||
@@ -1425,9 +1576,9 @@
|
||||
super.jumpFromGround();
|
||||
this.awardStat(StatisticList.JUMP);
|
||||
if (this.isSprinting()) {
|
||||
@@ -396,7 +413,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1454,7 +1597,11 @@
|
||||
@@ -1454,7 +1605,11 @@
|
||||
|
||||
this.setDeltaMovement(vec3d2.x, d0 * 0.6D, vec3d2.z);
|
||||
this.resetFallDistance();
|
||||
@@ -409,7 +426,7 @@
|
||||
} else {
|
||||
super.travel(vec3d);
|
||||
}
|
||||
@@ -1507,12 +1654,24 @@
|
||||
@@ -1507,12 +1662,24 @@
|
||||
}
|
||||
|
||||
public void startFallFlying() {
|
||||
@@ -435,7 +452,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1626,10 +1785,21 @@
|
||||
@@ -1626,10 +1793,21 @@
|
||||
return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
|
||||
}
|
||||
|
||||
@@ -458,7 +475,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1715,13 +1885,20 @@
|
||||
@@ -1715,13 +1893,20 @@
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
@@ -482,7 +499,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1760,26 +1937,31 @@
|
||||
@@ -1760,26 +1945,31 @@
|
||||
|
||||
protected void removeEntitiesOnShoulder() {
|
||||
if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) {
|
||||
|
||||
Reference in New Issue
Block a user