Skip to content

Commit

Permalink
feat: make Insomnia Cure serum apply the Drowsy status effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Aug 2, 2023
1 parent ce494f8 commit 97bc661
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.elenterius.biomancy.serum;

import com.github.elenterius.biomancy.init.ModMobEffects;
import com.github.elenterius.biomancy.styles.TextComponentUtil;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -8,6 +9,8 @@
import net.minecraft.stats.Stats;
import net.minecraft.stats.StatsCounter;
import net.minecraft.util.Mth;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;

Expand Down Expand Up @@ -49,6 +52,13 @@ public boolean canAffectPlayerSelf(CompoundTag tag, Player targetSelf) {
@Override
public void affectPlayerSelf(CompoundTag tag, ServerPlayer targetSelf) {
targetSelf.resetStat(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)); //reset insomnia
applyDrowsyEffect(targetSelf);
}

private static void applyDrowsyEffect(LivingEntity livingEntity) {
livingEntity.addEffect(new MobEffectInstance(ModMobEffects.DROWSY.get(), 4 * 60 * 20, 0, false, false, true));
livingEntity.addEffect(new MobEffectInstance(MobEffects.DARKNESS, 10 * 20, 0, false, false, false));
livingEntity.addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20 * 20, 0, false, false, false));
}

private int getTimeSinceRest(Player player) {
Expand Down

0 comments on commit 97bc661

Please sign in to comment.