Skip to content

Commit

Permalink
Switch around damager/damagee in event
Browse files Browse the repository at this point in the history
  • Loading branch information
Malfrador committed Sep 8, 2024
1 parent 54b1c27 commit e14e71b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions patches/api/0004-Profile-switching.patch
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ index 148c4aad384ae8e3b8b22d264a84bddfbcafdf1e..90a5f69d513833f116715f2f546593f9
this.damagerState = damagerState;
}
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
index 8ea4be529400b34df3d31b0f17c2d145345523d9..e9a87df62a86ee6ba3f2cabf702df25121b84ae1 100644
index 8ea4be529400b34df3d31b0f17c2d145345523d9..d6faa1a1d571c6fa93ca99e0a789ba289c77579e 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
@@ -2,8 +2,11 @@ package org.bukkit.event.entity;
Expand All @@ -766,15 +766,16 @@ index 8ea4be529400b34df3d31b0f17c2d145345523d9..e9a87df62a86ee6ba3f2cabf702df251
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -27,24 +30,30 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent {
@@ -27,24 +30,31 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent {
this.critical = false; // Paper - add critical damage API
}

- @Deprecated(forRemoval = true)
+ public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage, DamageType type) {
+ public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage, PDamageType type) {
+ super(damagee, cause, damage);
+ this.damager = damager;
+ this.critical = false; // Paper - add critical damage API
+ this.pDamageType = type;
+ }
+
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0004-Spellbook.patch
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ index cb61462d4691a055a4b25f7b953609d8a154fdfe..73ccb55889de521c65c76c7e15bbd6d1
float f = this.spawnDimensionsScale * this.getWidth() / 2.0F;
float f1 = this.spawnDimensionsScale * this.getHeight();
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index ccd9dff20a60f019e0c320acfb526b8bf3e5f806..76922d68702b6299fb2006dfd896d17faea1b05c 100644
index ccd9dff20a60f019e0c320acfb526b8bf3e5f806..f582f93b3022ced29bbd08b63ce041df10d2a58b 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -11,6 +11,9 @@ import com.mojang.datafixers.util.Pair;
Expand Down Expand Up @@ -1084,7 +1084,7 @@ index ccd9dff20a60f019e0c320acfb526b8bf3e5f806..76922d68702b6299fb2006dfd896d17f
+ resistance = resistance - living.getAttributeValue(type.pen); // Remove the value of the attackers penetration attribute from the victims resistance
+ }
+ finalDmg = amount - resistance;
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(getBukkitEntity(), attacker.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, finalDmg); // TODO: Add type back
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(attacker.getBukkitEntity(), getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, finalDmg, type.apiType); // TODO: Add type back
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
Expand Down

0 comments on commit e14e71b

Please sign in to comment.