3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-29 17:40:09 +01:00
Paper/nms-patches/EntityAreaEffectCloud.patch

72 Zeilen
3.3 KiB
Diff

--- a/net/minecraft/server/EntityAreaEffectCloud.java
+++ b/net/minecraft/server/EntityAreaEffectCloud.java
2018-12-25 22:00:00 +01:00
@@ -13,6 +13,10 @@
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
2018-07-15 02:00:00 +02:00
import org.apache.logging.log4j.LogManager;
2018-12-25 22:00:00 +01:00
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity;
+// CraftBukkit end
public class EntityAreaEffectCloud extends Entity {
2019-04-23 04:00:00 +02:00
@@ -105,6 +109,22 @@
}
+ // CraftBukkit start accessor methods
+ public void refreshEffects() {
2016-05-10 13:47:39 +02:00
+ if (!this.hasColor) {
2019-04-23 04:00:00 +02:00
+ this.getDataWatcher().set(EntityAreaEffectCloud.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); // PAIL: rename
+ }
+ }
+
+ public String getType() {
2018-08-26 04:00:00 +02:00
+ return ((MinecraftKey) IRegistry.POTION.getKey(this.potionRegistry)).toString();
+ }
+
+ public void setType(String string) {
2018-08-26 04:00:00 +02:00
+ a(IRegistry.POTION.get(new MinecraftKey(string)));
+ }
+ // CraftBukkit end
+
public int getColor() {
2019-04-23 04:00:00 +02:00
return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.COLOR);
}
2019-04-23 04:00:00 +02:00
@@ -249,6 +269,7 @@
2018-12-25 22:00:00 +01:00
if (!list1.isEmpty()) {
Iterator iterator2 = list1.iterator();
2018-12-25 22:00:00 +01:00
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
while (iterator2.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator2.next();
2019-04-23 04:00:00 +02:00
@@ -258,6 +279,17 @@
double d2 = d0 * d0 + d1 * d1;
if (d2 <= (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
2019-04-23 04:00:00 +02:00
this.affectedEntities.put(entityliving, this.ticksLived + this.reapplicationDelay);
2018-12-25 22:00:00 +01:00
Iterator iterator3 = list.iterator();
2019-04-23 04:00:00 +02:00
@@ -267,7 +299,7 @@
if (mobeffect1.getMobEffect().isInstant()) {
mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else {
- entityliving.addEffect(new MobEffect(mobeffect1));
+ entityliving.addEffect(new MobEffect(mobeffect1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
}
}