3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 13:30:06 +01:00
Paper/CraftBukkit-Patches/0025-Revert-Bukkit-Damage-API-Behavior.patch

56 Zeilen
2.6 KiB
Diff

2014-07-09 05:51:47 +02:00
From d4704f5db1d3d651344b8c385b211722c54eae02 Mon Sep 17 00:00:00 2001
2014-07-09 05:05:35 +02:00
From: Zach Brown <Zbob750@live.com>
Date: Tue, 8 Jul 2014 21:49:42 -0500
2014-07-09 02:31:32 +02:00
Subject: [PATCH] Revert Bukkit Damage API Behavior
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2014-07-09 05:05:35 +02:00
index 67484dc..760cec5 100644
2014-07-09 02:31:32 +02:00
--- 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()) {
2014-07-09 05:05:35 +02:00
+ // PaperSpigot start - moved up from below to bring back old behavior
2014-07-09 02:31:32 +02:00
+ 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;
2014-07-09 05:05:35 +02:00
@@ -1006,13 +1016,19 @@ public abstract class EntityLiving extends Entity {
f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
2014-07-09 02:31:32 +02:00
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
2014-07-09 05:05:35 +02:00
+ event.setDamage(DamageModifier.ARMOR, -armorModifier);
2014-07-09 02:31:32 +02:00
+ if (damagesource == DamageSource.FALLING_BLOCK || damagesource == DamageSource.ANVIL) {
+ event.setDamage(DamageModifier.HARD_HAT, -hardHatModifier);
}
2014-07-09 05:05:35 +02:00
2014-07-09 02:31:32 +02:00
- f = (float) event.getFinalDamage();
+ if (human) {
+ event.setDamage(DamageModifier.BLOCKING, -blockingModifier);
+ }
+ event.setDamage(DamageModifier.RESISTANCE, -resistanceModifier);
2014-07-09 05:05:35 +02:00
+ event.setDamage(DamageModifier.MAGIC, -magicModifier);
2014-07-09 02:31:32 +02:00
+ 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
2014-07-09 05:05:35 +02:00