diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/AreaEffectCloud.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/entity/AreaEffectCloud.java.patch | 465 |
1 files changed, 465 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/AreaEffectCloud.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/AreaEffectCloud.java.patch new file mode 100644 index 0000000000..f891ebc906 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/AreaEffectCloud.java.patch @@ -0,0 +1,465 @@ +--- a/net/minecraft/world/entity/AreaEffectCloud.java ++++ b/net/minecraft/world/entity/AreaEffectCloud.java +@@ -28,8 +28,11 @@ + import net.minecraft.world.item.alchemy.PotionUtils; + import net.minecraft.world.item.alchemy.Potions; + import net.minecraft.world.level.Level; +-import net.minecraft.world.level.material.PushReaction; ++import net.minecraft.world.level.material.EnumPistonReaction; + import org.slf4j.Logger; ++import org.bukkit.craftbukkit.entity.CraftLivingEntity; ++import org.bukkit.entity.LivingEntity; ++// CraftBukkit end + + public class AreaEffectCloud extends Entity implements TraceableEntity { + +@@ -45,23 +48,23 @@ + public static final float DEFAULT_WIDTH = 6.0F; + public static final float HEIGHT = 0.5F; + private static final String TAG_EFFECTS = "effects"; +- private Potion potion; +- private final List<MobEffectInstance> effects; ++ public Potion potion; ++ public List<MobEffectInstance> effects; + private final Map<Entity, Integer> victims; + private int duration; +- private int waitTime; +- private int reapplicationDelay; ++ public int waitTime; ++ public int reapplicationDelay; + private boolean fixedColor; +- private int durationOnUse; +- private float radiusOnUse; +- private float radiusPerTick; ++ public int durationOnUse; ++ public float radiusOnUse; ++ public float radiusPerTick; + @Nullable +- private LivingEntity owner; ++ private net.minecraft.world.entity.LivingEntity owner; + @Nullable + private UUID ownerUUID; + +- public AreaEffectCloud(EntityType<? extends AreaEffectCloud> entitytype, Level level) { +- super(entitytype, level); ++ public AreaEffectCloud(EntityType<? extends AreaEffectCloud> entityType, Level level) { ++ super(entityType, level); + this.potion = Potions.EMPTY; + this.effects = Lists.newArrayList(); + this.victims = Maps.newHashMap(); +@@ -71,13 +74,12 @@ + this.noPhysics = true; + } + +- public AreaEffectCloud(Level level, double d0, double d1, double d2) { ++ public AreaEffectCloud(Level level, double x, double d1, double y) { + this(EntityType.AREA_EFFECT_CLOUD, level); +- this.setPos(d0, d1, d2); ++ this.setPos(x, d1, y); + } + + @Override +- @Override + protected void defineSynchedData() { + this.getEntityData().define(AreaEffectCloud.DATA_COLOR, 0); + this.getEntityData().define(AreaEffectCloud.DATA_RADIUS, 3.0F); +@@ -85,15 +87,14 @@ + this.getEntityData().define(AreaEffectCloud.DATA_PARTICLE, ParticleTypes.ENTITY_EFFECT); + } + +- public void setRadius(float f) { ++ public void setRadius(float radius) { + if (!this.level().isClientSide) { +- this.getEntityData().set(AreaEffectCloud.DATA_RADIUS, Mth.clamp(f, 0.0F, 32.0F)); ++ this.getEntityData().set(AreaEffectCloud.DATA_RADIUS, Mth.clamp(radius, 0.0F, 32.0F)); + } + + } + + @Override +- @Override + public void refreshDimensions() { + double d0 = this.getX(); + double d1 = this.getY(); +@@ -115,7 +116,7 @@ + + } + +- private void updateColor() { ++ public void updateColor() { + if (this.potion == Potions.EMPTY && this.effects.isEmpty()) { + this.getEntityData().set(AreaEffectCloud.DATA_COLOR, 0); + } else { +@@ -124,8 +125,8 @@ + + } + +- public void addEffect(MobEffectInstance mobeffectinstance) { +- this.effects.add(mobeffectinstance); ++ public void addEffect(MobEffectInstance effectInstance) { ++ this.effects.add(effectInstance); + if (!this.fixedColor) { + this.updateColor(); + } +@@ -136,21 +137,21 @@ + return (Integer) this.getEntityData().get(AreaEffectCloud.DATA_COLOR); + } + +- public void setFixedColor(int i) { ++ public void setFixedColor(int color) { + this.fixedColor = true; +- this.getEntityData().set(AreaEffectCloud.DATA_COLOR, i); ++ this.getEntityData().set(AreaEffectCloud.DATA_COLOR, color); + } + + public ParticleOptions getParticle() { + return (ParticleOptions) this.getEntityData().get(AreaEffectCloud.DATA_PARTICLE); + } + +- public void setParticle(ParticleOptions particleoptions) { +- this.getEntityData().set(AreaEffectCloud.DATA_PARTICLE, particleoptions); ++ public void setParticle(ParticleOptions particleOption) { ++ this.getEntityData().set(AreaEffectCloud.DATA_PARTICLE, particleOption); + } + +- protected void setWaiting(boolean flag) { +- this.getEntityData().set(AreaEffectCloud.DATA_WAITING, flag); ++ protected void setWaiting(boolean waiting) { ++ this.getEntityData().set(AreaEffectCloud.DATA_WAITING, waiting); + } + + public boolean isWaiting() { +@@ -161,12 +162,11 @@ + return this.duration; + } + +- public void setDuration(int i) { +- this.duration = i; ++ public void setDuration(int duration) { ++ this.duration = duration; + } + + @Override +- @Override + public void tick() { + super.tick(); + boolean flag = this.isWaiting(); +@@ -177,7 +177,7 @@ + return; + } + +- ParticleOptions particleoptions = this.getParticle(); ++ ParticleOptions particleparam = this.getParticle(); + int i; + float f1; + +@@ -199,7 +199,7 @@ + double d4; + double d5; + +- if (particleoptions.getType() == ParticleTypes.ENTITY_EFFECT) { ++ if (particleparam.getType() == ParticleTypes.ENTITY_EFFECT) { + int k = flag && this.random.nextBoolean() ? 16777215 : this.getColor(); + + d3 = (double) ((float) (k >> 16 & 255) / 255.0F); +@@ -215,7 +215,7 @@ + d5 = (0.5D - this.random.nextDouble()) * 0.15D; + } + +- this.level().addAlwaysVisibleParticle(particleoptions, d0, d1, d2, d3, d4, d5); ++ this.level().addAlwaysVisibleParticle(particleparam, d0, d1, d2, d3, d4, d5); + } + } else { + if (this.tickCount >= this.waitTime + this.duration) { +@@ -251,41 +251,53 @@ + Iterator iterator = this.potion.getEffects().iterator(); + + while (iterator.hasNext()) { +- MobEffectInstance mobeffectinstance = (MobEffectInstance) iterator.next(); ++ MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); + +- list.add(new MobEffectInstance(mobeffectinstance.getEffect(), mobeffectinstance.mapDuration((l) -> { ++ list.add(new MobEffectInstance(mobeffect.getEffect(), mobeffect.mapDuration((l) -> { + return l / 4; +- }), mobeffectinstance.getAmplifier(), mobeffectinstance.isAmbient(), mobeffectinstance.isVisible())); ++ }), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible())); + } + + list.addAll(this.effects); + if (list.isEmpty()) { + this.victims.clear(); + } else { +- List<LivingEntity> list1 = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); ++ List<net.minecraft.world.entity.LivingEntity> list1 = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, this.getBoundingBox()); + + if (!list1.isEmpty()) { + Iterator iterator1 = list1.iterator(); + ++ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit + while (iterator1.hasNext()) { +- LivingEntity livingentity = (LivingEntity) iterator1.next(); ++ net.minecraft.world.entity.LivingEntity entityliving = (net.minecraft.world.entity.LivingEntity) iterator1.next(); + +- if (!this.victims.containsKey(livingentity) && livingentity.isAffectedByPotions()) { +- double d6 = livingentity.getX() - this.getX(); +- double d7 = livingentity.getZ() - this.getZ(); ++ if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) { ++ double d6 = entityliving.getX() - this.getX(); ++ double d7 = entityliving.getZ() - this.getZ(); + double d8 = d6 * d6 + d7 * d7; + + if (d8 <= (double) (f * f)) { +- this.victims.put(livingentity, this.tickCount + this.reapplicationDelay); ++ // 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) { ++ net.minecraft.world.entity.LivingEntity entityliving = ((CraftLivingEntity) entity).getHandle(); ++ // CraftBukkit end ++ this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); + Iterator iterator2 = list.iterator(); + + while (iterator2.hasNext()) { +- MobEffectInstance mobeffectinstance1 = (MobEffectInstance) iterator2.next(); ++ MobEffectInstance mobeffect1 = (MobEffectInstance) iterator2.next(); + +- if (mobeffectinstance1.getEffect().isInstantenous()) { +- mobeffectinstance1.getEffect().applyInstantenousEffect(this, this.getOwner(), livingentity, mobeffectinstance1.getAmplifier(), 0.5D); ++ if (mobeffect1.getEffect().isInstantenous()) { ++ mobeffect1.getEffect().applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); + } else { +- livingentity.addEffect(new MobEffectInstance(mobeffectinstance1), this); ++ entityliving.addEffect(new MobEffectInstance(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit + } + } + +@@ -320,48 +332,47 @@ + return this.radiusOnUse; + } + +- public void setRadiusOnUse(float f) { +- this.radiusOnUse = f; ++ public void setRadiusOnUse(float radiusOnUse) { ++ this.radiusOnUse = radiusOnUse; + } + + public float getRadiusPerTick() { + return this.radiusPerTick; + } + +- public void setRadiusPerTick(float f) { +- this.radiusPerTick = f; ++ public void setRadiusPerTick(float radiusPerTick) { ++ this.radiusPerTick = radiusPerTick; + } + + public int getDurationOnUse() { + return this.durationOnUse; + } + +- public void setDurationOnUse(int i) { +- this.durationOnUse = i; ++ public void setDurationOnUse(int durationOnUse) { ++ this.durationOnUse = durationOnUse; + } + + public int getWaitTime() { + return this.waitTime; + } + +- public void setWaitTime(int i) { +- this.waitTime = i; ++ public void setWaitTime(int waitTime) { ++ this.waitTime = waitTime; + } + +- public void setOwner(@Nullable LivingEntity livingentity) { +- this.owner = livingentity; +- this.ownerUUID = livingentity == null ? null : livingentity.getUUID(); ++ public void setOwner(@Nullable net.minecraft.world.entity.LivingEntity owner) { ++ this.owner = owner; ++ this.ownerUUID = owner == null ? null : owner.getUUID(); + } + + @Nullable + @Override +- @Override +- public LivingEntity getOwner() { ++ public net.minecraft.world.entity.LivingEntity getOwner() { + if (this.owner == null && this.ownerUUID != null && this.level() instanceof ServerLevel) { + Entity entity = ((ServerLevel) this.level()).getEntity(this.ownerUUID); + +- if (entity instanceof LivingEntity) { +- this.owner = (LivingEntity) entity; ++ if (entity instanceof net.minecraft.world.entity.LivingEntity) { ++ this.owner = (net.minecraft.world.entity.LivingEntity) entity; + } + } + +@@ -369,46 +380,45 @@ + } + + @Override +- @Override +- protected void readAdditionalSaveData(CompoundTag compoundtag) { +- this.tickCount = compoundtag.getInt("Age"); +- this.duration = compoundtag.getInt("Duration"); +- this.waitTime = compoundtag.getInt("WaitTime"); +- this.reapplicationDelay = compoundtag.getInt("ReapplicationDelay"); +- this.durationOnUse = compoundtag.getInt("DurationOnUse"); +- this.radiusOnUse = compoundtag.getFloat("RadiusOnUse"); +- this.radiusPerTick = compoundtag.getFloat("RadiusPerTick"); +- this.setRadius(compoundtag.getFloat("Radius")); +- if (compoundtag.hasUUID("Owner")) { +- this.ownerUUID = compoundtag.getUUID("Owner"); ++ protected void readAdditionalSaveData(CompoundTag compound) { ++ this.tickCount = compound.getInt("Age"); ++ this.duration = compound.getInt("Duration"); ++ this.waitTime = compound.getInt("WaitTime"); ++ this.reapplicationDelay = compound.getInt("ReapplicationDelay"); ++ this.durationOnUse = compound.getInt("DurationOnUse"); ++ this.radiusOnUse = compound.getFloat("RadiusOnUse"); ++ this.radiusPerTick = compound.getFloat("RadiusPerTick"); ++ this.setRadius(compound.getFloat("Radius")); ++ if (compound.hasUUID("Owner")) { ++ this.ownerUUID = compound.getUUID("Owner"); + } + +- if (compoundtag.contains("Particle", 8)) { ++ if (compound.contains("Particle", 8)) { + try { +- this.setParticle(ParticleArgument.readParticle(new StringReader(compoundtag.getString("Particle")), (HolderLookup) BuiltInRegistries.PARTICLE_TYPE.asLookup())); ++ this.setParticle(ParticleArgument.readParticle(new StringReader(compound.getString("Particle")), (HolderLookup) BuiltInRegistries.PARTICLE_TYPE.asLookup())); + } catch (CommandSyntaxException commandsyntaxexception) { +- AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", compoundtag.getString("Particle"), commandsyntaxexception); ++ AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", compound.getString("Particle"), commandsyntaxexception); + } + } + +- if (compoundtag.contains("Color", 99)) { +- this.setFixedColor(compoundtag.getInt("Color")); ++ if (compound.contains("Color", 99)) { ++ this.setFixedColor(compound.getInt("Color")); + } + +- if (compoundtag.contains("Potion", 8)) { +- this.setPotion(PotionUtils.getPotion(compoundtag)); ++ if (compound.contains("Potion", 8)) { ++ this.setPotion(PotionUtils.getPotion(compound)); + } + +- if (compoundtag.contains("effects", 9)) { +- ListTag listtag = compoundtag.getList("effects", 10); ++ if (compound.contains("effects", 9)) { ++ ListTag nbttaglist = compound.getList("effects", 10); + + this.effects.clear(); + +- for (int i = 0; i < listtag.size(); ++i) { +- MobEffectInstance mobeffectinstance = MobEffectInstance.load(listtag.getCompound(i)); ++ for (int i = 0; i < nbttaglist.size(); ++i) { ++ MobEffectInstance mobeffect = MobEffectInstance.load(nbttaglist.getCompound(i)); + +- if (mobeffectinstance != null) { +- this.addEffect(mobeffectinstance); ++ if (mobeffect != null) { ++ this.addEffect(mobeffect); + } + } + } +@@ -416,52 +426,50 @@ + } + + @Override +- @Override +- protected void addAdditionalSaveData(CompoundTag compoundtag) { +- compoundtag.putInt("Age", this.tickCount); +- compoundtag.putInt("Duration", this.duration); +- compoundtag.putInt("WaitTime", this.waitTime); +- compoundtag.putInt("ReapplicationDelay", this.reapplicationDelay); +- compoundtag.putInt("DurationOnUse", this.durationOnUse); +- compoundtag.putFloat("RadiusOnUse", this.radiusOnUse); +- compoundtag.putFloat("RadiusPerTick", this.radiusPerTick); +- compoundtag.putFloat("Radius", this.getRadius()); +- compoundtag.putString("Particle", this.getParticle().writeToString()); ++ protected void addAdditionalSaveData(CompoundTag compound) { ++ compound.putInt("Age", this.tickCount); ++ compound.putInt("Duration", this.duration); ++ compound.putInt("WaitTime", this.waitTime); ++ compound.putInt("ReapplicationDelay", this.reapplicationDelay); ++ compound.putInt("DurationOnUse", this.durationOnUse); ++ compound.putFloat("RadiusOnUse", this.radiusOnUse); ++ compound.putFloat("RadiusPerTick", this.radiusPerTick); ++ compound.putFloat("Radius", this.getRadius()); ++ compound.putString("Particle", this.getParticle().writeToString()); + if (this.ownerUUID != null) { +- compoundtag.putUUID("Owner", this.ownerUUID); ++ compound.putUUID("Owner", this.ownerUUID); + } + + if (this.fixedColor) { +- compoundtag.putInt("Color", this.getColor()); ++ compound.putInt("Color", this.getColor()); + } + + if (this.potion != Potions.EMPTY) { +- compoundtag.putString("Potion", BuiltInRegistries.POTION.getKey(this.potion).toString()); ++ compound.putString("Potion", BuiltInRegistries.POTION.getKey(this.potion).toString()); + } + + if (!this.effects.isEmpty()) { +- ListTag listtag = new ListTag(); ++ ListTag nbttaglist = new ListTag(); + Iterator iterator = this.effects.iterator(); + + while (iterator.hasNext()) { +- MobEffectInstance mobeffectinstance = (MobEffectInstance) iterator.next(); ++ MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); + +- listtag.add(mobeffectinstance.save(new CompoundTag())); ++ nbttaglist.add(mobeffect.save(new CompoundTag())); + } + +- compoundtag.put("effects", listtag); ++ compound.put("effects", nbttaglist); + } + + } + + @Override +- @Override +- public void onSyncedDataUpdated(EntityDataAccessor<?> entitydataaccessor) { +- if (AreaEffectCloud.DATA_RADIUS.equals(entitydataaccessor)) { ++ public void onSyncedDataUpdated(EntityDataAccessor<?> key) { ++ if (AreaEffectCloud.DATA_RADIUS.equals(key)) { + this.refreshDimensions(); + } + +- super.onSyncedDataUpdated(entitydataaccessor); ++ super.onSyncedDataUpdated(key); + } + + public Potion getPotion() { +@@ -469,14 +477,12 @@ + } + + @Override +- @Override +- public PushReaction getPistonPushReaction() { +- return PushReaction.IGNORE; ++ public EnumPistonReaction getPistonPushReaction() { ++ return EnumPistonReaction.IGNORE; + } + + @Override +- @Override +- public EntityDimensions getDimensions(Pose pose) { ++ public EntityDimensions getDimensions(EntityPose pose) { + return EntityDimensions.scalable(this.getRadius() * 2.0F, 0.5F); + } + } |