minecraft-src/net/minecraft/world/item/TippedArrowItem.java
2025-07-04 01:41:11 +03:00

34 lines
1.2 KiB
Java

package net.minecraft.world.item;
import java.util.List;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.item.alchemy.Potions;
public class TippedArrowItem extends ArrowItem {
public TippedArrowItem(Item.Properties properties) {
super(properties);
}
@Override
public ItemStack getDefaultInstance() {
ItemStack itemStack = super.getDefaultInstance();
itemStack.set(DataComponents.POTION_CONTENTS, new PotionContents(Potions.POISON));
return itemStack;
}
@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
PotionContents potionContents = stack.get(DataComponents.POTION_CONTENTS);
if (potionContents != null) {
potionContents.addPotionTooltip(tooltipComponents::add, 0.125F, context.tickRate());
}
}
@Override
public String getDescriptionId(ItemStack stack) {
return Potion.getName(stack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).potion(), this.getDescriptionId() + ".effect.");
}
}