use of com.minecolonies.coremod.colony.jobs.JobDruid in project minecolonies by Minecolonies.
the class DruidPotionEntity method applySplash.
@Override
public void applySplash(@NotNull List<EffectInstance> effects, @Nullable Entity entity) {
final AbstractEntityCitizen citizen = this.getOwner();
if (citizen != null && citizen.getCitizenData().getJob() instanceof JobDruid) {
final AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(SPLASH_SIZE, SPLASH_HEIGTH, SPLASH_SIZE);
final List<LivingEntity> list = this.level.getEntitiesOfClass(LivingEntity.class, axisalignedbb);
if (!list.isEmpty()) {
for (final LivingEntity livingentity : list) {
if (livingentity.isAffectedByPotions()) {
final double distanceSq = this.distanceToSqr(livingentity);
if (distanceSq < MAX_DISTANCE) {
double d1 = 1.0D - Math.sqrt(distanceSq) / 4.0D;
if (livingentity == entity) {
d1 = 1.0D;
}
for (final EffectInstance effectinstance : effects) {
final Effect effect = effectinstance.getEffect();
if (entitySelectionPredicate == null || entitySelectionPredicate.test(livingentity, effect)) {
if (effect.isInstantenous()) {
effect.applyInstantenousEffect(this, this.getOwner(), livingentity, effectinstance.getAmplifier(), d1);
} else {
final int duration = (int) (d1 * (double) effectinstance.getDuration());
livingentity.addEffect(new EffectInstance(effect, duration, effectinstance.getAmplifier(), effectinstance.isAmbient(), effectinstance.isVisible()));
}
}
}
}
}
}
}
}
}
use of com.minecolonies.coremod.colony.jobs.JobDruid in project minecolonies by ldtteam.
the class DruidPotionEntity method applySplash.
@Override
public void applySplash(@NotNull List<EffectInstance> effects, @Nullable Entity entity) {
final AbstractEntityCitizen citizen = this.getOwner();
if (citizen != null && citizen.getCitizenData() != null && citizen.getCitizenData().getJob() instanceof JobDruid) {
final AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(SPLASH_SIZE, SPLASH_HEIGTH, SPLASH_SIZE);
final List<LivingEntity> list = this.level.getEntitiesOfClass(LivingEntity.class, axisalignedbb);
if (!list.isEmpty()) {
for (final LivingEntity livingentity : list) {
if (livingentity.isAffectedByPotions()) {
final double distanceSq = this.distanceToSqr(livingentity);
if (distanceSq < MAX_DISTANCE) {
double d1 = 1.0D - Math.sqrt(distanceSq) / 4.0D;
if (livingentity == entity) {
d1 = 1.0D;
}
for (final EffectInstance effectinstance : effects) {
final Effect effect = effectinstance.getEffect();
if (entitySelectionPredicate == null || entitySelectionPredicate.test(livingentity, effect)) {
if (effect.isInstantenous()) {
effect.applyInstantenousEffect(this, this.getOwner(), livingentity, effectinstance.getAmplifier(), d1);
} else {
final int duration = (int) (d1 * (double) effectinstance.getDuration());
livingentity.addEffect(new EffectInstance(effect, duration, effectinstance.getAmplifier(), effectinstance.isAmbient(), effectinstance.isVisible()));
}
}
}
}
}
}
}
}
}
Aggregations