use of slimeknights.tconstruct.library.utils.TooltipKey in project TinkersConstruct by SlimeKnights.
the class TankItem method appendHoverText.
@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
if (stack.hasTag()) {
FluidTank tank = getFluidTank(stack);
if (tank.getFluidAmount() > 0) {
tooltip.add(new TranslatableComponent(KEY_FLUID, tank.getFluid().getDisplayName()).withStyle(ChatFormatting.GRAY));
int amount = tank.getFluidAmount();
TooltipKey key = SafeClientAccess.getTooltipKey();
if (tank.getCapacity() % FluidValues.INGOT != 0 || key == TooltipKey.SHIFT) {
tooltip.add(new TranslatableComponent(KEY_MB, amount).withStyle(ChatFormatting.GRAY));
} else {
int ingots = amount / FluidValues.INGOT;
int mb = amount % FluidValues.INGOT;
if (mb == 0) {
tooltip.add(new TranslatableComponent(KEY_INGOTS, ingots).withStyle(ChatFormatting.GRAY));
} else {
tooltip.add(new TranslatableComponent(KEY_MIXED, ingots, mb).withStyle(ChatFormatting.GRAY));
}
if (key != TooltipKey.UNKNOWN) {
tooltip.add(FluidTooltipHandler.HOLD_SHIFT);
}
}
}
} else {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
}
}
use of slimeknights.tconstruct.library.utils.TooltipKey in project TinkersConstruct by SlimeKnights.
the class ToolPartItem method appendHoverText.
@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
if (TooltipUtil.isDisplay(stack)) {
return;
}
// add all traits to the info
MaterialVariantId materialVariant = this.getMaterial(stack);
MaterialId id = materialVariant.getId();
if (!materialVariant.equals(IMaterial.UNKNOWN_ID)) {
if (canUseMaterial(id)) {
for (ModifierEntry entry : MaterialRegistry.getInstance().getTraits(id, getStatType())) {
tooltip.add(entry.getModifier().getDisplayName(entry.getLevel()));
}
// add stats
if (Config.CLIENT.extraToolTips.get()) {
TooltipKey key = SafeClientAccess.getTooltipKey();
if (key == TooltipKey.SHIFT || key == TooltipKey.UNKNOWN) {
this.addStatInfoTooltip(id, tooltip);
} else {
// info tooltip for detailed and component info
tooltip.add(TextComponent.EMPTY);
tooltip.add(TooltipUtil.TOOLTIP_HOLD_SHIFT);
}
}
} else {
// is the material missing, or is it not valid for this stat type?
IMaterial material = MaterialRegistry.getMaterial(id);
if (material == IMaterial.UNKNOWN) {
tooltip.add(new TranslatableComponent(MISSING_MATERIAL_KEY, id));
} else {
tooltip.add(new TranslatableComponent(MISSING_STATS_KEY, materialStatId).withStyle(ChatFormatting.GRAY));
}
}
}
// mod handled by getCreatorModId
}
Aggregations