craftbukkit/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch

100 lines
6.1 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/EntityAreaEffectCloud.java
+++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java
2025-03-26 03:05:00 +11:00
@@ -32,6 +32,12 @@
import net.minecraft.world.level.World;
2022-03-01 02:00:00 +11:00
import net.minecraft.world.level.material.EnumPistonReaction;
2021-03-09 08:47:33 +11:00
2018-12-26 08:00:00 +11:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityRemoveEvent;
2018-12-26 08:00:00 +11:00
+// CraftBukkit end
2021-03-09 08:47:33 +11:00
+
2023-03-15 03:30:00 +11:00
public class EntityAreaEffectCloud extends Entity implements TraceableEntity {
2018-12-26 08:00:00 +11:00
2025-03-26 03:05:00 +11:00
private static final int TIME_BETWEEN_APPLICATIONS = 5;
@@ -217,7 +223,7 @@
2024-10-23 02:15:00 +11:00
private void serverTick(WorldServer worldserver) {
2025-03-26 03:05:00 +11:00
if (this.duration != -1 && this.tickCount >= this.waitTime + this.duration) {
2024-10-23 02:15:00 +11:00
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else {
boolean flag = this.isWaiting();
boolean flag1 = this.tickCount < this.waitTime;
2025-03-26 03:05:00 +11:00
@@ -232,7 +238,7 @@
2024-10-23 02:15:00 +11:00
if (this.radiusPerTick != 0.0F) {
f += this.radiusPerTick;
if (f < 0.5F) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
2025-03-26 03:05:00 +11:00
@@ -254,9 +260,10 @@
List<EntityLiving> list1 = this.level().<EntityLiving>getEntitiesOfClass(EntityLiving.class, this.getBoundingBox());
2025-03-26 03:05:00 +11:00
if (!list1.isEmpty()) {
2024-10-23 02:15:00 +11:00
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
2025-03-26 03:05:00 +11:00
for (EntityLiving entityliving : list1) {
2024-10-23 02:15:00 +11:00
if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) {
- Stream stream = list.stream();
+ Stream<MobEffect> stream = list.stream(); // CraftBukkit - decompile error
2024-10-23 02:15:00 +11:00
Objects.requireNonNull(entityliving);
if (!stream.noneMatch(entityliving::canBeAffected)) {
2025-03-26 03:05:00 +11:00
@@ -265,20 +272,33 @@
2024-10-23 02:15:00 +11:00
double d2 = d0 * d0 + d1 * d1;
2024-06-14 01:05:00 +10:00
2024-10-23 02:15:00 +11:00
if (d2 <= (double) (f * f)) {
+ // CraftBukkit start
+ entities.add((LivingEntity) entityliving.getBukkitEntity());
+ }
2024-06-14 01:05:00 +10:00
+ }
+ }
+ }
2024-10-23 02:15:00 +11:00
+ {
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
+ if (!event.isCancelled()) {
+ for (LivingEntity entity : event.getAffectedEntities()) {
+ if (entity instanceof CraftLivingEntity) {
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
+ // CraftBukkit end
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
2025-03-26 03:05:00 +11:00
for (MobEffect mobeffect : list) {
if (((MobEffectList) mobeffect.getEffect().value()).isInstantenous()) {
((MobEffectList) mobeffect.getEffect().value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), 0.5D);
2024-10-23 02:15:00 +11:00
} else {
2025-03-26 03:05:00 +11:00
- entityliving.addEffect(new MobEffect(mobeffect), this);
+ entityliving.addEffect(new MobEffect(mobeffect), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
2024-10-23 02:15:00 +11:00
}
2024-06-14 01:05:00 +10:00
}
2024-10-23 02:15:00 +11:00
if (this.radiusOnUse != 0.0F) {
f += this.radiusOnUse;
if (f < 0.5F) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
2024-10-23 02:15:00 +11:00
@@ -288,7 +308,7 @@
2025-03-26 03:05:00 +11:00
if (this.durationOnUse != 0 && this.duration != -1) {
2024-10-23 02:15:00 +11:00
this.duration += this.durationOnUse;
if (this.duration <= 0) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
2024-06-14 01:05:00 +10:00
}
2025-03-26 03:05:00 +11:00
@@ -381,7 +401,7 @@
this.radiusOnUse = nbttagcompound.getFloatOr("RadiusOnUse", 0.0F);
this.radiusPerTick = nbttagcompound.getFloatOr("RadiusPerTick", 0.0F);
this.setRadius(nbttagcompound.getFloatOr("Radius", 3.0F));
- this.ownerUUID = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse((Object) null);
+ this.ownerUUID = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error
RegistryOps<NBTBase> registryops = this.registryAccess().<NBTBase>createSerializationContext(DynamicOpsNBT.INSTANCE);
this.setParticle((ParticleParam) nbttagcompound.read("Particle", Particles.CODEC, registryops).orElse(EntityAreaEffectCloud.DEFAULT_PARTICLE));