mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 12:05:53 +01:00
Account for splash water bottles now extinguishing entities (#8622)
* Account for splash water bottles now extinguishing entities * improvements and javadocs * reorder patches * rename event to WaterBottleSplashEvent Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
This commit is contained in:
parent
b2043f1c3a
commit
f97bb11e4b
150
patches/api/0310-Add-WaterBottleSplashEvent.patch
Normal file
150
patches/api/0310-Add-WaterBottleSplashEvent.patch
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||||
|
Date: Thu, 8 Dec 2022 10:12:23 -0700
|
||||||
|
Subject: [PATCH] Add WaterBottleSplashEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/event/entity/WaterBottleSplashEvent.java b/src/main/java/io/papermc/paper/event/entity/WaterBottleSplashEvent.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..4c4c645a1597b5afb62f78dc1cfae62c5fe60fcf
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/event/entity/WaterBottleSplashEvent.java
|
||||||
|
@@ -0,0 +1,125 @@
|
||||||
|
+package io.papermc.paper.event.entity;
|
||||||
|
+
|
||||||
|
+import java.util.Collection;
|
||||||
|
+import java.util.Map;
|
||||||
|
+import java.util.Set;
|
||||||
|
+import java.util.stream.Collectors;
|
||||||
|
+import org.bukkit.entity.LivingEntity;
|
||||||
|
+import org.bukkit.entity.ThrownPotion;
|
||||||
|
+import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Called when a splash water potion "splashes" and affects
|
||||||
|
+ * different entities in different ways.
|
||||||
|
+ */
|
||||||
|
+public class WaterBottleSplashEvent extends PotionSplashEvent {
|
||||||
|
+ private final @NotNull Set<LivingEntity> rehydrate;
|
||||||
|
+ private final @NotNull Set<LivingEntity> extinguish;
|
||||||
|
+
|
||||||
|
+ public WaterBottleSplashEvent(
|
||||||
|
+ final @NotNull ThrownPotion potion,
|
||||||
|
+ final @NotNull Map<LivingEntity, Double> affectedEntities,
|
||||||
|
+ final @NotNull Set<LivingEntity> rehydrate,
|
||||||
|
+ final @NotNull Set<LivingEntity> extinguish
|
||||||
|
+ ) {
|
||||||
|
+ super(potion, affectedEntities);
|
||||||
|
+ this.rehydrate = rehydrate;
|
||||||
|
+ this.extinguish = extinguish;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets an immutable collection of entities that
|
||||||
|
+ * will take damage as a result of this event. Use
|
||||||
|
+ * other methods on this class to modify which entities
|
||||||
|
+ * take damage.
|
||||||
|
+ *
|
||||||
|
+ * @return an immutable collection of entities
|
||||||
|
+ * @see #doNotDamageAsWaterSensitive(LivingEntity)
|
||||||
|
+ * @see #damageAsWaterSensitive(LivingEntity)
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public @Unmodifiable Collection<LivingEntity> getToDamage() {
|
||||||
|
+ return this.affectedEntities.entrySet().stream().filter(entry -> entry.getValue() > 0).map(Map.Entry::getKey).collect(Collectors.toUnmodifiableSet());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Removes this entity from the group that
|
||||||
|
+ * will be damaged.
|
||||||
|
+ *
|
||||||
|
+ * @param entity entity to remove
|
||||||
|
+ */
|
||||||
|
+ public void doNotDamageAsWaterSensitive(final @NotNull LivingEntity entity) {
|
||||||
|
+ this.affectedEntities.remove(entity);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Adds this entity to the group that
|
||||||
|
+ * will be damaged
|
||||||
|
+ *
|
||||||
|
+ * @param entity entity to add
|
||||||
|
+ */
|
||||||
|
+ public void damageAsWaterSensitive(final @NotNull LivingEntity entity) {
|
||||||
|
+ this.affectedEntities.put(entity, 1.0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Get a mutable collection of entities
|
||||||
|
+ * that will be rehydrated by this.
|
||||||
|
+ * <p>
|
||||||
|
+ * As of 1.19.3 this only will contain Axolotls as they
|
||||||
|
+ * are the only entity type that can be rehydrated, but
|
||||||
|
+ * it may change in the future.
|
||||||
|
+ *
|
||||||
|
+ * @return the entities
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public Collection<LivingEntity> getToRehydrate() {
|
||||||
|
+ return this.rehydrate;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Get a mutable collection of entities that will
|
||||||
|
+ * be extinguished as a result of this event.
|
||||||
|
+ *
|
||||||
|
+ * @return entities to be extinguished
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public Collection<LivingEntity> getToExtinguish() {
|
||||||
|
+ return this.extinguish;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * @return a confusing collection, don't use it
|
||||||
|
+ * @deprecated Use {@link #getToDamage()}
|
||||||
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull Collection<LivingEntity> getAffectedEntities() {
|
||||||
|
+ return super.getAffectedEntities();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Doesn't make sense for this event as intensity doesn't vary.
|
||||||
|
+ * @return a confusing value
|
||||||
|
+ * @deprecated check if {@link #getToDamage()} contains an entity
|
||||||
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
|
+ @Override
|
||||||
|
+ public double getIntensity(final @NotNull LivingEntity entity) {
|
||||||
|
+ return super.getIntensity(entity);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Doesn't make sense for this event as intensity doesn't vary.
|
||||||
|
+ * @deprecated use {@link #damageAsWaterSensitive(LivingEntity)}
|
||||||
|
+ * or {@link #doNotDamageAsWaterSensitive(LivingEntity)} to change which entities are
|
||||||
|
+ * damaged
|
||||||
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
|
+ @Override
|
||||||
|
+ public void setIntensity(final @NotNull LivingEntity entity, final double intensity) {
|
||||||
|
+ super.setIntensity(entity, intensity);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java b/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java
|
||||||
|
index 80f31a267ef4be88718811484e91a6097106e8d2..97d94aba0a8e86e055abd836dd868b8fe8a486bd 100644
|
||||||
|
--- a/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java
|
||||||
|
+++ b/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java
|
||||||
|
@@ -16,7 +16,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancelled;
|
||||||
|
- private final Map<LivingEntity, Double> affectedEntities;
|
||||||
|
+ protected final Map<LivingEntity, Double> affectedEntities; // Paper
|
||||||
|
|
||||||
|
public PotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final Map<LivingEntity, Double> affectedEntities) {
|
||||||
|
super(potion);
|
@ -8,7 +8,7 @@ Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|||||||
Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com>
|
Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||||
index 8fd399f791b45eb7fc62693ca954eea0c68e2881..2e9006700782924aa8f79e48194200cb1f13110f 100644
|
index dddbb661265aa23f88d93d0681f418f40a872351..998f629852e1103767e005405d1f39c2251ecd28 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
--- a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||||
@@ -23,7 +23,7 @@ public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
@@ -23,7 +23,7 @@ public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add Raw Byte Entity Serialization
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
index 057a4f1a374fcc240998c6ac3fe52d22389458c3..70103054057abfec37a99f30075123f9daa4e4ce 100644
|
index 9fd64aa7f2487b07fe0a6873bd57a0ed483499a3..aa252abe42c184914d6b50ad1f94ba7ada22d7df 100644
|
||||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
@@ -113,6 +113,14 @@ public interface UnsafeValues {
|
@@ -113,6 +113,14 @@ public interface UnsafeValues {
|
@ -5,7 +5,7 @@ Subject: [PATCH] Freeze Tick Lock API
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||||
index 9d6af05deead57a2df9663d76d89ccd8b8aab6d5..f9ca4b90f92f57288654d7006613531b139dcddc 100644
|
index 62abbe2149bfb6cb4a38027899863a535e19e94c..b878509ff536f2d728c800a0ae6cd36802570b31 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||||
@@ -279,6 +279,26 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
@@ -279,6 +279,26 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
@ -47,7 +47,7 @@ index 225a24898acd25038ea2a8448f9f3b57643d3026..d173010d51d05928c35bb4bf5fbc08ce
|
|||||||
* Sets this arrow to "noclip" status.
|
* Sets this arrow to "noclip" status.
|
||||||
*
|
*
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Firework.java b/src/main/java/org/bukkit/entity/Firework.java
|
diff --git a/src/main/java/org/bukkit/entity/Firework.java b/src/main/java/org/bukkit/entity/Firework.java
|
||||||
index 0d31aa0b22cf1e849572294e2cfe38b48c9210af..571712e17551f24b369044b8215b722f7183ae7d 100644
|
index 0d31aa0b22cf1e849572294e2cfe38b48c9210af..217d348ad0bbef720b25d3b507a55ca8105b7731 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/Firework.java
|
--- a/src/main/java/org/bukkit/entity/Firework.java
|
||||||
+++ b/src/main/java/org/bukkit/entity/Firework.java
|
+++ b/src/main/java/org/bukkit/entity/Firework.java
|
||||||
@@ -16,6 +16,8 @@ public interface Firework extends Projectile {
|
@@ -16,6 +16,8 @@ public interface Firework extends Projectile {
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add method isTickingWorlds() to Bukkit.
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
index 840aaf9e8fc828b5a7ea02252038c6524680f2e0..232c08c9a588d957d90f198ce479e57615c6e650 100644
|
index 41ea6212b52359927bd5c944c886ef32322b9a08..ac9b690fcccb60b587e5345f12f1383afd0a73a1 100644
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
@@ -753,12 +753,26 @@ public final class Bukkit {
|
@@ -753,12 +753,26 @@ public final class Bukkit {
|
||||||
@ -56,7 +56,7 @@ index 840aaf9e8fc828b5a7ea02252038c6524680f2e0..232c08c9a588d957d90f198ce479e576
|
|||||||
* @param world the world to unload
|
* @param world the world to unload
|
||||||
* @param save whether to save the chunks before unloading
|
* @param save whether to save the chunks before unloading
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
index da5cab4246bd253fcc4e4d9574bdae1867ebb5ab..e43fef0152468944d8a33036344a43e95fe58476 100644
|
index fe50eb0820b99ce5ad8fb8c53ced08709aa4caef..2204336d8800311b65e894739ab1b27273e7c6f2 100644
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
@@ -622,34 +622,55 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
@@ -622,34 +622,55 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
@ -76,7 +76,7 @@ index 0000000000000000000000000000000000000000..0426ee8bd71142b6f933a479c0f2e5ef
|
|||||||
+
|
+
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||||
index f9ca4b90f92f57288654d7006613531b139dcddc..8dd6c7bae8b5ce13e3b4d5847bb204dac5072da6 100644
|
index b878509ff536f2d728c800a0ae6cd36802570b31..9bfe62185acb2a208268a2db3aa81dad9e0eed5e 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||||
@@ -122,10 +122,77 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
@@ -122,10 +122,77 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
@ -6,7 +6,7 @@ Subject: [PATCH] Add NamespacedKey biome methods
|
|||||||
Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
|
Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
index 70103054057abfec37a99f30075123f9daa4e4ce..9b6600853df559eb941eb85b33c71f98b8df4675 100644
|
index aa252abe42c184914d6b50ad1f94ba7ada22d7df..854be548e5a645e7312e6e9390d5255f8b1d61e6 100644
|
||||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
@@ -243,5 +243,32 @@ public interface UnsafeValues {
|
@@ -243,5 +243,32 @@ public interface UnsafeValues {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user