Search in sources :

Example 31 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Armourers-Workshop by RiskyKen.

the class UndoManager method undoPressed.

public static void undoPressed(EntityPlayer player) {
    String key = player.getCommandSenderName();
    if (!playerUndoData.containsKey(key)) {
        String outOfUndosText = StatCollector.translateToLocal("chat." + LibModInfo.ID.toLowerCase() + ":undo.outOfUndos");
        player.addChatMessage(new ChatComponentText(outOfUndosText));
        return;
    }
    PlayerUndoData playerData = playerUndoData.get(key);
    World world = player.worldObj;
    String undoText = StatCollector.translateToLocal("chat." + LibModInfo.ID.toLowerCase() + ":undo.undoing");
    player.addChatMessage(new ChatComponentText(undoText));
    playerData.playerPressedUndo(world);
    if (playerData.getAvalableUndos() < 1) {
        playerUndoData.remove(key);
    }
}
Also used : World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 32 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Armourers-Workshop by RiskyKen.

the class SkinIOUtils method updateSkins.

public static void updateSkins(EntityPlayer player) {
    File updateDir = new File(System.getProperty("user.dir"), "skin-update");
    if (!updateDir.exists() & updateDir.isDirectory()) {
        player.addChatComponentMessage(new ChatComponentText("Directory skin-update not found."));
        return;
    }
    File outputDir = new File(updateDir, "updated");
    if (!outputDir.exists()) {
        outputDir.mkdir();
    }
    File[] skinFiles = updateDir.listFiles();
    player.addChatComponentMessage(new ChatComponentText(String.format("Found %d skins to be updated.", skinFiles.length)));
    player.addChatComponentMessage(new ChatComponentText("Working..."));
    int successCount = 0;
    int failCount = 0;
    for (int i = 0; i < skinFiles.length; i++) {
        File skinFile = skinFiles[i];
        if (skinFile.isFile()) {
            Skin skin = loadSkinFromFile(skinFile);
            if (skin != null) {
                if (saveSkinToFile(new File(outputDir, skinFile.getName()), skin)) {
                    successCount++;
                } else {
                    ModLogger.log(Level.ERROR, "Failed to update skin " + skinFile.getName());
                    failCount++;
                }
            } else {
                ModLogger.log(Level.ERROR, "Failed to update skin " + skinFile.getName());
                failCount++;
            }
        }
    }
    player.addChatComponentMessage(new ChatComponentText("Finished skin update."));
    player.addChatComponentMessage(new ChatComponentText(String.format("%d skins were updated and %d failed.", successCount, failCount)));
}
Also used : Skin(riskyken.armourersWorkshop.common.skin.data.Skin) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) File(java.io.File) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 33 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ct.js by ChatTriggers.

the class ChatLib method editChat.

/**
 * Edits an already sent chat message
 *
 * @param chatMessage the unformatted text of the message to be replaced
 * @param toReplace   the new message to be put in replace of the old one
 */
public static void editChat(String chatMessage, String toReplace, boolean once) {
    List<ChatLine> drawnChatLines = ReflectionHelper.getPrivateValue(GuiNewChat.class, Client.getChatGUI(), "drawnChatLines", "field_146252_h");
    List<ChatLine> chatLines = ReflectionHelper.getPrivateValue(GuiNewChat.class, Client.getChatGUI(), "chatLines", "field_146252_h");
    ChatComponentText cct = new ChatComponentText(addColor(toReplace));
    for (ChatLine chatLine : drawnChatLines) {
        if (removeFormatting(chatLine.getChatComponent().getUnformattedText()).equals(chatMessage)) {
            ReflectionHelper.setPrivateValue(ChatLine.class, chatLine, cct, "lineString", "field_74541_b");
            if (once)
                break;
        }
    }
    for (ChatLine chatLine : chatLines) {
        if (removeFormatting(chatLine.getChatComponent().getUnformattedText()).equals(chatMessage)) {
            ReflectionHelper.setPrivateValue(ChatLine.class, chatLine, cct, "lineString", "field_74541_b");
            if (once)
                break;
        }
    }
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText) ChatLine(net.minecraft.client.gui.ChatLine)

Example 34 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project ct.js by ChatTriggers.

the class TextComponent method reInstance.

// helper method to re-instance the component
private void reInstance() {
    String text = this.text;
    if (this.formatted)
        text = ChatLib.addColor(text);
    this.chatComponentText = new ChatComponentText(text);
    reInstanceClick();
    reInstanceHover();
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText)

Example 35 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project PneumaticCraft by MineMaarten.

the class ClientEventHandler method onPlayerJoin.

@SubscribeEvent
public void onPlayerJoin(TickEvent.PlayerTickEvent event) {
    if (Config.shouldDisplayChangeNotification && firstTick && event.player.worldObj.isRemote && event.player == FMLClientHandler.instance().getClientPlayerEntity()) {
        event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[PneumaticCraft] Disabled world generation of plants and plant mob drops in your config automatically, oil is turned on as replacement. This is only done once, you can change it as you wish now."));
        firstTick = false;
    }
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)164 ItemStack (net.minecraft.item.ItemStack)27 EntityPlayer (net.minecraft.entity.player.EntityPlayer)24 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)16 TileEntity (net.minecraft.tileentity.TileEntity)13 Entity (net.minecraft.entity.Entity)12 ClickEvent (net.minecraft.event.ClickEvent)10 IChatComponent (net.minecraft.util.IChatComponent)10 ArrayList (java.util.ArrayList)9 ChatStyle (net.minecraft.util.ChatStyle)9 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)8 Block (net.minecraft.block.Block)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)7 File (java.io.File)7 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)7 WrongUsageException (net.minecraft.command.WrongUsageException)7 World (net.minecraft.world.World)6 AccessGroup (com.builtbroken.mc.lib.access.AccessGroup)5 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)5