private void sendColorized(String msg, TextFormatting formatting) { for (String part : msg.split("\n")) { TextComponentString component = new TextComponentString(part); component.getStyle().setColor(formatting); this.player.sendMessage(component); } }
@Override public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender var1, @Nonnull String[] var2) { if(!ENABLED) var1.sendMessage(new TextComponentTranslation("botania.versioning.disabled").setStyle(new Style().setColor(TextFormatting.RED))); else if(var2.length == 1) if(VersionChecker.downloadedFile) var1.sendMessage(new TextComponentTranslation("botania.versioning.downloadedAlready").setStyle(new Style().setColor(TextFormatting.RED))); else if(VersionChecker.startedDownload) var1.sendMessage(new TextComponentTranslation("botania.versioning.downloadingAlready").setStyle(new Style().setColor(TextFormatting.RED))); else new ThreadDownloadMod("Botania " + var2[0] + ".jar"); }
@Override public void updateScreen() { super.updateScreen(); LexiconPage page = entry.pages.get(this.page); page.updateScreen(this); if(this.page == entry.pages.size() - 1) { LexiconEntry entry = tutorial.peek(); if(entry == this.entry) { tutorial.poll(); positionTutorialArrow(); if(tutorial.isEmpty()) { mc.player.sendMessage(new TextComponentTranslation("botaniamisc.tutorialEnded").setStyle(new Style().setColor(TextFormatting.RED))); hasTutorialArrow = false; } } } }
public void tellChanges(EntityPlayer player) { if(changes.size() == 0) return; player.sendMessage(new TextComponentTranslation("botaniamisc.adaptativeConfigChanges").setStyle(new Style().setColor(TextFormatting.GOLD))); for(String change : changes) player.sendMessage(new TextComponentString(change).setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE))); }
@Override public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) { if(sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) sender; ItemStack stack = PlayerHelper.getFirstHeldItemClass(player, ItemLexicon.class); if(!stack.isEmpty()) { ItemLexicon.setForcedPage(stack, args[0]); ItemLexicon.setQueueTicks(stack, 5); } else sender.sendMessage(new TextComponentTranslation("botaniamisc.noLexicon").setStyle(new Style().setColor(TextFormatting.RED))); } }
Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("botania.versioning.doneDownloading", fileName).setStyle(new Style().setColor(TextFormatting.GREEN)));
@Override @SideOnly(Side.CLIENT) public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { if(button == buttonText) { GuiLexicon.startTutorial(); Minecraft.getMinecraft().displayGuiScreen(new GuiLexicon()); Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("botaniamisc.tutorialStarted").setStyle(new Style().setColor(TextFormatting.GREEN))); } else if(button == buttonVideo && Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=D75Aad-5QgQ")); } catch(Exception e) { e.printStackTrace(); } } }
@SubscribeEvent public static void onTick(ClientTickEvent event) { if(event.phase == Phase.END && Minecraft.getMinecraft().player != null && !triedToWarnPlayer && doneChecking) { if(!onlineVersion.isEmpty()) { EntityPlayer player = Minecraft.getMinecraft().player; int onlineBuild = Integer.parseInt(onlineVersion.split("-")[1]); int clientBuild = LibMisc.BUILD.contains("GRADLE") ? Integer.MAX_VALUE : Integer.parseInt(LibMisc.BUILD); if(onlineBuild > clientBuild) { player.sendMessage(new TextComponentTranslation("botania.versioning.flavour" + player.world.rand.nextInt(FLAVOUR_MESSAGES)).setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE))); player.sendMessage(new TextComponentTranslation("botania.versioning.outdated", clientBuild, onlineBuild)); ITextComponent component = ITextComponent.Serializer.fromJsonLenient(I18n.translateToLocal("botania.versioning.updateMessage").replaceAll("%version%", onlineVersion)); player.sendMessage(component); } } triedToWarnPlayer = true; } }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(isRightPlayer(player, stack)) { if(world.isRemote) return ActionResult.newResult(EnumActionResult.SUCCESS, stack); world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); List<Integer> possible = new ArrayList<>(); for(int i = 0; i < 6; i++) { if(!hasRelicAlready(player, i)) possible.add(i); } if(possible.isEmpty()) { player.sendMessage(new TextComponentTranslation("botaniamisc.dudDiceRoll", world.rand.nextInt(6) + 1).setStyle(new Style().setColor(TextFormatting.DARK_GREEN))); stack.shrink(1); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } else { int relic = possible.get(world.rand.nextInt(possible.size())); player.sendMessage(new TextComponentTranslation("botaniamisc.diceRoll", relic + 1).setStyle(new Style().setColor(TextFormatting.DARK_GREEN))); return ActionResult.newResult(EnumActionResult.SUCCESS, relicStacks[relic].copy()); } } return ActionResult.newResult(EnumActionResult.PASS, stack); }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); String force = getForcedPage(stack); if(force != null && !force.isEmpty()) { LexiconEntry entry = getEntryFromForce(stack); if(entry != null) Botania.proxy.setEntryToOpen(entry); else player.sendMessage(new TextComponentTranslation("botaniamisc.cantOpen").setStyle(new Style().setColor(TextFormatting.RED))); setForcedPage(stack, ""); } openBook(player, stack, world, skipSound); skipSound = false; return ActionResult.newResult(EnumActionResult.SUCCESS, stack); }
private void sendError() { if(Minecraft.getMinecraft().player != null) Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("botania.versioning.error").setStyle(new Style().setColor(TextFormatting.RED))); } }
index.doCorporeaRequest(name, count, spark); event.getPlayer().sendMessage(new TextComponentTranslation("botaniamisc.requestMsg", count, WordUtils.capitalizeFully(name), CorporeaHelper.lastRequestMatches, CorporeaHelper.lastRequestExtractions).setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE))); CorporeaRequestTrigger.INSTANCE.trigger(event.getPlayer(), event.getPlayer().getServerWorld(), index.getPos(), CorporeaHelper.lastRequestExtractions);
if(world.getDifficulty() == EnumDifficulty.PEACEFUL) { if(!world.isRemote) player.sendMessage(new TextComponentTranslation("botaniamisc.peacefulNoob").setStyle(new Style().setColor(TextFormatting.RED))); return false; if(blockat != ModBlocks.pylon || state.getValue(BotaniaStateProps.PYLON_VARIANT) != PylonVariant.GAIA) { if(!world.isRemote) player.sendMessage(new TextComponentTranslation("botaniamisc.needsCatalysts").setStyle(new Style().setColor(TextFormatting.RED))); return false; new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ARENA_INDICATOR, pos.getX(), pos.getY(), pos.getZ())); player.sendMessage(new TextComponentTranslation("botaniamisc.badArena").setStyle(new Style().setColor(TextFormatting.RED)));
private static void renderPlayerLook(EntityPlayer player, RayTraceResult src) { if(currentMultiblock != null && dimension == player.world.provider.getDimension()) { BlockPos anchorPos = anchor != null ? anchor : src.getBlockPos(); GlStateManager.pushMatrix(); GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.disableLighting(); rendering = true; Multiblock mb = anchor != null ? currentMultiblock.getForFacing(angle) : currentMultiblock.getForEntity(player); boolean didAny = false; blockAccess.update(player.world, mb, anchorPos); ShaderHelper.useShader(ShaderHelper.alpha, shader -> { int alpha = ARBShaderObjects.glGetUniformLocationARB(shader, "alpha"); ARBShaderObjects.glUniform1fARB(alpha, 0.4F); }); for(MultiblockComponent comp : mb.getComponents()) { if(renderComponentInWorld(player.world, mb, comp, anchorPos)) didAny = true; } ShaderHelper.releaseShader(); rendering = false; GL11.glPopAttrib(); GlStateManager.popMatrix(); if(!didAny) { setMultiblock(null); player.sendMessage(new TextComponentTranslation("botaniamisc.structureComplete").setStyle(new Style().setColor(TextFormatting.GREEN))); } } }
private static void sendChatMessage(EntityPlayerSP sender, String chatMessage) { if (chatMessage.length() <= 256) { sender.sendChatMessage(chatMessage); } else { ITextComponent errorMessage = new TextComponentTranslation("jei.chat.error.command.too.long"); errorMessage.getStyle().setColor(TextFormatting.RED); sender.sendStatusMessage(errorMessage, false); ITextComponent chatMessageComponent = new TextComponentString(chatMessage); chatMessageComponent.getStyle().setColor(TextFormatting.RED); sender.sendStatusMessage(chatMessageComponent, false); } }
public static void writeChatMessage(EntityPlayer player, String translationKey, TextFormatting color) { TextComponentTranslation component = new TextComponentTranslation(translationKey); component.getStyle().setColor(color); player.sendMessage(component); }
@Override public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException { if(!ENABLED) sender.sendMessage(new TextComponentTranslation("psi.versioning.disabled").setStyle(new Style().setColor(TextFormatting.RED))); else if(args.length == 1) if(VersionChecker.downloadedFile) sender.sendMessage(new TextComponentTranslation("psi.versioning.downloadedAlready").setStyle(new Style().setColor(TextFormatting.RED))); else if(VersionChecker.startedDownload) sender.sendMessage(new TextComponentTranslation("psi.versioning.downloadingAlready").setStyle(new Style().setColor(TextFormatting.RED))); else new ThreadDownloadMod("Psi-" + args[0] + ".jar"); }
@SubscribeEvent public static void onHighAlchemistJoin(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent evt) { if (PECore.uuids.contains((evt.player.getUniqueID().toString()))) { ITextComponent prior = new TextComponentTranslation("pe.server.high_alchemist").setStyle(new Style().setColor(TextFormatting.BLUE)); ITextComponent playername = new TextComponentString(" " + evt.player.getName() + " ").setStyle(new Style().setColor(TextFormatting.GOLD)); ITextComponent latter = new TextComponentTranslation("pe.server.has_joined").setStyle(new Style().setColor(TextFormatting.BLUE)); FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().sendMessage(prior.appendSibling(playername).appendSibling(latter)); } }
private void sendError() { if(Minecraft.getMinecraft().player != null) Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("psi.versioning.error").setStyle(new Style().setColor(TextFormatting.RED))); } }
@NotNull @Override public ITextComponent getShortDisplayString() { final ITextComponent combined = new NonSiblingFormattingTextComponent(); combined.appendSibling(new TextComponentString(getRequest().getCount() + " ")); combined.appendSibling(getRequest().getStack().getTextComponent()); combined.getStyle().setColor(TextFormatting.BLACK); return combined; } }