Search in sources :

Example 51 with ITextComponent

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

the class BlockSurfaceRockDeprecated method getMagnifyResults.

@Override
public List<ITextComponent> getMagnifyResults(IBlockAccess world, BlockPos pos, IBlockState blockState, EntityPlayer player) {
    ArrayList<ITextComponent> result = new ArrayList<>();
    ITextComponent materialComponent = new TextComponentTranslation(getStoneMaterial(world, pos, blockState).getUnlocalizedName());
    materialComponent.getStyle().setColor(TextFormatting.GREEN);
    result.add(new TextComponentTranslation("gregtech.block.surface_rock.material", materialComponent));
    return result;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList)

Example 52 with ITextComponent

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

the class MetaTileEntityLargeTurbine method addDisplayText.

@Override
protected void addDisplayText(List<ITextComponent> textList) {
    if (isStructureFormed()) {
        MetaTileEntityRotorHolder rotorHolder = getRotorHolder();
        FluidStack fuelStack = ((LargeTurbineWorkableHandler) workableHandler).getFuelStack();
        int fuelAmount = fuelStack == null ? 0 : fuelStack.amount;
        ITextComponent fuelName = new TextComponentTranslation(fuelAmount == 0 ? "gregtech.fluid.empty" : fuelStack.getUnlocalizedName());
        textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.fuel_amount", fuelAmount, fuelName));
        if (rotorHolder.getRotorEfficiency() > 0.0) {
            textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_speed", rotorHolder.getCurrentRotorSpeed(), rotorHolder.getMaxRotorSpeed()));
            textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_efficiency", (int) (rotorHolder.getRotorEfficiency() * 100)));
            int rotorDurability = (int) (rotorHolder.getRotorDurability() * 100);
            if (rotorDurability > MIN_DURABILITY_TO_WARN) {
                textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_durability", rotorDurability));
            } else {
                textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.low_rotor_durability", MIN_DURABILITY_TO_WARN, rotorDurability).setStyle(new Style().setColor(TextFormatting.RED)));
            }
        }
        if (!isRotorFaceFree()) {
            textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.obstructed").setStyle(new Style().setColor(TextFormatting.RED)));
        }
    }
    super.addDisplayText(textList);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) FluidStack(net.minecraftforge.fluids.FluidStack) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style) MetaTileEntityRotorHolder(gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityRotorHolder)

Example 53 with ITextComponent

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

the class MetaTileEntityDieselEngine method addDisplayText.

@Override
protected void addDisplayText(List<ITextComponent> textList) {
    if (isStructureFormed()) {
        FluidStack lubricantStack = importFluidHandler.drain(Materials.Lubricant.getFluid(Integer.MAX_VALUE), false);
        FluidStack oxygenStack = importFluidHandler.drain(Materials.Oxygen.getFluid(Integer.MAX_VALUE), false);
        FluidStack fuelStack = ((DieselEngineWorkableHandler) workableHandler).getFuelStack();
        int lubricantAmount = lubricantStack == null ? 0 : lubricantStack.amount;
        int oxygenAmount = oxygenStack == null ? 0 : oxygenStack.amount;
        int fuelAmount = fuelStack == null ? 0 : fuelStack.amount;
        ITextComponent fuelName = new TextComponentTranslation(fuelAmount == 0 ? "gregtech.fluid.empty" : fuelStack.getUnlocalizedName());
        textList.add(new TextComponentTranslation("gregtech.multiblock.diesel_engine.lubricant_amount", lubricantAmount));
        textList.add(new TextComponentTranslation("gregtech.multiblock.diesel_engine.fuel_amount", fuelAmount, fuelName));
        textList.add(new TextComponentTranslation("gregtech.multiblock.diesel_engine.oxygen_amount", oxygenAmount));
        textList.add(new TextComponentTranslation(oxygenAmount >= 2 ? "gregtech.multiblock.diesel_engine.oxygen_boosted" : "gregtech.multiblock.diesel_engine.supply_oxygen_to_boost"));
    }
    super.addDisplayText(textList);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) FluidStack(net.minecraftforge.fluids.FluidStack) ITextComponent(net.minecraft.util.text.ITextComponent)

Example 54 with ITextComponent

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

the class ModeSwitchBehavior method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    if (player.isSneaking()) {
        T currentMode = getModeFromItemStack(itemStack);
        int currentModeIndex = ArrayUtils.indexOf(enumConstants, currentMode);
        T nextMode = enumConstants[(currentModeIndex + 1) % enumConstants.length];
        setModeForItemStack(itemStack, nextMode);
        ITextComponent newModeComponent = new TextComponentTranslation(nextMode.getUnlocalizedName());
        ITextComponent textComponent = new TextComponentTranslation("metaitem.behavior.mode_switch.mode_switched", newModeComponent);
        player.sendStatusMessage(textComponent, true);
        return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
    }
    return ActionResult.newResult(EnumActionResult.PASS, itemStack);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) ItemStack(net.minecraft.item.ItemStack)

Example 55 with ITextComponent

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

the class ScannerBehavior method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, EntityPlayer player) {
    if (!player.world.isRemote) {
        Pair<BlockPos, IBlockState> hitBlock = getHitBlock(player);
        if (hitBlock != null && checkCanUseScanner(stack, player, false).getLeft() == null) {
            ITextComponent component = new TextComponentTranslation("behavior.scanner.analyzing_complete");
            component.getStyle().setColor(TextFormatting.GOLD);
            player.sendStatusMessage(component, true);
            IScannableBlock magnifiableBlock = ((IScannableBlock) hitBlock.getRight().getBlock());
            List<ITextComponent> text = magnifiableBlock.getMagnifyResults(player.world, hitBlock.getLeft(), hitBlock.getRight(), player);
            text.forEach(player::sendMessage);
        }
    }
    return stack;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBlockState(net.minecraft.block.state.IBlockState) IScannableBlock(gregtech.api.items.toolitem.IScannableBlock) ITextComponent(net.minecraft.util.text.ITextComponent) BlockPos(net.minecraft.util.math.BlockPos)

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