Search in sources :

Example 11 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.

the class LanguageHandler method buildChatComponent.

private static ITextComponent buildChatComponent(final String key, final Object... message) {
    TextComponentTranslation translation = null;
    int onlyArgsUntil = 0;
    for (final Object object : message) {
        if (object instanceof ITextComponent) {
            if (onlyArgsUntil == 0) {
                onlyArgsUntil = -1;
            }
            break;
        }
        onlyArgsUntil++;
    }
    if (onlyArgsUntil >= 0) {
        final Object[] args = new Object[onlyArgsUntil];
        System.arraycopy(message, 0, args, 0, onlyArgsUntil);
        translation = new TextComponentTranslation(key, args);
    }
    for (final Object object : message) {
        if (translation == null) {
            if (object instanceof ITextComponent) {
                translation = new TextComponentTranslation(key);
            } else {
                translation = new TextComponentTranslation(key, object);
                continue;
            }
        }
        if (object instanceof ITextComponent) {
            translation.appendSibling((ITextComponent) object);
        } else if (object instanceof String) {
            boolean isInArgs = false;
            for (final Object obj : translation.getFormatArgs()) {
                if (obj.equals(object)) {
                    isInArgs = true;
                    break;
                }
            }
            if (!isInArgs) {
                translation.appendText((String) object);
            }
        }
    }
    if (translation == null) {
        translation = new TextComponentTranslation(key);
    }
    return translation;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent)

Example 12 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.

the class AbstractEntityAIBasic method checkForWeapon.

/**
     * Ensures that we have a pickaxe available.
     * Will set {@code needsPickaxe} accordingly.
     *
     * @return true if we have a pickaxe
     */
public boolean checkForWeapon() {
    //Check for a pickaxe
    getOwnBuilding().setNeedsWeapon(!InventoryFunctions.matchFirstInProvider(worker, stack -> stack != null && Utils.doesItemServeAsWeapon(stack)));
    delay += DELAY_RECHECK;
    if (getOwnBuilding().needsWeapon()) {
        if (walkToBuilding()) {
            return false;
        }
        if (isWeaponInHut()) {
            return true;
        }
        requestWithoutSpam(new TextComponentTranslation("com.minecolonies.coremod.job.guard.needWeapon"));
    }
    return getOwnBuilding().needsWeapon();
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 13 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Pearcel-Mod by MiningMark48.

the class ItemPearcelBlockPlacer method onItemRightClick.

@Override
public ActionResult onItemRightClick(ItemStack item, World world, EntityPlayer player, EnumHand hand) {
    if (player.isSneaking()) {
        if (!item.hasTagCompound()) {
            item.setTagCompound(new NBTTagCompound());
            item.getTagCompound().setInteger("mode", 1);
        } else {
            if (item.getTagCompound().getInteger("mode") == 1) {
                item.getTagCompound().setInteger("mode", 2);
                if (!world.isRemote) {
                    player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.pbp.modeChange"))));
                }
            } else {
                item.getTagCompound().setInteger("mode", 1);
                if (!world.isRemote) {
                    player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.pbp.modeChange"))));
                }
            }
        }
        return new ActionResult(EnumActionResult.PASS, item);
    } else {
        return new ActionResult(EnumActionResult.PASS, item);
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 14 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Railcraft by Railcraft.

the class CommandHelpers method sendLocalizedChatMessage.

public static void sendLocalizedChatMessage(ICommandSender sender, Style chatStyle, String locTag, Object... args) {
    TextComponentTranslation chat = new TextComponentTranslation(locTag, args);
    chat.setStyle(chatStyle);
    sender.addChatMessage(chat);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 15 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project RecurrentComplex by Ivorforce.

the class CommandSightInfo method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    WorldStructureGenerationData generationData = WorldStructureGenerationData.get(sender.getEntityWorld());
    WorldStructureGenerationData.Entry entry = generationData.getEntry(UUID.fromString(parameters.get().first().require()));
    if (entry == null)
        throw ServerTranslations.commandException("commands.rcsightinfo.unknown");
    else {
        ITextComponent area = RCTextStyle.area(RCBlockAreas.from(entry.getBoundingBox()));
        ITextComponent sight = RCTextStyle.sight(entry, true);
        if (entry instanceof WorldStructureGenerationData.StructureEntry) {
            WorldStructureGenerationData.StructureEntry structureEntry = (WorldStructureGenerationData.StructureEntry) entry;
            sender.sendMessage(new TextComponentTranslation("commands.rcsightinfo.structure", RCTextStyle.structure(structureEntry.getStructureID()), area, RCTextStyle.copy(String.valueOf(structureEntry.getSeed())), sight));
        } else
            sender.sendMessage(new TextComponentTranslation("commands.rcsightinfo.get", entry.description(), area, sight));
    }
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) WorldStructureGenerationData(ivorius.reccomplex.world.gen.feature.WorldStructureGenerationData) ITextComponent(net.minecraft.util.text.ITextComponent)

Aggregations

TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)35 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 TileEntity (net.minecraft.tileentity.TileEntity)5 TextComponentString (net.minecraft.util.text.TextComponentString)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ActionResult (net.minecraft.util.ActionResult)4 EnumActionResult (net.minecraft.util.EnumActionResult)4 BlockPos (net.minecraft.util.math.BlockPos)4 TargetingInfo (blusunrize.immersiveengineering.api.TargetingInfo)2 IImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable)2 ItemStack (net.minecraft.item.ItemStack)2 ITextComponent (net.minecraft.util.text.ITextComponent)2 DimensionChunkCoords (blusunrize.immersiveengineering.api.DimensionChunkCoords)1 IMultiblock (blusunrize.immersiveengineering.api.MultiblockHandler.IMultiblock)1 IFluxProvider (blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxProvider)1 IFluxReceiver (blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxReceiver)1 AbstractConnection (blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.AbstractConnection)1 Connection (blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection)1 WireType (blusunrize.immersiveengineering.api.energy.wires.WireType)1 MineralMix (blusunrize.immersiveengineering.api.tool.ExcavatorHandler.MineralMix)1