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:
@@ -17,32 +17,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
private void applyWater() {
|
||||
AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
|
||||
- List<net.minecraft.world.entity.LivingEntity> list = this.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE);
|
||||
+ List<net.minecraft.world.entity.LivingEntity> list = this.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.APPLY_WATER_GET_ENTITIES_PREDICATE); // Paper
|
||||
+ Map<LivingEntity, Double> affected = new HashMap<>(); // Paper
|
||||
+ // Paper start
|
||||
+ List<net.minecraft.world.entity.LivingEntity> list = this.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.APPLY_WATER_GET_ENTITIES_PREDICATE);
|
||||
+ Map<LivingEntity, Double> affected = new HashMap<>();
|
||||
+ java.util.Set<LivingEntity> rehydrate = new java.util.HashSet<>();
|
||||
+ java.util.Set<LivingEntity> extinguish = new java.util.HashSet<>();
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
net.minecraft.world.entity.LivingEntity entityliving = (net.minecraft.world.entity.LivingEntity) iterator.next();
|
||||
+ // Paper start - Change into single getEntities for axolotls & water sensitive
|
||||
+ if (entityliving instanceof Axolotl axolotl) {
|
||||
+ affected.put(axolotl.getBukkitLivingEntity(), 1.0);
|
||||
+ continue;
|
||||
+ rehydrate.add(((org.bukkit.entity.Axolotl) axolotl.getBukkitEntity()));
|
||||
+ }
|
||||
+ // Paper end
|
||||
double d0 = this.distanceToSqr((Entity) entityliving);
|
||||
|
||||
if (d0 < 16.0D) {
|
||||
if (entityliving.isSensitiveToWater()) {
|
||||
- entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F);
|
||||
+ // Paper start
|
||||
+ double intensity = 1.0D - Math.sqrt(d0) / 4.0D;
|
||||
+ affected.put(entityliving.getBukkitLivingEntity(), intensity);
|
||||
+ // entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F); // Paper - moved down
|
||||
+ // Paper end
|
||||
+ affected.put(entityliving.getBukkitLivingEntity(), 1.0);
|
||||
}
|
||||
|
||||
if (entityliving.isOnFire() && entityliving.isAlive()) {
|
||||
@@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
||||
- entityliving.extinguishFire();
|
||||
+ extinguish.add(entityliving.getBukkitLivingEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,15 +51,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- Axolotl axolotl = (Axolotl) iterator1.next();
|
||||
-
|
||||
- axolotl.rehydrate();
|
||||
+ // Paper start
|
||||
+ org.bukkit.event.entity.PotionSplashEvent event = CraftEventFactory.callPotionSplashEvent(this, affected);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ for (LivingEntity affectedEntity : event.getAffectedEntities()) {
|
||||
+ net.minecraft.world.entity.LivingEntity entityliving = ((CraftLivingEntity) affectedEntity).getHandle();
|
||||
+ if (entityliving instanceof Axolotl axolotl && event.getIntensity(affectedEntity) > 0) {
|
||||
+ io.papermc.paper.event.entity.WaterBottleSplashEvent event = new io.papermc.paper.event.entity.WaterBottleSplashEvent(
|
||||
+ (org.bukkit.entity.ThrownPotion) this.getBukkitEntity(), affected, rehydrate, extinguish
|
||||
+ );
|
||||
+ if (event.callEvent()) {
|
||||
+ for (LivingEntity affectedEntity : event.getToDamage()) {
|
||||
+ ((CraftLivingEntity) affectedEntity).getHandle().hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F);
|
||||
+ }
|
||||
+ for (LivingEntity toExtinguish : event.getToExtinguish()) {
|
||||
+ ((CraftLivingEntity) toExtinguish).getHandle().extinguishFire();
|
||||
+ }
|
||||
+ for (LivingEntity toRehydrate : event.getToRehydrate()) {
|
||||
+ if (((CraftLivingEntity) toRehydrate).getHandle() instanceof Axolotl axolotl) {
|
||||
+ axolotl.rehydrate();
|
||||
+ } else {
|
||||
+ entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
Reference in New Issue
Block a user