Search in sources :

Example 46 with TextComponentTranslation

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

the class DistillationTowerInfo method generateBlockTooltips.

@Override
protected void generateBlockTooltips() {
    super.generateBlockTooltips();
    ITextComponent tooltip = new TextComponentTranslation("gregtech.multiblock.preview.limit_per_layer", 1).setStyle(new Style().setColor(TextFormatting.DARK_RED));
    ITextComponent inputTooltip = new TextComponentTranslation("gregtech.multiblock.preview.only_location", I18n.format("gregtech.multiblock.preview.location.b_c")).setStyle(new Style().setColor(TextFormatting.DARK_RED));
    for (int i = 0; i < GTValues.V.length; i++) {
        addBlockTooltip(MetaTileEntities.FLUID_EXPORT_HATCH[i].getStackForm(), tooltip);
        addBlockTooltip(MetaTileEntities.FLUID_IMPORT_HATCH[i].getStackForm(), inputTooltip);
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style)

Example 47 with TextComponentTranslation

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

the class PyrolyzeOvenInfo method generateBlockTooltips.

@Override
protected void generateBlockTooltips() {
    super.generateBlockTooltips();
    ItemStack coils = MetaBlocks.WIRE_COIL.getItemVariant(BlockWireCoil.CoilType.CUPRONICKEL);
    ITextComponent tooltip = new TextComponentTranslation("gregtech.multiblock.preview.only", coils.getDisplayName()).setStyle(new Style().setColor(TextFormatting.RED));
    addBlockTooltip(coils, tooltip);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style) ItemStack(net.minecraft.item.ItemStack)

Example 48 with TextComponentTranslation

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

the class CommandHand method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (sender instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        ItemStack stackInHand = player.inventory.getCurrentItem();
        if (stackInHand.isEmpty()) {
            throw new CommandException("gregtech.command.util.hand.no_item");
        }
        String registryName = stackInHand.getItem().getRegistryName().toString();
        ClickEvent itemNameEvent = new ClickEvent(Action.OPEN_URL, registryName);
        player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.item_id", registryName, stackInHand.getItemDamage()).setStyle(new Style().setClickEvent(itemNameEvent)));
        IElectricItem electricItem = stackInHand.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null);
        IFluidHandlerItem fluidHandlerItem = stackInHand.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
        if (electricItem != null) {
            player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.electric", electricItem.getCharge(), electricItem.getMaxCharge(), electricItem.getTier(), Boolean.toString(electricItem.canProvideChargeExternally())));
        }
        if (fluidHandlerItem != null) {
            for (IFluidTankProperties properties : fluidHandlerItem.getTankProperties()) {
                FluidStack contents = properties.getContents();
                String fluidName = contents == null ? "empty" : contents.getFluid().getName();
                ClickEvent fluidClickEvent = new ClickEvent(Action.OPEN_URL, fluidName);
                player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.fluid", fluidName, contents == null ? 0 : contents.amount, properties.getCapacity(), Boolean.toString(properties.canFill()), Boolean.toString(properties.canDrain())).setStyle(new Style().setClickEvent(fluidClickEvent)));
            }
        }
        if (stackInHand.getItem() instanceof MetaItem) {
            MetaItem<?> metaItem = (MetaItem<?>) stackInHand.getItem();
            MetaValueItem metaValueItem = metaItem.getItem(stackInHand);
            if (metaValueItem == null) {
                if (metaItem instanceof MaterialMetaItem) {
                    Material material = ((MaterialMetaItem) metaItem).getMaterial(stackInHand);
                    OrePrefix orePrefix = ((MaterialMetaItem) metaItem).getOrePrefix(stackInHand);
                    String oreDictName = new UnificationEntry(orePrefix, material).toString();
                    player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.material_meta_item", orePrefix, material).setStyle(new Style().setClickEvent(new ClickEvent(Action.OPEN_URL, oreDictName))));
                }
            } else {
                if (metaValueItem instanceof ToolMetaItem.MetaToolValueItem) {
                    IToolStats toolStats = ((MetaToolValueItem) metaValueItem).getToolStats();
                    player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.tool_stats", toolStats.getClass().getName()));
                }
                ClipboardUtil.copyToClipboard(player, metaValueItem.unlocalizedName);
                ClickEvent metaItemEvent = new ClickEvent(Action.OPEN_URL, metaValueItem.unlocalizedName);
                player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.meta_item", metaValueItem.unlocalizedName, metaValueItem).setStyle(new Style().setClickEvent(metaItemEvent)));
            }
        }
    } else {
        throw new CommandException("gregtech.command.util.hand.not_a_player");
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IElectricItem(gregtech.api.capability.IElectricItem) MetaValueItem(gregtech.api.items.metaitem.MetaItem.MetaValueItem) MaterialMetaItem(gregtech.api.items.materialitem.MaterialMetaItem) MetaItem(gregtech.api.items.metaitem.MetaItem) ToolMetaItem(gregtech.api.items.toolitem.ToolMetaItem) FluidStack(net.minecraftforge.fluids.FluidStack) ClickEvent(net.minecraft.util.text.event.ClickEvent) OrePrefix(gregtech.api.unification.ore.OrePrefix) UnificationEntry(gregtech.api.unification.stack.UnificationEntry) Material(gregtech.api.unification.material.type.Material) MetaToolValueItem(gregtech.api.items.toolitem.ToolMetaItem.MetaToolValueItem) CommandException(net.minecraft.command.CommandException) IToolStats(gregtech.api.items.toolitem.IToolStats) MaterialMetaItem(gregtech.api.items.materialitem.MaterialMetaItem) IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) IFluidHandlerItem(net.minecraftforge.fluids.capability.IFluidHandlerItem) Style(net.minecraft.util.text.Style) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 49 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation 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 50 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation 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)

Aggregations

TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)502 ItemStack (net.minecraft.item.ItemStack)134 ITextComponent (net.minecraft.util.text.ITextComponent)82 EntityPlayer (net.minecraft.entity.player.EntityPlayer)72 BlockPos (net.minecraft.util.math.BlockPos)70 TextComponentString (net.minecraft.util.text.TextComponentString)66 Style (net.minecraft.util.text.Style)60 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)58 TileEntity (net.minecraft.tileentity.TileEntity)45 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)36 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)33 ArrayList (java.util.ArrayList)32 World (net.minecraft.world.World)30 IBlockState (net.minecraft.block.state.IBlockState)28 EnumFacing (net.minecraft.util.EnumFacing)26 CommandException (net.minecraft.command.CommandException)25 Block (net.minecraft.block.Block)20 Nonnull (javax.annotation.Nonnull)19 WrongUsageException (net.minecraft.command.WrongUsageException)19 EnumActionResult (net.minecraft.util.EnumActionResult)19