3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-16 19:40:07 +01:00
Paper/patches/server/0655-Fix-PotionSplashEvent-for-water-splash-potions.patch
Spottedleaf 01a13871de
Rewrite chunk system (#8177)
Patch documentation to come

Issues with the old system that are fixed now:
- World generation does not scale with cpu cores effectively.
- Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps.
- Unreliable prioritisation of chunk gen/load calls that block the main thread.
- Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved.
- Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal.
- Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles.

The above list is not complete. The patch documentation will complete it.

New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil.

Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft.

The old legacy chunk system patches have been moved to the removed folder in case we need them again.
2022-09-26 01:02:51 -07:00

77 Zeilen
4.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 20 May 2021 20:40:53 -0700
Subject: [PATCH] Fix PotionSplashEvent for water splash potions
Fixes SPIGOT-6221: https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6221
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
index ebe9b713905d33a4107fe32874a783e154bd0524..fee09e6ff72cf1da389d5811dd005642cd50a5b4 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
@@ -121,30 +121,47 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
}
}
+ private static final Predicate<net.minecraft.world.entity.LivingEntity> APPLY_WATER_GET_ENTITIES_PREDICATE = ThrownPotion.WATER_SENSITIVE.or(Axolotl.class::isInstance); // Paper
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);
+ 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
if (!list.isEmpty()) {
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;
+ }
+ // Paper end
double d0 = this.distanceToSqr((Entity) entityliving);
if (d0 < 16.0D && 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
}
}
}
- List<Axolotl> list1 = this.level.getEntitiesOfClass(Axolotl.class, axisalignedbb);
- Iterator iterator1 = list1.iterator();
-
- while (iterator1.hasNext()) {
- 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) {
+ axolotl.rehydrate();
+ } else {
+ entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F);
+ }
+ }
+ // Paper end
}
}
@@ -165,6 +182,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
double d0 = this.distanceToSqr((Entity) entityliving);
if (d0 < 16.0D) {
+ // Paper - diff on change, used when calling the splash event for water splash potions
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
if (entityliving == entity) {