PaperMC/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch
CraftBukkit/Spigot b3a8254758 Update to Minecraft 1.17
By: md_5 <git@md-5.net>
2021-06-11 15:00:00 +10:00

73 lines
3.4 KiB
Diff

--- a/net/minecraft/world/entity/EntityAreaEffectCloud.java
+++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java
@@ -32,6 +32,12 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import net.minecraft.resources.MinecraftKey;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity;
+// CraftBukkit end
+
public class EntityAreaEffectCloud extends Entity {
private static final Logger LOGGER = LogManager.getLogger();
@@ -127,6 +133,22 @@
}
+ // CraftBukkit start accessor methods
+ public void refreshEffects() {
+ if (!this.fixedColor) {
+ this.getDataWatcher().set(EntityAreaEffectCloud.DATA_COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potion, (Collection) this.effects))); // PAIL: rename
+ }
+ }
+
+ public String getType() {
+ return ((MinecraftKey) IRegistry.POTION.getKey(this.potion)).toString();
+ }
+
+ public void setType(String string) {
+ a(IRegistry.POTION.get(new MinecraftKey(string)));
+ }
+ // CraftBukkit end
+
public int getColor() {
return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.DATA_COLOR);
}
@@ -259,6 +281,7 @@
if (!list1.isEmpty()) {
Iterator iterator1 = list1.iterator();
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
while (iterator1.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator1.next();
@@ -268,6 +291,17 @@
double d8 = d6 * d6 + d7 * d7;
if (d8 <= (double) (f * f)) {
+ // CraftBukkit start
+ entities.add((LivingEntity) entityliving.getBukkitEntity());
+ }
+ }
+ }
+ 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);
Iterator iterator2 = list.iterator();
@@ -277,7 +311,7 @@
if (mobeffect1.getMobEffect().isInstant()) {
mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else {
- entityliving.addEffect(new MobEffect(mobeffect1), this);
+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
}
}