mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
928bcc8d3a
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 09943450 Update SnakeYAML version 5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc 6f82b381 PR-788: Add getHand() to all relevant events CraftBukkit Changes: aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe 5329dd6fd PR-1107: Add getHand() to all relevant events 93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
51 lines
2.7 KiB
Diff
51 lines
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: dodison <kacpik@mapik.eu>
|
|
Date: Mon, 26 Jul 2021 17:35:20 +0200
|
|
Subject: [PATCH] Add critical damage API
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
|
|
index 869bad7405ec7fa67728e90d8b9f2e11b542611f..7ce8f1a26c1b33dd0eb6e6435952fd73abf49879 100644
|
|
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
|
|
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
|
|
@@ -11,15 +11,40 @@ import org.jetbrains.annotations.NotNull;
|
|
public class EntityDamageByEntityEvent extends EntityDamageEvent {
|
|
private final Entity damager;
|
|
|
|
+ @Deprecated // Paper - add critical damage API
|
|
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
|
|
super(damagee, cause, damage);
|
|
this.damager = damager;
|
|
+ this.critical = false; // Paper - add critical damage API
|
|
}
|
|
|
|
+ @Deprecated // Paper - add critical damage API
|
|
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) {
|
|
+ // Paper start - add critical damage API
|
|
+ this(damager, damagee, cause, modifiers, modifierFunctions, false);
|
|
+ }
|
|
+
|
|
+ private final boolean critical;
|
|
+ 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, boolean critical) {
|
|
+ // Paper end
|
|
super(damagee, cause, modifiers, modifierFunctions);
|
|
this.damager = damager;
|
|
+ // Paper start - add critical damage API
|
|
+ this.critical = critical;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Shows this damage instance was critical.
|
|
+ * The damage instance can be critical if the attacking player met the respective conditions.
|
|
+ * Furthermore arrows may also cause a critical damage event if the arrow {@link org.bukkit.entity.AbstractArrow#isCritical()}.
|
|
+ *
|
|
+ * @return if the hit was critical.
|
|
+ * @see <a href="https://minecraft.fandom.com/wiki/Damage#Critical_hit">https://minecraft.fandom.com/wiki/Damage#Critical_hit</a>
|
|
+ */
|
|
+ public boolean isCritical() {
|
|
+ return this.critical;
|
|
}
|
|
+ // Paper end
|
|
|
|
/**
|
|
* Returns the entity that damaged the defender.
|