package com.dairymoose.modernlife.items;

import com.dairymoose.modernlife.blocks.gui.GuitarScreen;
import com.google.common.collect.Sets;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/* loaded from: outputsrg.jar:com/dairymoose/modernlife/items/GuitarItem.class */
public class GuitarItem extends DiggerItem {
    private static final Logger LOGGER = LogManager.getLogger();
    private static final Set<Material> DIGGABLE_MATERIALS = Sets.newHashSet(new Material[]{Material.WOOD, Material.NETHER_WOOD, Material.PLANT, Material.REPLACEABLE_PLANT, Material.BAMBOO, Material.VEGETABLE});
    private static final Set<Block> OTHER_DIGGABLE_BLOCKS = Sets.newHashSet(new Block[]{Blocks.LADDER, Blocks.SCAFFOLDING, Blocks.OAK_BUTTON, Blocks.SPRUCE_BUTTON, Blocks.BIRCH_BUTTON, Blocks.JUNGLE_BUTTON, Blocks.DARK_OAK_BUTTON, Blocks.ACACIA_BUTTON, Blocks.CRIMSON_BUTTON, Blocks.WARPED_BUTTON});
    private final ScheduledExecutorService scheduler;
    int counter;
    boolean canChange;

    /* loaded from: outputsrg.jar:com/dairymoose/modernlife/items/GuitarItem$Tuning.class */
    public enum Tuning {
        STRING_E,
        STRING_A,
        STRING_D,
        STRING_G,
        STRING_B,
        STRING_HI_E
    }

    public GuitarItem(Tier p_i48530_1_, float p_i48530_2_, float p_i48530_3_, Properties p_i48530_4_) {
        super(p_i48530_2_, p_i48530_3_, p_i48530_1_, BlockTags.LEAVES, p_i48530_4_);
        this.scheduler = Executors.newScheduledThreadPool(3);
        this.counter = 1;
        this.canChange = true;
    }

    public float getDestroySpeed(ItemStack p_150893_1_, BlockState p_150893_2_) {
        Material material = p_150893_2_.m_60767_();
        return DIGGABLE_MATERIALS.contains(material) ? this.speed : super.getDestroySpeed(p_150893_1_, p_150893_2_);
    }

    public void appendHoverText(ItemStack itemStack, @Nullable Level world, List<Component> text, TooltipFlag flag) {
        text.add(new TextComponent("Right click to use"));
        text.add(new TextComponent("* Standard Tuning (EADGBE)"));
    }

    float getFreqForFret(Tuning string, int fret) {
        if (string == Tuning.STRING_E) {
            return (float) ((77.657d * Math.exp(0.0579d * fret)) / 155.55999755859375d);
        }
        return 82.0f;
    }

    @OnlyIn(Dist.CLIENT)
    public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
        if (world.isClientSide) {
            Minecraft.getInstance().setScreen(new GuitarScreen(world, player));
        }
        return super.use(world, player, hand);
    }
}
