package net.minecraft.world.item;

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<?> aku, final Fluid coi, final Properties a) {
        super(coi, a);
        this.type = aku;
    }
    
    @Override
    public void checkExtraContent(final Level bjw, final ItemStack ben, final BlockPos fk) {
        if (!bjw.isClientSide) {
            this.spawn(bjw, ben, fk);
        }
    }
    
    @Override
    protected void playEmptySound(@Nullable final Player ayj, final LevelAccessor bjx, final BlockPos fk) {
        bjx.playSound(ayj, fk, SoundEvents.BUCKET_EMPTY_FISH, SoundSource.NEUTRAL, 1.0f, 1.0f);
    }
    
    private void spawn(final Level bjw, final ItemStack ben, final BlockPos fk) {
        final Entity akq5 = this.type.spawn(bjw, ben, null, fk, MobSpawnType.BUCKET, true, false);
        if (akq5 != null) {
            ((AbstractFish)akq5).setFromBucket(true);
        }
    }
    
    @Override
    public void appendHoverText(final ItemStack ben, @Nullable final Level bjw, final List<Component> list, final TooltipFlag bfw) {
        if (this.type == EntityType.TROPICAL_FISH) {
            final CompoundTag jt6 = ben.getTag();
            if (jt6 != null && jt6.contains("BucketVariantTag", 3)) {
                final int integer7 = jt6.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), new Object[0]).withStyle(arr8));
                        return;
                    }
                }
                list.add(new TranslatableComponent(TropicalFish.getFishTypeName(integer7), new Object[0]).withStyle(arr8));
                final Component lf11 = new TranslatableComponent(string9, new Object[0]);
                if (!string9.equals(string10)) {
                    lf11.append(", ").append(new TranslatableComponent(string10, new Object[0]));
                }
                lf11.withStyle(arr8);
                list.add(lf11);
            }
        }
    }
}
