net.minecraft.util.ChatComponentText Java Examples
The following examples show how to use
net.minecraft.util.ChatComponentText.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NetworkHandler.java From Hyperium with GNU Lesser General Public License v3.0 | 7 votes |
@Override public void handleChat(String s) { if (s.toLowerCase().contains("reconnecting hyperium connection")) return; Hyperium.LOGGER.debug("Chat: {}", s); s = s.replace("&", C.COLOR_CODE_SYMBOL); IChatComponent chatComponent = new ChatComponentText(""); Arrays.stream(s.split(" ")).forEach(s1 -> { ChatComponentText iChatComponents = new ChatComponentText(s1 + " "); if (s1.contains(".") && !s1.startsWith(".") && !s1.endsWith(".")) { ChatStyle chatStyle = new ChatStyle(); chatStyle.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, s1.startsWith("http") ? s1 : "http://" + s1)); iChatComponents.setChatStyle(chatStyle); } chatComponent.appendSibling(iChatComponents); }); GeneralChatHandler.instance().sendMessage(chatComponent); }
Example #2
Source File: StructureBuilder.java From mobycraft with Apache License 2.0 | 6 votes |
private static void wrapSignText(String containerProperty, TileEntitySign sign) { if (containerProperty.length() < 14) { sign.signText[1] = new ChatComponentText(containerProperty); } else if (containerProperty.length() < 27) { sign.signText[1] = new ChatComponentText( containerProperty.substring(0, 13)); sign.signText[2] = new ChatComponentText( containerProperty.substring(13, containerProperty.length())); } else { sign.signText[1] = new ChatComponentText( containerProperty.substring(0, 13)); sign.signText[1] = new ChatComponentText( containerProperty.substring(13, 26)); sign.signText[2] = new ChatComponentText( containerProperty.substring(26, containerProperty.length())); } }
Example #3
Source File: BlockCoordTransporter.java From ModdingTutorials with GNU General Public License v2.0 | 6 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = playerIn.getCurrentEquippedItem(); if(stack != null) { if(stack.getItem() instanceof ItemCoordinateCache) { if(stack.getItem().hasEffect(stack)) { TileEntityCoordTransporter tect = (TileEntityCoordTransporter) worldIn.getTileEntity(pos); stack.stackSize--; playerIn.addChatMessage(new ChatComponentText("Added cordinate cache to tile entity")); } } } return true; }
Example #4
Source File: EventHandlerWorld.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public void onBreak(BlockEvent.BreakEvent event) { if (!event.world.isRemote) { if (event.block == RegisteredBlocks.blockNodeManipulator) { TileEntity te = event.world.getTileEntity(event.x, event.y, event.z); if (te != null && te instanceof TileNodeManipulator) { if (((TileNodeManipulator) te).isInMultiblock()) ((TileNodeManipulator) te).breakMultiblock(); } } if (event.block == RegisteredBlocks.blockStoneMachine && event.blockMetadata == 5) { TileAIShutdown.removeTrackedEntities(event.world, event.x, event.y, event.z); } if (event.world.provider.dimensionId == ModConfig.dimOuterId) { if(event.block == ConfigBlocks.blockEldritchNothing) { if(event.getPlayer().capabilities.isCreativeMode && MiscUtils.isANotApprovedOrMisunderstoodPersonFromMoreDoor(event.getPlayer())) return; event.setCanceled(true); event.getPlayer().addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + StatCollector.translateToLocal("gadomancy.eldritch.nobreakPortalNothing"))); } } } }
Example #5
Source File: EventHandlerEntity.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public void on(LivingEvent.LivingUpdateEvent event) { if (event.entityLiving == null || !(event.entityLiving instanceof EntityPlayer)) return; EntityPlayer player = (EntityPlayer) event.entity; if ((event.entity.worldObj.provider.dimensionId == ModConfig.dimOuterId) && ((player.ticksExisted & 7) == 0) && ((player.capabilities.isFlying) || (Hover.getHover(player.getEntityId())))) { if(player.capabilities.isCreativeMode && MiscUtils.isANotApprovedOrMisunderstoodPersonFromMoreDoor(player)) return; player.capabilities.isFlying = false; Hover.setHover(player.getEntityId(), false); if (!((EntityPlayer) event.entityLiving).worldObj.isRemote) { String msg = StatCollector.translateToLocal("tc.break.fly"); if (player.capabilities.isCreativeMode) { msg += " " + StatCollector.translateToLocal("gadomancy.eldritch.noflyCreative"); } player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + msg)); } } }
Example #6
Source File: BlockCoordTransporter.java From ModdingTutorials with GNU General Public License v2.0 | 6 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = playerIn.getCurrentEquippedItem(); if(stack != null) { if(stack.getItem() instanceof ItemCoordinateCache) { if(stack.getItem().hasEffect(stack)) { TileEntityCoordTransporter tect = (TileEntityCoordTransporter) worldIn.getTileEntity(pos); stack.stackSize--; playerIn.addChatMessage(new ChatComponentText("Added cordinate cache to tile entity")); } } } return true; }
Example #7
Source File: HyperiumEntityPlayer.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
public IChatComponent getDisplayName() { if (cachedName == null || System.currentTimeMillis() - lastChangeTime > 50L) { IChatComponent ichatcomponent = new ChatComponentText(ScorePlayerTeam .formatPlayerName(parent.getTeam(), displayName)); ichatcomponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + parent.getName() + " ")); //Unneeded for client if (Minecraft.getMinecraft().isIntegratedServerRunning()) { ichatcomponent.getChatStyle() .setChatHoverEvent(((IMixinEntity) parent).callGetHoverEvent()); } ichatcomponent.getChatStyle().setInsertion(parent.getName()); cachedName = ichatcomponent; } return cachedName; }
Example #8
Source File: CommandReload.java From TickDynamic with MIT License | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] args) { sender.addChatMessage(new ChatComponentText("Reloading configuration...")); sender.addChatMessage(new ChatComponentText("Note: Moving of (tile)entities to new groups might cause lag!")); mod.loadConfig(false); sender.addChatMessage(new ChatComponentText("Configuration reloaded!")); }
Example #9
Source File: BlockMultiblockGlass.java From BigReactors with MIT License | 5 votes |
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if(player.isSneaking()) { return false; } // If the player's hands are empty and they rightclick on a multiblock, they get a // multiblock-debugging message if the machine is not assembled. if(!world.isRemote && player.getCurrentEquippedItem() == null) { TileEntity te = world.getTileEntity(x, y, z); if(te instanceof IMultiblockPart) { MultiblockControllerBase controller = ((IMultiblockPart)te).getMultiblockController(); if(controller == null) { player.addChatMessage(new ChatComponentText(String.format("SERIOUS ERROR - server part @ %d, %d, %d has no controller!", x, y, z))); //TODO Localize } else { Exception e = controller.getLastValidationException(); if(e != null) { player.addChatMessage(new ChatComponentText(e.getMessage())); return true; } } } } return false; }
Example #10
Source File: MwUtil.java From mapwriter with MIT License | 5 votes |
public static void printBoth(String msg) { EntityClientPlayerMP thePlayer = Minecraft.getMinecraft().thePlayer; if (thePlayer != null) { thePlayer.addChatMessage(new ChatComponentText(msg)); } MwUtil.log("%s", msg); }
Example #11
Source File: CommandsAdmin.java From MyTown2 with The Unlicense | 5 votes |
@Command( name = "itemClass", permission = "mytown.adm.cmd.debug.item", parentName = "mytown.adm.cmd.debug", syntax = "/townadmin debug itemClass", console = false) public static CommandResponse debugItemCommand(ICommandSender sender, List<String> args) { if(sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)sender; List<Class> list = new ArrayList<Class>(); if(player.inventory.getCurrentItem() != null) { if(player.inventory.getCurrentItem().getItem() instanceof ItemBlock) { Block block = ((ItemBlock)player.inventory.getCurrentItem().getItem()).field_150939_a; list.add(block.getClass()); if(block instanceof ITileEntityProvider) { TileEntity te = ((ITileEntityProvider) block).createNewTileEntity(MinecraftServer.getServer().worldServerForDimension(0), 0); list.add(te == null ? TileEntity.class : te.getClass()); } } else { list.add(player.inventory.getCurrentItem().getItem().getClass()); } ChatManager.send(sender, new ChatComponentText("For item: " + player.inventory.getCurrentItem().getDisplayName())); for(Class cls : list) { while (cls != Object.class) { ChatManager.send(sender, new ChatComponentText(cls.getName())); cls = cls.getSuperclass(); } } } } return CommandResponse.DONE; }
Example #12
Source File: CCUpdateChecker.java From CodeChickenCore with MIT License | 5 votes |
public static void tick() { Minecraft mc = Minecraft.getMinecraft(); if (!mc.inGameHasFocus) return; synchronized (updates) { for (String s : updates) mc.thePlayer.addChatMessage(new ChatComponentText(s)); updates.clear(); } }
Example #13
Source File: EntityShip.java From archimedes-ships with MIT License | 5 votes |
public boolean disassemble(boolean overwrite) { if (worldObj.isRemote) return true; updateRiderPosition(); ChunkDisassembler disassembler = getDisassembler(); disassembler.overwrite = overwrite; if (!disassembler.canDisassemble()) { if (prevRiddenByEntity instanceof EntityPlayer) { ChatComponentText c = new ChatComponentText("Cannot disassemble ship here"); ((EntityPlayer) prevRiddenByEntity).addChatMessage(c); } return false; } AssembleResult result = disassembler.doDisassemble(); if (result.getShipMarker() != null) { TileEntity te = result.getShipMarker().tileEntity; if (te instanceof TileEntityHelm) { ((TileEntityHelm) te).setAssembleResult(result); ((TileEntityHelm) te).setShipInfo(info); } } return true; }
Example #14
Source File: CommandItemName.java From OmniOcular with Apache License 2.0 | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] array) { EntityPlayer player = (EntityPlayer) sender; ItemStack holdItem = player.getHeldItem(); if (holdItem == null) { player.addChatComponentMessage(new ChatComponentTranslation("omniocular.info.NotHolding")); return; } player.addChatComponentMessage(new ChatComponentText(Item.itemRegistry.getNameForObject(holdItem.getItem()))); }
Example #15
Source File: TileMotor.java From Framez with GNU General Public License v3.0 | 5 votes |
@Override public boolean debug(World world, int x, int y, int z, ForgeDirection face, EntityPlayer player) { if (!world.isRemote) return true; player.addChatMessage(new ChatComponentText("Power: " + getEnergyBuffer() + "/" + getEnergyBufferSize())); player.addChatMessage(new ChatComponentText("Face: " + getFace().name().toLowerCase())); getMovement().debug(world, x, y, z, face, player); return true; }
Example #16
Source File: ForgePlayer.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void sendMessage(String msg) { for (String part : msg.split("\n")) { part = BBC.color(part); ChatComponentText component = new ChatComponentText(part); component.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE); this.parent.addChatMessage(component); } }
Example #17
Source File: ClientEventHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@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; } }
Example #18
Source File: CommandRMax.java From burlapcraft with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] args) { World world = sender.getEntityWorld(); if (!world.isRemote) { if (args.length > 0) { sender.addChatMessage(new ChatComponentText("This command takes no arguments")); return; } Dungeon dungeon = BurlapCraft.currentDungeon; if (dungeon == null) { sender.addChatMessage(new ChatComponentText("You are not inside a dungeon")); return; } Thread btread = new Thread(new Runnable() { @Override public void run() { MinecraftSolver.learn(); } }); btread.start(); } }
Example #19
Source File: ItemFruitTainted.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { if(!world.isRemote && player instanceof EntityPlayerMP) { Thaumcraft.addStickyWarpToPlayer(player, 1); player.addPotionEffect(getEffect(PotionFluxTaint.instance.id, 600, false)); player.addPotionEffect(getEffect(Potion.hunger.id, 600, false)); if(world.rand.nextFloat() < 0.4F){ player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("warp.text.15"))); player.addPotionEffect(getEffect(PotionThaumarhia.instance.id, 600, true)); } } return super.onEaten(stack, world, player); }
Example #20
Source File: CommandHandler.java From TickDynamic with MIT License | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] args) { if(args.length == 0) { sender.addChatMessage(new ChatComponentText("Usage: " + getCommandUsage(sender))); return; } if(args[0].equals("tps")) { sender.addChatMessage(new ChatComponentText("Average TPS: " + getTPSFormatted(mod) + " TPS")); return; } else if(args[0].equals("identify")) { sender.addChatMessage(new ChatComponentText("Command not yet implemented! This will allow you to check what group a Tile or Entity belongs to by right clicking it.(And other info, like TPS)")); return; } else if(args[0].equals("help")) { sender.addChatMessage(new ChatComponentText("You can find the documentation over at http://mods.stjerncraft.com/tickdynamic")); return; } //Send it over to subCommand handler ICommand subHandler = subCommandHandlers.get(args[0]); if(subHandler == null) { sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "No handler for the command " + EnumChatFormatting.ITALIC + args[0])); return; } subHandler.processCommand(sender, args); }
Example #21
Source File: TownBlock.java From MyTown2 with The Unlicense | 5 votes |
@Override public IChatComponent toChatMessage() { IChatComponent root = new ChatComponentText(""); for (TownBlock block : values()) { root.appendSibling(block.toChatMessage()); root.appendSibling(new ChatComponentText(" ")); } return root; }
Example #22
Source File: Rank.java From MyTown2 with The Unlicense | 5 votes |
@Override public IChatComponent toChatMessage() { IChatComponent root = new ChatComponentText(""); for (Rank rank : this) { if (root.getSiblings().size() > 0) { root.appendSibling(new ChatComponentFormatted("{7|, }")); } root.appendSibling(rank.toChatMessage()); } return root; }
Example #23
Source File: TCMazeHandler.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public static void handleBossFinish(TCMazeSession session) { CellLoc spawnChunk = session.portalCell; WorldServer world = MinecraftServer.getServer().worldServerForDimension(ModConfig.dimOuterId); int lX = (spawnChunk.x << 4) + 8; int lZ = (spawnChunk.z << 4) + 8; world.setBlock(lX, 52, lZ, ConfigBlocks.blockEldritch, 3, 3); world.setBlock(lX, 53, lZ, RegisteredBlocks.blockAdditionalEldrichPortal); GenCommon.genObelisk(world, lX, 54, lZ); session.player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + StatCollector.translateToLocal("gadomancy.eldritch.portalSpawned"))); }
Example #24
Source File: Utils.java From SkyblockAddons with MIT License | 5 votes |
public void sendMessage(String text, boolean prefix) { ClientChatReceivedEvent event = new ClientChatReceivedEvent((byte) 1, new ChatComponentText((prefix ? MESSAGE_PREFIX : "") + text)); MinecraftForge.EVENT_BUS.post(event); // Let other mods pick up the new message if (!event.isCanceled()) { Minecraft.getMinecraft().thePlayer.addChatMessage(event.message); // Just for logs } }
Example #25
Source File: PackBase.java From SimplyJetpacks with MIT License | 5 votes |
protected void toggleState(boolean on, ItemStack stack, String type, String tag, EntityPlayer player, boolean showInChat) { stack.stackTagCompound.setBoolean(tag, !on); if (player != null && showInChat) { String color = on ? StringHelper.LIGHT_RED : StringHelper.BRIGHT_GREEN; type = type != null && !type.equals("") ? "chat." + this.name + "." + type + ".on" : "chat." + this.name + ".on"; String msg = SJStringHelper.localize(type) + " " + color + SJStringHelper.localize("chat." + (on ? "disabled" : "enabled")); player.addChatMessage(new ChatComponentText(msg)); } }
Example #26
Source File: ForgePlayer.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void sendMessage(String msg) { for (String part : msg.split("\n")) { part = BBC.color(part); ChatComponentText component = new ChatComponentText(part); component.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE); this.parent.addChatMessage(component); } }
Example #27
Source File: Formatter.java From MyTown2 with The Unlicense | 5 votes |
public static void sendMap(Resident res, int dim, int cx, int cz) { int heightRad = 4, widthRad = 9; ChatManager.send(res.getPlayer(), new ChatComponentText("---------- Town Map ----------")); for (int z = cz - heightRad; z <= cz + heightRad; z++) { JsonMessageBuilder msgBuilder = new JsonMessageBuilder(); for (int x = cx - widthRad; x <= cx + widthRad; x++) { TownBlock b = MyTownUniverse.instance.blocks.get(dim, x, z); JsonMessageBuilder extraBuilder = msgBuilder.addExtra(); boolean mid = z == cz && x == cx; boolean isTown = b != null && b.getTown() != null; boolean ownTown = isTown && res.townsContainer.contains(b.getTown()); if (mid) { extraBuilder.setColor(ownTown ? EnumChatFormatting.GREEN : isTown ? EnumChatFormatting.RED : EnumChatFormatting.WHITE); } else { extraBuilder.setColor(ownTown ? EnumChatFormatting.DARK_GREEN : isTown ? EnumChatFormatting.DARK_RED : EnumChatFormatting.GRAY); } extraBuilder.setText(isTown ? "O" : "_"); if (b != null) { extraBuilder.setHoverEventShowText(formatBlockInfo(b)); extraBuilder.setClickEventRunCommand("/t info " + b.getTown().getName()); } } res.getPlayer().addChatMessage(msgBuilder.build()); } }
Example #28
Source File: LoginHandler.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unused") @SubscribeEvent public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) { event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "==================================================")); event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Welcome to Gregtech:New Horizons " + EnumChatFormatting.GREEN + CoreModConfig.ModPackVersion) ); event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Experimental recipe acceleration! Vanilla, Forestry Worktable, AE2." )); event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "May cause issues with oredicted wildcard recipes." )); event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + "Please bring comments to https://discord.gg/EXshrPV" )); event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "==================================================")); }
Example #29
Source File: Jetpack.java From SimplyJetpacks with MIT License | 5 votes |
public void doEHover(ItemStack armor, EntityLivingBase user) { NBTHelper.getNBT(armor).setBoolean(TAG_ON, true); NBTHelper.getNBT(armor).setBoolean(TAG_HOVERMODE_ON, true); if (user instanceof EntityPlayer) { ((EntityPlayer) user).addChatMessage(new ChatComponentText(StringHelper.LIGHT_RED + SJStringHelper.localize("chat.jetpack.emergencyHoverMode.msg"))); } }
Example #30
Source File: CommandDisassembleShip.java From archimedes-ships with MIT License | 5 votes |
@Override public void processCommand(ICommandSender icommandsender, String[] astring) { if (icommandsender instanceof Entity) { Entity player = (Entity) icommandsender; if (player.ridingEntity instanceof EntityShip) { EntityShip ship = (EntityShip) player.ridingEntity; int mode = 0; if (astring != null && astring.length > 2) { if (astring[0].equals("overwrite") || astring[0].equals("override")) { icommandsender.addChatMessage(new ChatComponentText("Overwriting existing blocks with ship blocks")); mode = 1; } else if (astring[1].equals("drop")) { icommandsender.addChatMessage(new ChatComponentText("Dropping to items if rejoining ship with the world fails")); mode = 2; } } else { icommandsender.addChatMessage(new ChatComponentText("Trying to add ship blocks to world")); } if (!ship.disassemble(mode == 1)) { if (mode == 2) { ship.dropAsItems(); } } player.mountEntity(null); return; } } icommandsender.addChatMessage(new ChatComponentText("Not steering a ship")); }