content: package com.github.alexthe666.iceandfire.item;
  
  import com.github.alexthe666.iceandfire.IceAndFire;
  import net.minecraft.ChatFormatting;
  import net.minecraft.nbt.CompoundTag;
  import net.minecraft.network.chat.Component;
  import net.minecraft.network.chat.TranslatableComponent;
  import net.minecraft.world.effect.MobEffectInstance;
  import net.minecraft.world.effect.MobEffects;
  import net.minecraft.world.entity.Entity;
  import net.minecraft.world.entity.LivingEntity;
  import net.minecraft.world.entity.Mob;
  import net.minecraft.world.entity.monster.Enemy;
  import net.minecraft.world.item.Item;
  import net.minecraft.world.item.ItemStack;
  import net.minecraft.world.item.TooltipFlag;
  import net.minecraft.world.level.Level;
  import net.minecraft.world.phys.AABB;
  import org.jetbrains.annotations.NotNull;
  
  import javax.annotation.Nullable;
  import java.util.List;
  
  public class ItemCyclopsEye extends Item {
  
      public ItemCyclopsEye() {
          super(new Item.Properties().tab(IceAndFire.TAB_ITEMS).durability(500));
      }
  
      @Override
      public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
          return !oldStack.sameItem(newStack);
      }
  
      @Override
      public void inventoryTick(ItemStack stack, @NotNull Level world, @NotNull Entity entity, int itemSlot, boolean isSelected) {
          if (stack.getTag() == null) {
              stack.setTag(new CompoundTag());
          } else {
              if (entity instanceof LivingEntity) {
                  LivingEntity living = (LivingEntity) entity;
                  if (living.getMainHandItem() == stack || living.getOffhandItem() == stack) {
                      double range = 15;
                      boolean inflictedDamage = false;
                      for (Mob LivingEntity : world.getEntitiesOfClass(Mob.class, new AABB(living.getX() - range, living.getY() - range, living.getZ() - range, living.getX() + range, living.getY() + range, living.getZ() + range))) {
                          if (!LivingEntity.is(living) && !LivingEntity.isAlliedTo(living) && (LivingEntity.getTarget() == living || LivingEntity.getLastHurtByMob() == living || LivingEntity instanceof Enemy)) {
                              LivingEntity.addEffect(new MobEffectInstance(MobEffects.WEAKNESS, 10, 1));
                              inflictedDamage = true;
                          }
                      }
                      if (inflictedDamage) {
                          stack.getTag().putInt("HurtingTicks", stack.getTag().getInt("HurtingTicks") + 1);
                      }
                  }
                  if (stack.getTag().getInt("HurtingTicks") > 120) {
                      stack.hurtAndBreak(1, (LivingEntity) entity, (p_220017_1_) -> {
                      });
                      stack.getTag().putInt("HurtingTicks", 0);
                  }
              }
  
          }
      }
  
      @Override
      public void appendHoverText(@NotNull ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, @NotNull TooltipFlag flagIn) {
          tooltip.add(new TranslatableComponent("item.iceandfire.legendary_weapon.desc").withStyle(ChatFormatting.GRAY));
          tooltip.add(new TranslatableComponent("item.iceandfire.cyclops_eye.desc_0").withStyle(ChatFormatting.GRAY));
          tooltip.add(new TranslatableComponent("item.iceandfire.cyclops_eye.desc_1").withStyle(ChatFormatting.GRAY));
      }
  }
  