Revert Bukkit damage API changes
This commit is contained in:
parent
cfd51ccfb9
commit
0e9f7b049f
@ -1,24 +0,0 @@
|
||||
From 990816b6568d211f62cdd1b7538f52c1c096c1d4 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 7 Jul 2014 23:26:59 -0400
|
||||
Subject: [PATCH] Fix damage bug - Fixes BUKKIT-5678
|
||||
|
||||
If a plugin lowers the damage in EntityDamageEvent while also having damage reduction modifiers,
|
||||
the entity will in turn be able to receive absorption buff on every hit, making them invincible.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
|
||||
index 17d9548..a4b9eb2 100644
|
||||
--- a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
|
||||
@@ -135,7 +135,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
|
||||
for (DamageModifier modifier : MODIFIERS) {
|
||||
damage += getDamage(modifier);
|
||||
}
|
||||
- return damage;
|
||||
+ return Math.max(damage, 0); // Spigot
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
1.9.1
|
||||
|
@ -0,0 +1,59 @@
|
||||
From 087bba2d9d05ddab50ca8b320d726dbe2d55e14d Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 8 Jul 2014 19:21:28 -0400
|
||||
Subject: [PATCH] Revert Bukkit Damage API Behavior
|
||||
|
||||
This API is extremely broken and even updated plugins can not adequately restore their intended behavior with the existing API.
|
||||
|
||||
Until Bukkit comes up with an adequate solution, lets revert the change in behavior.
|
||||
|
||||
New plugins using the API will not error but will also not behave as intended, but there are likely no plugins using this new API.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index 6b4cd2c..f445d7e 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -967,6 +967,16 @@ public abstract class EntityLiving extends Entity {
|
||||
// CraftBukkit start
|
||||
protected boolean d(DamageSource damagesource, float f) { // void -> boolean
|
||||
if (!this.isInvulnerable()) {
|
||||
+ // PaperSpigot start - moved up from below to bring back old behavior.
|
||||
+ EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, f, 0, 0, 0, 0, 0, 0);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ f = (float) event.getDamage();
|
||||
+ // PaperSpigot end
|
||||
+
|
||||
boolean human = this instanceof EntityHuman;
|
||||
float originalDamage = f;
|
||||
float preDamage = f;
|
||||
@@ -1006,13 +1016,18 @@ public abstract class EntityLiving extends Entity {
|
||||
f = Math.max(f - this.br(), 0.0F);
|
||||
float absorptionModifier = Math.max(f1 - f, 0.0F);
|
||||
|
||||
- EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, -hardHatModifier, -blockingModifier, -armorModifier, -resistanceModifier, -magicModifier, -absorptionModifier);
|
||||
-
|
||||
- if (event.isCancelled()) {
|
||||
- return false;
|
||||
+ // PaperSpigot start - Moved event call up
|
||||
+ event.setDamage(DamageModifier.ARMOR, -armorModifier);
|
||||
+ if (damagesource == DamageSource.FALLING_BLOCK || damagesource == DamageSource.ANVIL) {
|
||||
+ event.setDamage(DamageModifier.HARD_HAT, -hardHatModifier);
|
||||
}
|
||||
-
|
||||
- f = (float) event.getFinalDamage();
|
||||
+ if (human) {
|
||||
+ event.setDamage(DamageModifier.BLOCKING, -blockingModifier);
|
||||
+ }
|
||||
+ event.setDamage(DamageModifier.RESISTANCE, -resistanceModifier);
|
||||
+ event.setDamage(DamageModifier.MAGIC, -magicModifier);
|
||||
+ event.setDamage(DamageModifier.ABSORPTION, -absorptionModifier);
|
||||
+ // PaperSpigot end
|
||||
|
||||
// Apply damage to helmet
|
||||
if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) {
|
||||
--
|
||||
1.9.1
|
Loading…
Reference in New Issue
Block a user