use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.
the class IllnessFortune method finish.
@Override
public boolean finish(ServerWorld world, PlayerEntity target) {
target.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 600, 1));
target.addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 600, 1));
return super.finish(world, target);
}
use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.
the class PlayerEntityMixin method eat.
@Inject(method = "eatFood", at = @At("HEAD"))
private void eat(World world, ItemStack stack, CallbackInfoReturnable<ItemStack> callbackInfo) {
if (!world.isClient) {
FoodComponent foodComponent = stack.getItem().getFoodComponent();
if (foodComponent != null) {
boolean vampire = BewitchmentAPI.isVampire(this, true);
if (vampire || (BewitchmentAPI.isWerewolf(this, true) && !foodComponent.isMeat())) {
addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 100, 1));
addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 100, 1));
addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 100, 1));
addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 1));
}
if (vampire && (stack.getItem() == BWObjects.GARLIC || stack.getItem() == BWObjects.GRILLED_GARLIC || stack.getItem() == BWObjects.GARLIC_BREAD)) {
damage(BWDamageSources.MAGIC_COPY, Float.MAX_VALUE);
}
}
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.
the class ContractsComponent method serverTick.
@Override
public void serverTick() {
int level = 0;
for (int i = contracts.size() - 1; i >= 0; i--) {
Contract.Instance instance = contracts.get(i);
level += instance.cost;
instance.contract.tick(obj);
instance.duration--;
if (instance.duration <= 0) {
contracts.remove(i);
}
}
if (level > 0) {
obj.addStatusEffect(new StatusEffectInstance(BWStatusEffects.PACT, 10, level - 1, true, false));
if (obj.getHealth() > obj.getMaxHealth()) {
obj.setHealth(obj.getMaxHealth());
}
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.
the class TransformationComponent method serverTick.
@Override
public void serverTick() {
boolean vampire = BewitchmentAPI.isVampire(obj, true);
if (vampire) {
boolean pledgedToLilith = BewitchmentAPI.isPledged(obj, BWPledges.LILITH);
obj.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
if (BWComponents.RESPAWN_TIMER_COMPONENT.get(obj).getRespawnTimer() <= 0 && obj.world.isDay() && !obj.world.isRaining() && obj.world.isSkyVisible(obj.getBlockPos()) && AllowVampireBurn.EVENT.invoker().allowBurn(obj)) {
obj.setOnFireFor(8);
}
HungerManager hungerManager = obj.getHungerManager();
if (BWComponents.BLOOD_COMPONENT.get(obj).getBlood() > 0) {
if (AllowVampireHeal.EVENT.invoker().allowHeal(obj, pledgedToLilith)) {
if (obj.age % (pledgedToLilith ? 30 : 40) == 0) {
if (obj.getHealth() < obj.getMaxHealth()) {
obj.heal(1);
hungerManager.addExhaustion(3);
}
if ((hungerManager.isNotFull() || hungerManager.getSaturationLevel() < 10) && BWComponents.BLOOD_COMPONENT.get(obj).drainBlood(1, false)) {
hungerManager.add(1, 20);
}
}
}
} else {
if (isAlternateForm()) {
TransformationAbilityPacket.useAbility(obj, true);
}
hungerManager.addExhaustion(Float.MAX_VALUE);
}
if (isAlternateForm()) {
hungerManager.addExhaustion(0.5f);
if (!pledgedToLilith) {
TransformationAbilityPacket.useAbility(obj, true);
}
}
}
if (BewitchmentAPI.isWerewolf(obj, true)) {
AdditionalWerewolfDataComponent additionalWerewolfDataComponent = BWComponents.ADDITIONAL_WEREWOLF_DATA_COMPONENT.get(obj);
boolean forced = additionalWerewolfDataComponent.isForcedTransformation();
if (!obj.isCreative() && !obj.isSpectator() && !isAlternateForm() && obj.world.isNight() && BewitchmentAPI.getMoonPhase(obj.world) == 0 && obj.world.isSkyVisible(obj.getBlockPos())) {
TransformationAbilityPacket.useAbility(obj, true);
additionalWerewolfDataComponent.setForcedTransformation(true);
} else if (isAlternateForm() && forced && (obj.world.isDay() || BewitchmentAPI.getMoonPhase(obj.world) != 0)) {
TransformationAbilityPacket.useAbility(obj, true);
additionalWerewolfDataComponent.setForcedTransformation(false);
}
if (isAlternateForm()) {
obj.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
Set<ItemStack> toDrop = new HashSet<>();
obj.getArmorItems().forEach(stack -> {
if (!stack.isEmpty()) {
toDrop.add(stack);
}
});
if (BWUtil.isTool(obj.getMainHandStack())) {
toDrop.add(obj.getMainHandStack());
}
if (BWUtil.isTool(obj.getOffHandStack())) {
toDrop.add(obj.getOffHandStack());
}
toDrop.forEach(stack -> {
int firstEmptyInventorySlot = getFirstEmptyInventorySlot();
if (firstEmptyInventorySlot != -1) {
obj.getInventory().setStack(firstEmptyInventorySlot, stack.split(stack.getCount()));
} else {
obj.dropStack(stack.split(stack.getCount()));
}
});
if (!forced && !BewitchmentAPI.isPledged(obj, BWPledges.HERNE)) {
TransformationAbilityPacket.useAbility(obj, true);
}
}
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project WK by witches-kitchen.
the class CuSithEntity method tryAttack.
@Override
public boolean tryAttack(Entity target) {
boolean flag = super.tryAttack(target);
Random rand = new Random();
int i = rand.nextInt(100);
if (i <= 33) {
if (target instanceof LivingEntity) {
((LivingEntity) target).addStatusEffect(new StatusEffectInstance(WKStatusEffects.HORROR, 1000));
this.playSound(WKSoundEvents.CUSITH_HOWL_EVENT, 0.8F, 0.7F);
}
}
return flag;
}
Aggregations