Files
CatServer/patches/net/minecraft/entity/EntityAreaEffectCloud.java.patch
2019-02-24 22:29:41 +08:00

91 lines
3.8 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/EntityAreaEffectCloud.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityAreaEffectCloud.java
@@ -2,6 +2,9 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -23,6 +26,8 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity;
public class EntityAreaEffectCloud extends Entity
{
@@ -33,15 +38,15 @@
private static final DataParameter<Integer> PARTICLE_PARAM_1 = EntityDataManager.<Integer>createKey(EntityAreaEffectCloud.class, DataSerializers.VARINT);
private static final DataParameter<Integer> PARTICLE_PARAM_2 = EntityDataManager.<Integer>createKey(EntityAreaEffectCloud.class, DataSerializers.VARINT);
private PotionType potion;
- private final List<PotionEffect> effects;
+ public final List<PotionEffect> effects;
private final Map<Entity, Integer> reapplicationDelayMap;
private int duration;
- private int waitTime;
- private int reapplicationDelay;
+ public int waitTime;
+ public int reapplicationDelay;
private boolean colorSet;
- private int durationOnUse;
- private float radiusOnUse;
- private float radiusPerTick;
+ public int durationOnUse;
+ public float radiusOnUse;
+ public float radiusPerTick;
private EntityLivingBase owner;
private UUID ownerUniqueId;
@@ -126,6 +131,22 @@
}
}
+ // CraftBukkit start accessor methods
+ public void refreshEffects() {
+ if (!this.colorSet) {
+ this.getDataManager().set(EntityAreaEffectCloud.COLOR, PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(this.potion, (Collection) this.effects)));
+ }
+ }
+
+ public String getType() {
+ return (PotionType.REGISTRY.getNameForObject(this.potion)).toString();
+ }
+
+ public void setType(String string) {
+ setPotion(PotionType.REGISTRY.getObject(new ResourceLocation(string)));
+ }
+ // CraftBukkit end
+
public int getColor()
{
return ((Integer)this.getDataManager().get(COLOR)).intValue();
@@ -326,6 +347,7 @@
if (!list.isEmpty())
{
+ List<LivingEntity> entities = new ArrayList<>();
for (EntityLivingBase entitylivingbase : list)
{
if (!this.reapplicationDelayMap.containsKey(entitylivingbase) && entitylivingbase.canBeHitWithPotion())
@@ -336,6 +358,15 @@
if (d2 <= (double)(f * f))
{
+ entities.add((LivingEntity) entitylivingbase.getBukkitEntity());
+ }
+ }
+ }
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
+ if (true) { // Preserve NMS spacing and bracket count for smallest diff
+ for (LivingEntity entity : event.getAffectedEntities()) {
+ if (entity instanceof CraftLivingEntity) {
+ EntityLivingBase entitylivingbase = ((CraftLivingEntity) entity).getHandle();
this.reapplicationDelayMap.put(entitylivingbase, Integer.valueOf(this.ticksExisted + this.reapplicationDelay));
for (PotionEffect potioneffect : potions)