Search in sources :

Example 86 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.

the class MultiblockInfoRecipeWrapper method getTooltipStrings.

@Override
public List<String> getTooltipStrings(int mouseX, int mouseY) {
    if (tooltipBlockStack != null && !tooltipBlockStack.isEmpty() && !Mouse.isButtonDown(0)) {
        Minecraft minecraft = Minecraft.getMinecraft();
        ITooltipFlag flag = minecraft.gameSettings.advancedItemTooltips ? TooltipFlags.ADVANCED : TooltipFlags.NORMAL;
        List<String> tooltip = tooltipBlockStack.getTooltip(minecraft.player, flag);
        EnumRarity rarity = tooltipBlockStack.getRarity();
        for (int k = 0; k < tooltip.size(); ++k) {
            if (k == 0) {
                tooltip.set(k, rarity.color + tooltip.get(k));
            } else {
                tooltip.set(k, TextFormatting.GRAY + tooltip.get(k));
            }
        }
        Map<ItemStack, List<ITextComponent>> blockTooltipMap = infoPage.getBlockTooltipMap();
        if (blockTooltipMap.containsKey(tooltipBlockStack)) {
            List<ITextComponent> tooltips = blockTooltipMap.get(tooltipBlockStack);
            for (int i = 0; i < tooltips.size(); i++) {
                // Start at i+1 due to ItemStack name
                tooltip.add(i + 1, tooltips.get(i).getFormattedText());
            }
        }
        return tooltip;
    }
    return Collections.emptyList();
}
Also used : EnumRarity(net.minecraft.item.EnumRarity) ITooltipFlag(net.minecraft.client.util.ITooltipFlag) ITextComponent(net.minecraft.util.text.ITextComponent) NonNullList(net.minecraft.util.NonNullList) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Example 87 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.

the class ElectricBlastFurnaceInfo method generateBlockTooltips.

@Override
protected void generateBlockTooltips() {
    super.generateBlockTooltips();
    ITextComponent tooltip = new TextComponentTranslation("gregtech.multiblock.preview.limit", 10).setStyle(new Style().setColor(TextFormatting.AQUA));
    addBlockTooltip(MetaBlocks.METAL_CASING.getItemVariant(MetalCasingType.INVAR_HEATPROOF), tooltip);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style)

Example 88 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.

the class MultiSmelterInfo method generateBlockTooltips.

@Override
protected void generateBlockTooltips() {
    super.generateBlockTooltips();
    ITextComponent tooltip = new TextComponentTranslation("gregtech.multiblock.preview.limit", 9).setStyle(new Style().setColor(TextFormatting.AQUA));
    addBlockTooltip(MetaBlocks.METAL_CASING.getItemVariant(MetalCasingType.INVAR_HEATPROOF), tooltip);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style)

Example 89 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.

the class ImplosionCompressorInfo method generateBlockTooltips.

@Override
protected void generateBlockTooltips() {
    super.generateBlockTooltips();
    ITextComponent tooltip = new TextComponentTranslation("gregtech.multiblock.preview.limit", 14).setStyle(new Style().setColor(TextFormatting.AQUA));
    addBlockTooltip(MetaBlocks.METAL_CASING.getItemVariant(MetalCasingType.STEEL_SOLID), tooltip);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style)

Example 90 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.

the class ScannerBehavior method onItemUsingTick.

@Override
public void onItemUsingTick(ItemStack stack, EntityPlayer player, int count) {
    if (!player.world.isRemote) {
        Pair<String, Integer> pair = checkCanUseScanner(stack, player, true);
        String failureReason = pair.getLeft();
        if (failureReason == null) {
            ITextComponent component = new TextComponentTranslation("behavior.scanner.analyzing");
            component.getStyle().setColor(TextFormatting.GREEN);
            player.sendStatusMessage(component, true);
            int maxUseCount = pair.getRight();
            if ((getMaxItemUseDuration(stack) - count) >= maxUseCount) {
                player.activeItemStackUseCount = 0;
            }
        } else {
            ITextComponent component = new TextComponentTranslation(failureReason);
            component.getStyle().setColor(TextFormatting.RED);
            player.sendStatusMessage(component, true);
            player.stopActiveHand();
            player.getCooldownTracker().setCooldown(stack.getItem(), 20);
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent)

Aggregations

ITextComponent (net.minecraft.util.text.ITextComponent)116 TextComponentString (net.minecraft.util.text.TextComponentString)53 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)43 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 ItemStack (net.minecraft.item.ItemStack)17 Style (net.minecraft.util.text.Style)17 ClickEvent (net.minecraft.util.text.event.ClickEvent)16 HoverEvent (net.minecraft.util.text.event.HoverEvent)9 ArrayList (java.util.ArrayList)8 BlockPos (net.minecraft.util.math.BlockPos)8 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 Minecraft (net.minecraft.client.Minecraft)5 StringTextComponent (net.minecraft.util.text.StringTextComponent)4 Text (org.spongepowered.api.text.Text)4 MagicBook (cavern.magic.MagicBook)3 SpecialMagic (cavern.magic.SpecialMagic)3 Matcher (java.util.regex.Matcher)3 TileEntity (net.minecraft.tileentity.TileEntity)3 SoundEvent (net.minecraft.util.SoundEvent)3 TextFormatting (net.minecraft.util.text.TextFormatting)3