Files
ParchmentMC/patches/api/0004-Add-origin-location-to-EntityDamageByBlockEvent.patch
lexikiq ba9826b5e1 Exclude eden-common from shading (without patches)
Slightly cleaner approach; less prone to patch breakage from upstream changes and much easier to update
2022-01-19 15:04:30 -05:00

55 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lexikiq <noellekiq@gmail.com>
Date: Fri, 18 Jun 2021 14:06:43 -0400
Subject: [PATCH] Add origin location to EntityDamageByBlockEvent
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
index 461727dc7f06efb3550fc370e0db5bd04ba89711..f20ac2ba1921616f346c11ef60c53aba0080728b 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
@@ -12,17 +12,43 @@ import org.jetbrains.annotations.Nullable;
*/
public class EntityDamageByBlockEvent extends EntityDamageEvent {
private final Block damager;
+ private final org.bukkit.Location location; // Parchment
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
super(damagee, cause, damage);
this.damager = damager;
+ this.location = damager != null ? damager.getLocation() : null; // Parchment
}
public EntityDamageByBlockEvent(@Nullable final Block 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) {
super(damagee, cause, modifiers, modifierFunctions);
this.damager = damager;
+ this.location = damager != null ? damager.getLocation() : null; // Parchment
}
+ // Parchment start
+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @Nullable final org.bukkit.Location damageLocation, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
+ super(damagee, cause, modifiers, modifierFunctions);
+ this.damager = damager;
+ if (damageLocation != null)
+ this.location = damageLocation;
+ else if (damager != null)
+ this.location = damager.getLocation();
+ else
+ this.location = null;
+ }
+
+ /**
+ * Gets the location of the damage source.
+ *
+ * @return Originating location of the damage source
+ */
+ @Nullable
+ public org.bukkit.Location getLocation() {
+ return location;
+ }
+ // Parchment end
+
/**
* Returns the block that damaged the player.
*