mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Don't fire EntityPotionEffectEvent during worldgen (#9965)
This commit is contained in:
parent
c60d4a3836
commit
635d3870ee
1 changed files with 61 additions and 0 deletions
|
@ -0,0 +1,61 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 23 Nov 2023 10:33:25 -0800
|
||||
Subject: [PATCH] Don't fire EntityPotionEffectEvent during worldgen
|
||||
|
||||
Asynchronous chunk generation provides an opportunity for mobs
|
||||
being added with generation to have effects added to them. The event
|
||||
does not support asynchronous firing.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) {
|
||||
+ // Paper start - add boolean param to optionally fire the event
|
||||
+ return this.addEffect(mobeffect, entity, cause, true);
|
||||
+ }
|
||||
+ public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) {
|
||||
+ // Paper end
|
||||
// org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API
|
||||
if (this.isTickingEffects) {
|
||||
this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause));
|
||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
override = new MobEffectInstance(mobeffect1).update(mobeffect);
|
||||
}
|
||||
|
||||
+ if (fireEvent) { // Paper
|
||||
EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect1, mobeffect, cause, override);
|
||||
+ override = event.isOverride(); // Paper
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
+ } // Paper
|
||||
// CraftBukkit end
|
||||
|
||||
if (mobeffect1 == null) {
|
||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.onEffectAdded(mobeffect, entity);
|
||||
flag = true;
|
||||
// CraftBukkit start
|
||||
- } else if (event.isOverride()) {
|
||||
+ } else if (override) { // Paper
|
||||
mobeffect1.update(mobeffect);
|
||||
this.onEffectUpdated(mobeffect1, true, entity);
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
@@ -0,0 +0,0 @@ public class Spider extends Monster {
|
||||
MobEffect mobeffectlist = entityspider_groupdataspider.effect;
|
||||
|
||||
if (mobeffectlist != null) {
|
||||
- this.addEffect(new MobEffectInstance(mobeffectlist, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit
|
||||
+ this.addEffect(new MobEffectInstance(mobeffectlist, -1), null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN, world instanceof net.minecraft.server.level.ServerLevel); // CraftBukkit // Paper - only fire the effect event if this is happening in a ServerLevel
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue