use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.
the class TheftStatusEffect method applyUpdateEffect.
@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
if (!entity.world.isClient && entity.age % 20 == 0) {
entity.world.getEntitiesByClass(LivingEntity.class, entity.getBoundingBox().expand(3 * (amplifier + 1)), foundEntity -> foundEntity != entity).forEach(livingEntity -> {
List<StatusEffectInstance> statusEffects = livingEntity.getStatusEffects().stream().filter(instance -> instance.getEffectType().getCategory() == StatusEffectCategory.BENEFICIAL && !instance.isAmbient()).toList();
for (StatusEffectInstance statusEffect : statusEffects) {
entity.addStatusEffect(new StatusEffectInstance(statusEffect.getEffectType(), statusEffect.getDuration() / 2, statusEffect.getAmplifier()));
livingEntity.removeStatusEffect(statusEffect.getEffectType());
}
});
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.
the class CorruptionStatusEffect method applyUpdateEffect.
@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
if (!entity.world.isClient) {
Registry.STATUS_EFFECT.stream().forEach(effect -> {
if (effect.getCategory() == StatusEffectCategory.BENEFICIAL && entity.hasStatusEffect(effect) && !entity.getStatusEffect(effect).isAmbient()) {
StatusEffect inverse = INVERSE_EFFECTS.get(effect);
StatusEffectInstance inverseEffect = null;
if (inverse != null) {
StatusEffectInstance goodEffect = entity.getStatusEffect(effect);
inverseEffect = new StatusEffectInstance(inverse, goodEffect.getDuration(), goodEffect.getAmplifier(), goodEffect.isAmbient(), goodEffect.shouldShowParticles(), goodEffect.shouldShowIcon());
}
entity.removeStatusEffect(effect);
if (inverseEffect != null) {
entity.addStatusEffect(inverseEffect);
}
}
});
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.
the class LeonardEntity method tick.
@Override
public void tick() {
super.tick();
if (!world.isClient) {
bossBar.setPercent(getHealth() / getMaxHealth());
LivingEntity target = getTarget();
int timer = age + getId();
if (timer % 300 == 0 && getHealth() < getMaxHealth() && (target == null || distanceTo(target) < 4)) {
spawnPotion(getBlockPos(), Potions.AWKWARD);
addStatusEffect(new StatusEffectInstance(StatusEffects.INSTANT_HEALTH, 1, 1));
}
if (target != null) {
timeSinceLastAttack++;
if (timeSinceLastAttack >= 600) {
BWUtil.teleport(this, target.getX(), target.getY(), target.getZ(), true);
timeSinceLastAttack = 0;
}
lookAtEntity(target, 360, 360);
if (timer % 40 == 0) {
spawnPotion(target.getBlockPos(), target.isUndead() ? Potions.STRONG_HEALING : Potions.STRONG_HARMING);
}
if (timer % 600 == 0) {
summonMinions(this);
}
} else {
if (getY() > -64) {
heal(8);
}
timeSinceLastAttack = 0;
}
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.
the class LilithEntity method tryAttack.
@Override
public boolean tryAttack(Entity target) {
boolean flag = super.tryAttack(target);
if (flag && target instanceof LivingEntity) {
((LivingEntity) target).addStatusEffect(new StatusEffectInstance(BWStatusEffects.MORTAL_COIL, 1200));
target.setOnFireFor(16);
target.addVelocity(0, 0.2, 0);
swingHand(Hand.MAIN_HAND);
}
return flag;
}
use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.
the class PricklyBeltCraftingRecipe method craft.
@Override
public ItemStack craft(CraftingInventory inv) {
ItemStack pricklyBelt = null, potion = null;
for (int i = 0; i < inv.size(); i++) {
ItemStack stack = inv.getStack(i);
if (stack.getItem() instanceof PricklyBeltItem) {
pricklyBelt = stack.copy();
} else if (stack.getItem() == Items.POTION) {
potion = stack.copy();
}
}
int uses = 1;
List<StatusEffectInstance> effects = !PotionUtil.getCustomPotionEffects(potion).isEmpty() ? PotionUtil.getCustomPotionEffects(potion) : PotionUtil.getPotionEffects(potion);
for (int i = 0; i < effects.size(); i++) {
StatusEffectInstance effect = effects.get(i);
int duration = effect.getDuration();
int amplifier = effect.getAmplifier();
while (duration > 600) {
uses++;
duration /= 2;
}
while (amplifier > 0) {
uses += 2;
amplifier--;
}
effects.set(i, new StatusEffectInstance(effect.getEffectType(), duration, amplifier, effect.isAmbient(), effect.shouldShowParticles(), effect.shouldShowIcon()));
}
if (potion.getOrCreateNbt().contains("PolymorphUUID")) {
pricklyBelt.getOrCreateNbt().putUuid("PolymorphUUID", potion.getNbt().getUuid("PolymorphUUID"));
pricklyBelt.getOrCreateNbt().putString("PolymorphName", potion.getNbt().getString("PolymorphName"));
}
PotionUtil.setCustomPotionEffects(pricklyBelt, effects);
pricklyBelt.getOrCreateNbt().putInt("PotionUses", uses);
return pricklyBelt;
}
Aggregations