13
0
geforkt von Mirrors/Paper

SPIGOT-2907: Improve EntityResurrectEvent handling

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2016-12-10 12:16:14 +11:00
Ursprung b4a50e447b
Commit 8b77464a94

Datei anzeigen

@ -319,22 +319,37 @@
this.aA = 0.0F; this.aA = 0.0F;
Entity entity1 = damagesource.getEntity(); 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()); + EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity());
+ event.setCancelled(!flag); + event.setCancelled(!flag);
+ this.world.getServer().getPluginManager().callEvent(event); + this.world.getServer().getPluginManager().callEvent(event);
+ flag = !event.isCancelled();
+ +
+ if (!event.isCancelled()) { if (flag) {
+ itemstack.subtract(1);
+ // CraftBukkit end + // CraftBukkit end
if (this instanceof EntityHuman) { if (this instanceof EntityHuman) {
((EntityHuman) this).b(StatisticList.b(Items.cY)); ((EntityHuman) this).b(StatisticList.b(Items.cY));
} }
@@ -914,6 +1061,12 @@ @@ -914,6 +1064,12 @@
boolean flag = this.lastDamageByPlayerTime > 0; boolean flag = this.lastDamageByPlayerTime > 0;
this.a(flag, i, damagesource); 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); int i = MathHelper.f((f - 3.0F - f2) * f1);
if (i > 0) { if (i > 0) {
@ -362,7 +377,7 @@
int j = MathHelper.floor(this.locX); int j = MathHelper.floor(this.locX);
int k = MathHelper.floor(this.locY - 0.20000000298023224D); int k = MathHelper.floor(this.locY - 0.20000000298023224D);
int l = MathHelper.floor(this.locZ); int l = MathHelper.floor(this.locZ);
@@ -1031,7 +1189,7 @@ @@ -1031,7 +1192,7 @@
protected float applyArmorModifier(DamageSource damagesource, float f) { protected float applyArmorModifier(DamageSource damagesource, float f) {
if (!damagesource.ignoresArmor()) { if (!damagesource.ignoresArmor()) {
@ -371,7 +386,7 @@
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.h).getValue()); f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.h).getValue());
} }
@@ -1044,7 +1202,8 @@ @@ -1044,7 +1205,8 @@
} else { } else {
int i; int i;
@ -381,7 +396,7 @@
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i; int j = 25 - i;
float f1 = f * (float) j; float f1 = f * (float) j;
@@ -1065,22 +1224,129 @@ @@ -1065,22 +1227,129 @@
} }
} }
@ -521,7 +536,7 @@
} }
public CombatTracker getCombatTracker() { public CombatTracker getCombatTracker() {
@@ -1147,6 +1413,7 @@ @@ -1147,6 +1416,7 @@
public AttributeMapBase getAttributeMap() { public AttributeMapBase getAttributeMap() {
if (this.attributeMap == null) { if (this.attributeMap == null) {
this.attributeMap = new AttributeMapServer(); this.attributeMap = new AttributeMapServer();
@ -529,7 +544,7 @@
} }
return this.attributeMap; return this.attributeMap;
@@ -1438,6 +1705,7 @@ @@ -1438,6 +1708,7 @@
} }
if (this.onGround && !this.world.isClientSide) { if (this.onGround && !this.world.isClientSide) {
@ -537,7 +552,7 @@
this.setFlag(7, false); this.setFlag(7, false);
} }
} else { } else {
@@ -1798,6 +2066,7 @@ @@ -1798,6 +2069,7 @@
} }
if (!this.world.isClientSide) { if (!this.world.isClientSide) {
@ -545,7 +560,7 @@
this.setFlag(7, flag); this.setFlag(7, flag);
} }
@@ -1895,11 +2164,11 @@ @@ -1895,11 +2167,11 @@
} }
public boolean isInteractable() { public boolean isInteractable() {
@ -559,7 +574,7 @@
} }
protected void ap() { protected void ap() {
@@ -2036,7 +2305,23 @@ @@ -2036,7 +2308,23 @@
protected void v() { protected void v() {
if (!this.activeItem.isEmpty() && this.isHandRaised()) { if (!this.activeItem.isEmpty() && this.isHandRaised()) {
this.a(this.activeItem, 16); this.a(this.activeItem, 16);
@ -584,7 +599,7 @@
this.cF(); this.cF();
} }
@@ -2115,10 +2400,18 @@ @@ -2115,10 +2403,18 @@
} }
if (flag1) { if (flag1) {