mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 03:32:46 +01:00
SPIGOT-2907: Improve EntityResurrectEvent handling
This commit is contained in:
parent
03c4bf2244
commit
7dfa530395
1 changed files with 30 additions and 15 deletions
|
@ -319,22 +319,37 @@
|
|||
this.aA = 0.0F;
|
||||
Entity entity1 = damagesource.getEntity();
|
||||
|
||||
@@ -817,7 +958,13 @@
|
||||
@@ -806,18 +947,27 @@
|
||||
EnumHand[] aenumhand = EnumHand.values();
|
||||
int i = aenumhand.length;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack = ItemStack.a;
|
||||
for (int j = 0; j < i; ++j) {
|
||||
EnumHand enumhand = aenumhand[j];
|
||||
- ItemStack itemstack = this.b(enumhand);
|
||||
+ itemstack = this.b(enumhand);
|
||||
|
||||
if (itemstack.getItem() == Items.cY) {
|
||||
- itemstack.subtract(1);
|
||||
+ // itemstack.subtract(1);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- if (flag) {
|
||||
+ // CraftBukkit start
|
||||
+ EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity());
|
||||
+ event.setCancelled(!flag);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ flag = !event.isCancelled();
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
if (flag) {
|
||||
+ itemstack.subtract(1);
|
||||
+ // CraftBukkit end
|
||||
if (this instanceof EntityHuman) {
|
||||
((EntityHuman) this).b(StatisticList.b(Items.cY));
|
||||
}
|
||||
@@ -914,6 +1061,12 @@
|
||||
@@ -914,6 +1064,12 @@
|
||||
boolean flag = this.lastDamageByPlayerTime > 0;
|
||||
|
||||
this.a(flag, i, damagesource);
|
||||
|
@ -347,7 +362,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1003,8 +1156,13 @@
|
||||
@@ -1003,8 +1159,13 @@
|
||||
int i = MathHelper.f((f - 3.0F - f2) * f1);
|
||||
|
||||
if (i > 0) {
|
||||
|
@ -362,7 +377,7 @@
|
|||
int j = MathHelper.floor(this.locX);
|
||||
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
|
||||
int l = MathHelper.floor(this.locZ);
|
||||
@@ -1031,7 +1189,7 @@
|
||||
@@ -1031,7 +1192,7 @@
|
||||
|
||||
protected float applyArmorModifier(DamageSource damagesource, float f) {
|
||||
if (!damagesource.ignoresArmor()) {
|
||||
|
@ -371,7 +386,7 @@
|
|||
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.h).getValue());
|
||||
}
|
||||
|
||||
@@ -1044,7 +1202,8 @@
|
||||
@@ -1044,7 +1205,8 @@
|
||||
} else {
|
||||
int i;
|
||||
|
||||
|
@ -381,7 +396,7 @@
|
|||
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = f * (float) j;
|
||||
@@ -1065,22 +1224,129 @@
|
||||
@@ -1065,22 +1227,129 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -521,7 +536,7 @@
|
|||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1147,6 +1413,7 @@
|
||||
@@ -1147,6 +1416,7 @@
|
||||
public AttributeMapBase getAttributeMap() {
|
||||
if (this.attributeMap == null) {
|
||||
this.attributeMap = new AttributeMapServer();
|
||||
|
@ -529,7 +544,7 @@
|
|||
}
|
||||
|
||||
return this.attributeMap;
|
||||
@@ -1438,6 +1705,7 @@
|
||||
@@ -1438,6 +1708,7 @@
|
||||
}
|
||||
|
||||
if (this.onGround && !this.world.isClientSide) {
|
||||
|
@ -537,7 +552,7 @@
|
|||
this.setFlag(7, false);
|
||||
}
|
||||
} else {
|
||||
@@ -1798,6 +2066,7 @@
|
||||
@@ -1798,6 +2069,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
|
@ -545,7 +560,7 @@
|
|||
this.setFlag(7, flag);
|
||||
}
|
||||
|
||||
@@ -1895,11 +2164,11 @@
|
||||
@@ -1895,11 +2167,11 @@
|
||||
}
|
||||
|
||||
public boolean isInteractable() {
|
||||
|
@ -559,7 +574,7 @@
|
|||
}
|
||||
|
||||
protected void ap() {
|
||||
@@ -2036,7 +2305,23 @@
|
||||
@@ -2036,7 +2308,23 @@
|
||||
protected void v() {
|
||||
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
|
||||
this.a(this.activeItem, 16);
|
||||
|
@ -584,7 +599,7 @@
|
|||
this.cF();
|
||||
}
|
||||
|
||||
@@ -2115,10 +2400,18 @@
|
||||
@@ -2115,10 +2403,18 @@
|
||||
}
|
||||
|
||||
if (flag1) {
|
||||
|
|
Loading…
Reference in a new issue