75 lines
3.2 KiB
Java
75 lines
3.2 KiB
Java
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<?> akr, final Fluid cof, final Properties a) {
|
|
super(cof, a);
|
|
this.type = akr;
|
|
}
|
|
|
|
@Override
|
|
public void checkExtraContent(final Level bjt, final ItemStack bek, final BlockPos fk) {
|
|
if (!bjt.isClientSide) {
|
|
this.spawn(bjt, bek, fk);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void playEmptySound(@Nullable final Player ayg, final LevelAccessor bju, final BlockPos fk) {
|
|
bju.playSound(ayg, fk, SoundEvents.BUCKET_EMPTY_FISH, SoundSource.NEUTRAL, 1.0f, 1.0f);
|
|
}
|
|
|
|
private void spawn(final Level bjt, final ItemStack bek, final BlockPos fk) {
|
|
final Entity akn5 = this.type.spawn(bjt, bek, null, fk, MobSpawnType.BUCKET, true, false);
|
|
if (akn5 != null) {
|
|
((AbstractFish)akn5).setFromBucket(true);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void appendHoverText(final ItemStack bek, @Nullable final Level bjt, final List<Component> list, final TooltipFlag bft) {
|
|
if (this.type == EntityType.TROPICAL_FISH) {
|
|
final CompoundTag jt6 = bek.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);
|
|
}
|
|
}
|
|
}
|
|
}
|