Java Code Examples for net.minecraft.util.text.TextComponentString

The following are top voted examples for showing how to use net.minecraft.util.text.TextComponentString. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Backmemed   File: EntityRenderer.java   View source code 6 votes vote down vote up
private void checkLoadVisibleChunks(Entity p_checkLoadVisibleChunks_1_, float p_checkLoadVisibleChunks_2_, ICamera p_checkLoadVisibleChunks_3_, boolean p_checkLoadVisibleChunks_4_)
{
    if (this.loadVisibleChunks)
    {
        this.loadVisibleChunks = false;
        this.loadAllVisibleChunks(p_checkLoadVisibleChunks_1_, (double)p_checkLoadVisibleChunks_2_, p_checkLoadVisibleChunks_3_, p_checkLoadVisibleChunks_4_);
    }

    if (Keyboard.isKeyDown(61) && Keyboard.isKeyDown(38))
    {
        this.loadVisibleChunks = true;
        TextComponentString textcomponentstring = new TextComponentString(I18n.format("of.message.loadingVisibleChunks", new Object[0]));
        this.mc.ingameGUI.getChatGUI().printChatMessage(textcomponentstring);
        Reflector.Minecraft_actionKeyF3.setValue(this.mc, Boolean.TRUE);
    }
}
 
Example 2
Project: pnc-repressurized   File: BlockSecurityStation.java   View source code 6 votes vote down vote up
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9) {
    if (player.isSneaking()) return false;
    else {
        if (!world.isRemote) {
            TileEntitySecurityStation te = (TileEntitySecurityStation) world.getTileEntity(pos);
            if (te != null) {
                if (te.isPlayerOnWhiteList(player)) {
                    player.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.SECURITY_STATION_INVENTORY.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
                } else if (!te.hasValidNetwork()) {
                    player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "This Security Station is out of order: Its network hasn't been properly configured."), false);
                } else if (te.hasPlayerHacked(player)) {
                    player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "You've already hacked this Security Station!"), false);
                } else if (getPlayerHackLevel(player) < te.getSecurityLevel()) {
                    player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "You can't access or hack this Security Station. To hack it you need at least a Pneumatic Helmet upgraded with " + te.getSecurityLevel() + " Security upgrade(s)."), false);
                } else {
                    player.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.HACKING.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
                }
            }
        }
        return true;
    }
}
 
Example 3
Project: ProgressiveDifficulty   File: EventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event){
    if(DifficultyManager.enabled && ProgressiveDifficulty.oldConfigExists){
        TextComponentString linkComponent = new TextComponentString("[Progressive Difficulty Wiki]");
        ITextComponent[] chats = new ITextComponent[]{
                new TextComponentString("[ProgressiveDifficulty] It looks like you have a version 1.0 " +
                        "config file. Please check out the Progressive Difficulty Wiki for instructions on how" +
                        " to migrate to a version 2.0 config file."),
                linkComponent
        };
        ClickEvent goLinkEvent = new ClickEvent(ClickEvent.Action.OPEN_URL,"https://github.com/talandar/ProgressiveDifficulty/wiki/2.0-Transition");
        linkComponent.getStyle().setClickEvent(goLinkEvent);
        linkComponent.getStyle().setColor(TextFormatting.BLUE);
        linkComponent.getStyle().setUnderlined(true);
        ChatUtil.sendChat(event.player,chats);
    }
}
 
Example 4
Project: CustomWorldGen   File: CommandTreeBase.java   View source code 6 votes vote down vote up
/**
 * Callback for when the command is executed
 */
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if(args.length < 1)
    {
        sender.addChatMessage(new TextComponentString(CommandBase.joinNiceStringFromCollection(commandMap.keySet())));
    }
    else
    {
        ICommand cmd = getCommandMap().get(args[0]);

        if(cmd == null)
        {
            throw new CommandException("commands.tree_base.invalid_cmd", args[0]);
        }
        else if(!cmd.checkPermission(server, sender))
        {
            throw new CommandException("commands.generic.permission");
        }
        else
        {
            cmd.execute(server, sender, shiftArgs(args));
        }
    }
}
 
Example 5
Project: Geolosys   File: BlockSampleVanilla.java   View source code 6 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (Config.getInstance().boringSamples)
    {
        String resource = Types.Vanilla.byMetadata(state.getBlock().getMetaFromState(state)).getResource();
        playerIn.sendStatusMessage(new TextComponentString("You break the sample to find " + resource), true);
    }
    else
    {
        this.dropBlockAsItem(worldIn, pos, state, 0);
    }
    worldIn.setBlockToAir(pos);
    playerIn.swingArm(EnumHand.MAIN_HAND);
    return true;
}
 
Example 6
Project: ForgeHax   File: Helper.java   View source code 6 votes vote down vote up
public static void printMessageNaked(String startWith, String message, Style firstStyle, Style secondStyle) {
    if(getLocalPlayer() != null && !Strings.isNullOrEmpty(message)) {
        if(message.contains("\n")) {
            Scanner scanner = new Scanner(message);
            scanner.useDelimiter("\n");
            Style s1 = firstStyle;
            Style s2 = secondStyle;
            while (scanner.hasNext()) {
                printMessageNaked(startWith, scanner.next(), s1, s2);
                // alternate between colors each newline
                Style cpy = s1;
                s1 = s2;
                s2 = cpy;
            }
        } else {
            TextComponentString string = new TextComponentString(startWith + message.replaceAll("\r", ""));
            string.setStyle(firstStyle);
            getLocalPlayer().sendMessage(string);
        }
    }
}
 
Example 7
Project: CustomWorldGen   File: GuiChat.java   View source code 6 votes vote down vote up
/**
 * Called when tab key pressed. If it's the first time we tried to complete this string, we ask the server
 * for completions. When the server responds, this method gets called again (via setCompletions).
 */
public void complete()
{
    super.complete();

    if (this.completions.size() > 1)
    {
        StringBuilder stringbuilder = new StringBuilder();

        for (String s : this.completions)
        {
            if (stringbuilder.length() > 0)
            {
                stringbuilder.append(", ");
            }

            stringbuilder.append(s);
        }

        this.clientInstance.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new TextComponentString(stringbuilder.toString()), 1);
    }
}
 
Example 8
Project: CustomWorldGen   File: CommandBase.java   View source code 6 votes vote down vote up
public static ITextComponent join(List<ITextComponent> components)
{
    ITextComponent itextcomponent = new TextComponentString("");

    for (int i = 0; i < components.size(); ++i)
    {
        if (i > 0)
        {
            if (i == components.size() - 1)
            {
                itextcomponent.appendText(" and ");
            }
            else if (i > 0)
            {
                itextcomponent.appendText(", ");
            }
        }

        itextcomponent.appendSibling((ITextComponent)components.get(i));
    }

    return itextcomponent;
}
 
Example 9
Project: BetterBeginningsReborn   File: ItemInfusionScroll.java   View source code 6 votes vote down vote up
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos,
    EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
{
    TileEntity te = world.getTileEntity(pos);
    if(te instanceof TileEntityInfusionRepair)
    {
        Stack<RecipeElement> pendingIngredients = ((TileEntityInfusionRepair)te).getPendingIngredients();
        if(!pendingIngredients.isEmpty())
        {
            RecipeElement element = pendingIngredients.peek();
            player.sendMessage(new TextComponentString(element.toFriendlyString()));
        }
    }
    return EnumActionResult.SUCCESS;
}
 
Example 10
Project: AuthMod   File: CommandEvents.java   View source code 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
  public void CommandEvents(CommandEvent evt) {
	
	if(Main.debug==1)System.out.println(evt.getSender().getName() + " called Command " + evt.getSender().toString());

	
	if(evt.getSender() instanceof EntityPlayer){
	if(!Main.logged.contains(evt.getSender().getName())){
		//System.out.println(evt.getCommand().getCommandName().toString());
		if(!evt.getCommand().getCommandName().toString().contains("login") && !evt.getCommand().getCommandName().toString().contains("register")){
		evt.setCanceled(true);
		if(Main.passwords.containsKey(evt.getSender().getName())){
			evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("loginmessage")));
		} else {
		evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("registermessage")));
		}
		} 
	}
	}
}
 
Example 11
Project: Backmemed   File: GuiChat.java   View source code 6 votes vote down vote up
public void complete()
{
    super.complete();

    if (this.completions.size() > 1)
    {
        StringBuilder stringbuilder = new StringBuilder();

        for (String s : this.completions)
        {
            if (stringbuilder.length() > 0)
            {
                stringbuilder.append(", ");
            }

            stringbuilder.append(s);
        }

        this.clientInstance.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new TextComponentString(stringbuilder.toString()), 1);
    }
}
 
Example 12
Project: uniquecrops   File: GrowthSteps.java   View source code 6 votes vote down vote up
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {

	TileEntity tile = world.getTileEntity(pos);
	if (tile != null && tile instanceof TileFeroxia) {
		TileFeroxia te = (TileFeroxia)tile;
		EntityPlayer player = UCUtils.getPlayerFromUUID(te.getOwner().toString());
		if (!world.isRemote && player != null && world.getPlayerEntityByUUID(te.getOwner()) != null) {
			NBTTagCompound tag = player.getEntityData();
			if (!tag.hasKey("hasSacrificed"))
			{
				player.addChatMessage(new TextComponentString(TextFormatting.RED + "The savage plant whispers: \"The time is right to perform a self sacrifice.\""));
				tag.setBoolean("hasSacrificed", false);
				return false;
			}
			if (tag.hasKey("hasSacrificed") && tag.getBoolean("hasSacrificed"))
			{
				tag.removeTag("hasSacrificed");
				world.setBlockState(pos, ((Feroxia)state.getBlock()).withAge(7), 2);
				GrowthSteps.generateSteps(player);
				return false;
			}
		}
	}
	return false;
}
 
Example 13
Project: Backmemed   File: SignStrictJSON.java   View source code 5 votes vote down vote up
public ITextComponent deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    if (p_deserialize_1_.isJsonPrimitive())
    {
        return new TextComponentString(p_deserialize_1_.getAsString());
    }
    else if (p_deserialize_1_.isJsonArray())
    {
        JsonArray jsonarray = p_deserialize_1_.getAsJsonArray();
        ITextComponent itextcomponent = null;

        for (JsonElement jsonelement : jsonarray)
        {
            ITextComponent itextcomponent1 = this.deserialize(jsonelement, jsonelement.getClass(), p_deserialize_3_);

            if (itextcomponent == null)
            {
                itextcomponent = itextcomponent1;
            }
            else
            {
                itextcomponent.appendSibling(itextcomponent1);
            }
        }

        return itextcomponent;
    }
    else
    {
        throw new JsonParseException("Don\'t know how to turn " + p_deserialize_1_ + " into a Component");
    }
}
 
Example 14
Project: ModularMachinery   File: ItemDebugStruct.java   View source code 5 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(worldIn.isRemote) return EnumActionResult.SUCCESS;
    TileEntity te = worldIn.getTileEntity(pos);
    if(te != null && te instanceof TileMachineController) {
        DynamicMachine dm = ((TileMachineController) te).getBlueprintMachine();
        if(dm != null) {
            BlockArray pattern = dm.getPattern();
            if(pattern != null) {

                EnumFacing face = EnumFacing.NORTH;
                player.sendMessage(new TextComponentString("Attempting structure matching:"));
                player.sendMessage(new TextComponentString("Structure is facing: " + worldIn.getBlockState(pos).getValue(BlockController.FACING).name()));
                do {
                    if(face == worldIn.getBlockState(pos).getValue(BlockController.FACING)) {
                        BlockPos mismatch = pattern.getRelativeMismatchPosition(worldIn, pos);
                        if(mismatch != null) {
                            player.sendMessage(new TextComponentString("Failed at relative position: " + mismatch.toString()));
                        }
                    }
                    face = face.rotateYCCW();
                    pattern = pattern.rotateYCCW();
                } while (face != EnumFacing.NORTH);
            }
        }
    }
    return EnumActionResult.SUCCESS;
}
 
Example 15
Project: pnc-repressurized   File: NetworkConnectionAIHandler.java   View source code 5 votes vote down vote up
@Override
public void onSlotHack(int slot, boolean nuked) {
    ItemStack stack = station.getPrimaryInventory().getStackInSlot(slot);
    if (!simulating && !stack.isEmpty() && stack.getItemDamage() == ItemNetworkComponents.NETWORK_IO_PORT) {
        FMLClientHandler.instance().getClient().player.closeScreen();
        FMLClientHandler.instance().getClient().player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Hacking unsuccessful! The Diagnostic Subroutine traced to your location!"), false);
        if (gui instanceof GuiSecurityStationHacking)
            ((GuiSecurityStationHacking) gui).removeUpdatesOnConnectionHandlers();
    }
}
 
Example 16
Project: CustomWorldGen   File: CommandListBans.java   View source code 5 votes vote down vote up
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length >= 1 && "ips".equalsIgnoreCase(args[0]))
    {
        sender.addChatMessage(new TextComponentTranslation("commands.banlist.ips", new Object[] {Integer.valueOf(server.getPlayerList().getBannedIPs().getKeys().length)}));
        sender.addChatMessage(new TextComponentString(joinNiceString(server.getPlayerList().getBannedIPs().getKeys())));
    }
    else
    {
        sender.addChatMessage(new TextComponentTranslation("commands.banlist.players", new Object[] {Integer.valueOf(server.getPlayerList().getBannedPlayers().getKeys().length)}));
        sender.addChatMessage(new TextComponentString(joinNiceString(server.getPlayerList().getBannedPlayers().getKeys())));
    }
}
 
Example 17
Project: World-Border   File: Util.java   View source code 5 votes vote down vote up
/**
 * Sends an automatically translated and formatted message to a command sender
 * @param sender Target to send message to
 * @param msg String or language key to broadcast
 */
public static void chat(ICommandSender sender, String msg, Object... parts)
{
    String translated = translate(msg);

    // Consoles require ANSI coloring for formatting
    if (sender instanceof DedicatedServer)
        Log.info( removeFormatting(translated), parts );
    else
    {
        translated = String.format(translated, parts);
        sender.addChatMessage( new TextComponentString(translated) );
    }
}
 
Example 18
Project: Backmemed   File: CommandGameRule.java   View source code 5 votes vote down vote up
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    GameRules gamerules = this.getOverWorldGameRules(server);
    String s = args.length > 0 ? args[0] : "";
    String s1 = args.length > 1 ? buildString(args, 1) : "";

    switch (args.length)
    {
        case 0:
            sender.addChatMessage(new TextComponentString(joinNiceString(gamerules.getRules())));
            break;

        case 1:
            if (!gamerules.hasRule(s))
            {
                throw new CommandException("commands.gamerule.norule", new Object[] {s});
            }

            String s2 = gamerules.getString(s);
            sender.addChatMessage((new TextComponentString(s)).appendText(" = ").appendText(s2));
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, gamerules.getInt(s));
            break;

        default:
            if (gamerules.areSameType(s, GameRules.ValueType.BOOLEAN_VALUE) && !"true".equals(s1) && !"false".equals(s1))
            {
                throw new CommandException("commands.generic.boolean.invalid", new Object[] {s1});
            }

            gamerules.setOrCreateGameRule(s, s1);
            notifyGameRuleChange(gamerules, s, server);
            notifyCommandListener(sender, this, "commands.gamerule.success", new Object[] {s, s1});
    }
}
 
Example 19
Project: CustomWorldGen   File: CommandBlockBaseLogic.java   View source code 5 votes vote down vote up
/**
 * Send a chat message to the CommandSender
 */
public void addChatMessage(ITextComponent component)
{
    if (this.trackOutput && this.getEntityWorld() != null && !this.getEntityWorld().isRemote)
    {
        this.lastOutput = (new TextComponentString("[" + TIMESTAMP_FORMAT.format(new Date()) + "] ")).appendSibling(component);
        this.updateCommand();
    }
}
 
Example 20
Project: CustomWorldGen   File: GuiOptions.java   View source code 5 votes vote down vote up
public String getDifficultyText(EnumDifficulty p_175355_1_)
{
    ITextComponent itextcomponent = new TextComponentString("");
    itextcomponent.appendSibling(new TextComponentTranslation("options.difficulty", new Object[0]));
    itextcomponent.appendText(": ");
    itextcomponent.appendSibling(new TextComponentTranslation(p_175355_1_.getDifficultyResourceKey(), new Object[0]));
    return itextcomponent.getFormattedText();
}
 
Example 21
Project: CustomWorldGen   File: GuiConnecting.java   View source code 5 votes vote down vote up
/**
 * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
 */
protected void actionPerformed(GuiButton button) throws IOException
{
    if (button.id == 0)
    {
        this.cancel = true;

        if (this.networkManager != null)
        {
            this.networkManager.closeChannel(new TextComponentString("Aborted"));
        }

        this.mc.displayGuiScreen(this.previousGuiScreen);
    }
}
 
Example 22
Project: Backmemed   File: StatBase.java   View source code 5 votes vote down vote up
/**
 * 1.8.9
 */
public ITextComponent createChatComponent()
{
    ITextComponent itextcomponent = this.getStatName();
    ITextComponent itextcomponent1 = (new TextComponentString("[")).appendSibling(itextcomponent).appendText("]");
    itextcomponent1.setStyle(itextcomponent.getStyle());
    return itextcomponent1;
}
 
Example 23
Project: CustomWorldGen   File: NetHandlerHandshakeTCP.java   View source code 5 votes vote down vote up
/**
 * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The
 * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention
 * must pass a versioncheck or receive a disconnect otherwise
 */
public void processHandshake(C00Handshake packetIn)
{
    if (!net.minecraftforge.fml.common.FMLCommonHandler.instance().handleServerHandshake(packetIn, this.networkManager)) return;

    switch (packetIn.getRequestedState())
    {
        case LOGIN:
            this.networkManager.setConnectionState(EnumConnectionState.LOGIN);

            if (packetIn.getProtocolVersion() > 210)
            {
                TextComponentString textcomponentstring = new TextComponentString("Outdated server! I\'m still on 1.10.2");
                this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring));
                this.networkManager.closeChannel(textcomponentstring);
            }
            else if (packetIn.getProtocolVersion() < 210)
            {
                TextComponentString textcomponentstring1 = new TextComponentString("Outdated client! Please use 1.10.2");
                this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring1));
                this.networkManager.closeChannel(textcomponentstring1);
            }
            else
            {
                this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager));
            }

            break;
        case STATUS:
            this.networkManager.setConnectionState(EnumConnectionState.STATUS);
            this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager));
            break;
        default:
            throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState());
    }
}
 
Example 24
Project: InControl   File: CmdLoadLoot.java   View source code 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (!RulesManager.readCustomLoot(args[0])) {
        ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Error reading file '" + args[0] + "'!"));
        InControl.logger.warn("Error reading file '" + args[0] + "'!");
    }
}
 
Example 25
Project: InControl   File: CmdLoadSpawn.java   View source code 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (!RulesManager.readCustomSpawn(args[0])) {
        ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Error reading file '" + args[0] + "'!"));
        InControl.logger.warn("Error reading file '" + args[0] + "'!");
    }
}
 
Example 26
Project: CustomWorldGen   File: CommandBase.java   View source code 5 votes vote down vote up
public static ITextComponent getChatComponentFromNthArg(ICommandSender sender, String[] args, int index, boolean p_147176_3_) throws PlayerNotFoundException
{
    ITextComponent itextcomponent = new TextComponentString("");

    for (int i = index; i < args.length; ++i)
    {
        if (i > index)
        {
            itextcomponent.appendText(" ");
        }

        ITextComponent itextcomponent1 = net.minecraftforge.common.ForgeHooks.newChatWithLinks(args[i]); // Forge: links for messages

        if (p_147176_3_)
        {
            ITextComponent itextcomponent2 = EntitySelector.matchEntitiesToTextComponent(sender, args[i]);

            if (itextcomponent2 == null)
            {
                if (EntitySelector.hasArguments(args[i]))
                {
                    throw new PlayerNotFoundException();
                }
            }
            else
            {
                itextcomponent1 = itextcomponent2;
            }
        }

        itextcomponent.appendSibling(itextcomponent1);
    }

    return itextcomponent;
}
 
Example 27
Project: CustomWorldGen   File: CommandListPlayers.java   View source code 5 votes vote down vote up
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    int i = server.getCurrentPlayerCount();
    sender.addChatMessage(new TextComponentTranslation("commands.players.list", new Object[] {Integer.valueOf(i), Integer.valueOf(server.getMaxPlayers())}));
    sender.addChatMessage(new TextComponentString(server.getPlayerList().getFormattedListOfPlayers(args.length > 0 && "uuids".equalsIgnoreCase(args[0]))));
    sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, i);
}
 
Example 28
Project: Backmemed   File: GuiOptions.java   View source code 5 votes vote down vote up
public String getDifficultyText(EnumDifficulty p_175355_1_)
{
    ITextComponent itextcomponent = new TextComponentString("");
    itextcomponent.appendSibling(new TextComponentTranslation("options.difficulty", new Object[0]));
    itextcomponent.appendText(": ");
    itextcomponent.appendSibling(new TextComponentTranslation(p_175355_1_.getDifficultyResourceKey(), new Object[0]));
    return itextcomponent.getFormattedText();
}
 
Example 29
Project: CustomWorldGen   File: Entity.java   View source code 5 votes vote down vote up
/**
 * Get the formatted ChatComponent that will be used for the sender's username in chat
 */
public ITextComponent getDisplayName()
{
    TextComponentString textcomponentstring = new TextComponentString(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getName()));
    textcomponentstring.getStyle().setHoverEvent(this.getHoverEvent());
    textcomponentstring.getStyle().setInsertion(this.getCachedUniqueIdString());
    return textcomponentstring;
}
 
Example 30
Project: needtobreath   File: ForgeEventHandlers.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onBonemeal(BonemealEvent evt) {
    World world = evt.getWorld();
    DimensionData data = getDimensionData(world);
    if (data != null) {
        if (preventPlantGrowth(world, data, evt.getPos())) {
            evt.setResult(Event.Result.ALLOW);
            if (world.isRemote) {
                evt.getEntityPlayer().sendStatusMessage(new TextComponentString(TextFormatting.RED + "The bonemeal did not work!"), false);
            }
        }
    }
}
 
Example 31
Project: Scripty   File: ScriptyNetworkHandler.java   View source code 5 votes vote down vote up
@SideOnly(Side.SERVER)
public static void handleOpenRequest(BlockPos pos, EntityPlayerMP player) {
    TileEntity te = player.world.getTileEntity(pos);
    if (te instanceof ScriptyBlock.TEScriptyBlock) {
        ScriptyBlock.TEScriptyBlock scriptyBlock = (ScriptyBlock.TEScriptyBlock) te;
        if (scriptyBlock.getOwner() != null && scriptyBlock.getOwner().isEntityEqual(player)) {
            player.sendMessage(new TextComponentString(scriptyBlock.getOwner().getName() + " is already using this Scripty block.").setStyle(new Style().setColor(TextFormatting.RED)));
            return;
        }
        scriptyBlock.setOwner(player);
        sendContentMessage(player, pos, scriptyBlock.getContent(), scriptyBlock.getLanguage(), scriptyBlock.isParsing());
    }
}
 
Example 32
Project: Etheric   File: TileEntityTestTank.java   View source code 5 votes vote down vote up
public boolean activate(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
		EnumFacing side, float hitX, float hitY, float hitZ) {
	if (!world.isRemote) {
		player.sendMessage(new TextComponentString(
				"Quintessence: " + internalTank.getAmount() + ", Purity: " + internalTank.getPurity()));
	}
	return true;
}
 
Example 33
Project: Geolosys   File: BlockSample.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void registerEvent(BlockEvent.HarvestDropsEvent event)
{
    if (!Config.getInstance().boringSamples || event.getHarvester() == null || event.getState() == null || event.getState().getBlock() != this)
    {
        return;
    }
    String resource = Types.Modded.byMetadata(event.getState().getBlock().getMetaFromState(event.getState())).getResource();
    event.getHarvester().sendStatusMessage(new TextComponentString("You break the sample to find " + resource), true);
    event.getDrops().clear();
}
 
Example 34
Project: CustomWorldGen   File: CommandBlockBaseLogic.java   View source code 5 votes vote down vote up
/**
 * Reads NBT formatting and stored data into variables.
 */
public void readDataFromNBT(NBTTagCompound nbt)
{
    this.commandStored = nbt.getString("Command");
    this.successCount = nbt.getInteger("SuccessCount");

    if (nbt.hasKey("CustomName", 8))
    {
        this.customName = nbt.getString("CustomName");
    }

    if (nbt.hasKey("TrackOutput", 1))
    {
        this.trackOutput = nbt.getBoolean("TrackOutput");
    }

    if (nbt.hasKey("LastOutput", 8) && this.trackOutput)
    {
        try
        {
            this.lastOutput = ITextComponent.Serializer.jsonToComponent(nbt.getString("LastOutput"));
        }
        catch (Throwable throwable)
        {
            this.lastOutput = new TextComponentString(throwable.getMessage());
        }
    }
    else
    {
        this.lastOutput = null;
    }

    this.resultStats.readStatsFromNBT(nbt);
}
 
Example 35
Project: DankNull   File: BlockDankNullDock.java   View source code 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (getTE(world, pos) != null) {
		if (!player.getHeldItem(hand).isEmpty() && getTE(world, pos).getStack().isEmpty() && player.getHeldItem(hand).getItem() == ModItems.DANK_NULL) {
			getTE(world, pos).setStack(player.getHeldItem(hand));
			getTE(world, pos).setSelectedStack(DankNullUtils.getSelectedStack(DankNullUtils.getInventoryFromHeld(player)));
			player.setHeldItem(hand, ItemStack.EMPTY);
			return true;
		}
		else if (player.getHeldItem(hand).isEmpty()) {
			if (!player.isSneaking()) {
				if (getTE(world, pos).getExtractionMode() == ExtractionMode.NORMAL) {
					getTE(world, pos).setExtractionMode(ExtractionMode.SELECTED);
					if (world.isRemote) {
						player.sendMessage(new TextComponentString("Extraction mode: Only Selected Item Extracted"));
					}
				}
				else {
					getTE(world, pos).setExtractionMode(ExtractionMode.NORMAL);
					if (world.isRemote) {
						player.sendMessage(new TextComponentString("Extraction mode: All Items Extracted"));
					}
				}
			}
			else {
				if (!getTE(world, pos).getStack().isEmpty()) {
					player.setHeldItem(hand, getTE(world, pos).getStack());
					getTE(world, pos).setStack(ItemStack.EMPTY);
					getTE(world, pos).setSelectedStack(ItemStack.EMPTY);
					getTE(world, pos).resetInventory();
				}
			}
			return true;
		}
	}
	return false;
}
 
Example 36
Project: CustomWorldGen   File: StatBase.java   View source code 5 votes vote down vote up
/**
 * 1.8.9
 */
public ITextComponent createChatComponent()
{
    ITextComponent itextcomponent = this.getStatName();
    ITextComponent itextcomponent1 = (new TextComponentString("[")).appendSibling(itextcomponent).appendText("]");
    itextcomponent1.setStyle(itextcomponent.getStyle());
    return itextcomponent1;
}
 
Example 37
Project: Backmemed   File: GuiConnecting.java   View source code 5 votes vote down vote up
/**
 * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
 */
protected void actionPerformed(GuiButton button) throws IOException
{
    if (button.id == 0)
    {
        this.cancel = true;

        if (this.networkManager != null)
        {
            this.networkManager.closeChannel(new TextComponentString("Aborted"));
        }

        this.mc.displayGuiScreen(this.previousGuiScreen);
    }
}
 
Example 38
Project: ForgeHax   File: AutoLog.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onPacketRecieved(PacketEvent.Incoming.Pre event) {
    if (event.getPacket() instanceof SPacketSpawnPlayer) {
        if (disconnectOnNewPlayer.getAsBoolean()) {
            AutoReconnectMod.hasAutoLogged = true; // dont automatically reconnect
            UUID id = ((SPacketSpawnPlayer) event.getPacket()).getUniqueId();

            NetworkPlayerInfo info = MC.getConnection().getPlayerInfo(id);
            String name = info != null ? info.getGameProfile().getName() : "(Failed) " + id.toString();

            getNetworkManager().closeChannel(new TextComponentString(name + " entered render distance"));
            disable();
        }
    }
}
 
Example 39
Project: ForgeHax   File: GuiTextInput.java   View source code 5 votes vote down vote up
public void keyTyped(char typedChar, int keyCode) throws IOException {
    if (isActive) {
        switch (keyCode) {
            case Keyboard.KEY_ESCAPE:
                isActive = false;
                break;

            case Keyboard.KEY_RETURN:
                isActive = false;
                //setValue(input);
                MC.player.sendMessage(new TextComponentString(input.toString()));
                break;

            case Keyboard.KEY_BACK:
                if (selectedIndex > -1) {
                    input.deleteCharAt(selectedIndex);
                    selectedIndex--;
                }
                break;

            case Keyboard.KEY_LEFT:
                selectedIndex--;
                break;

            case Keyboard.KEY_RIGHT:
                selectedIndex++;
                break;

            default:
                if (isValidChar(typedChar)) {
                    selectedIndex++;
                    input.insert(selectedIndex, typedChar);
                }
        }
        selectedIndex = MathHelper.clamp(selectedIndex, -1, input.length()-1);
    }
}
 
Example 40
Project: OpenFlexiTrack   File: ChatPacket.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(final ChatPacket message, final MessageContext ctx){
	FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(new Runnable(){
		@Override
		public void run(){
			Minecraft.getMinecraft().thePlayer.addChatMessage(new TextComponentString(I18n.format(message.translatableMessage) + message.extraMessage));
		}
	});
	return null;
}