package net.minecraft.world.item;

import net.minecraft.network.chat.MutableComponent;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.entity.animal.TropicalFish;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import java.util.List;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.animal.AbstractFish;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.LevelAccessor;
import javax.annotation.Nullable;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.entity.EntityType;

public class FishBucketItem extends BucketItem {
    private final EntityType<?> type;
    
    public FishBucketItem(final EntityType<?> aoq, final Fluid cwz, final Properties a) {
        super(cwz, a);
        this.type = aoq;
    }
    
    @Override
    public void checkExtraContent(final Level bqb, final ItemStack bki, final BlockPos fu) {
        if (!bqb.isClientSide) {
            this.spawn(bqb, bki, fu);
        }
    }
    
    @Override
    protected void playEmptySound(@Nullable final Player bec, final LevelAccessor bqc, final BlockPos fu) {
        bqc.playSound(bec, fu, SoundEvents.BUCKET_EMPTY_FISH, SoundSource.NEUTRAL, 1.0f, 1.0f);
    }
    
    private void spawn(final Level bqb, final ItemStack bki, final BlockPos fu) {
        final Entity aom5 = this.type.spawn(bqb, bki, null, fu, MobSpawnType.BUCKET, true, false);
        if (aom5 != null) {
            ((AbstractFish)aom5).setFromBucket(true);
        }
    }
    
    @Override
    public void appendHoverText(final ItemStack bki, @Nullable final Level bqb, final List<Component> list, final TooltipFlag bls) {
        if (this.type == EntityType.TROPICAL_FISH) {
            final CompoundTag le6 = bki.getTag();
            if (le6 != null && le6.contains("BucketVariantTag", 3)) {
                final int integer7 = le6.getInt("BucketVariantTag");
                final ChatFormatting[] arr8 = { ChatFormatting.ITALIC, ChatFormatting.GRAY };
                final String string9 = "color.minecraft." + TropicalFish.getBaseColor(integer7);
                final String string10 = "color.minecraft." + TropicalFish.getPatternColor(integer7);
                for (int integer8 = 0; integer8 < TropicalFish.COMMON_VARIANTS.length; ++integer8) {
                    if (integer7 == TropicalFish.COMMON_VARIANTS[integer8]) {
                        list.add(new TranslatableComponent(TropicalFish.getPredefinedName(integer8)).withStyle(arr8));
                        return;
                    }
                }
                list.add(new TranslatableComponent(TropicalFish.getFishTypeName(integer7)).withStyle(arr8));
                final MutableComponent mx11 = new TranslatableComponent(string9);
                if (!string9.equals(string10)) {
                    mx11.append(", ").append(new TranslatableComponent(string10));
                }
                mx11.withStyle(arr8);
                list.add(mx11);
            }
        }
    }
}
