Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
import net.minecraft.enchantment.EnchantmentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraftforge.fml.LogicalSide;
import hellfirepvp.astralsorcery.common.data.research.PlayerProgress;
import hellfirepvp.astralsorcery.common.data.research.ResearchHelper;

/**
* This class is part of the Astral Sorcery Mod
Expand All @@ -32,10 +36,28 @@ public EnchantmentNightVision() {
@Override
public void tick(PlayerEntity player, LogicalSide side, int level) {
if (side.isServer()) {
player.addPotionEffect(new EffectInstance(Effects.NIGHT_VISION, 300, level - 1, true, false));
PlayerProgress prog = ResearchHelper.getProgress(player, LogicalSide.SERVER);
if (prog.doPerkAbilities()) {
EffectInstance effect = new EffectInstance(Effects.NIGHT_VISION, 300, level - 1, true, false);
effect.addCurativeItem(getCurativeMarkerItem());
player.addPotionEffect(effect);
} else {
player.curePotionEffects(getCurativeMarkerItem());
}
}
}

private static ItemStack getCurativeMarkerItem() {
ItemStack curativeItem = new ItemStack(Items.BARRIER, 1);

CompoundNBT nbtMarker = new CompoundNBT();
nbtMarker.putBoolean("astralNightVision", true);

curativeItem.setTag(nbtMarker);

return curativeItem;
}

@Override
public boolean canApply(ItemStack stack) {
return this.type.canEnchantItem(stack.getItem());
Expand Down