net.minecraft.util.text.StringTextComponent Java Examples

The following examples show how to use net.minecraft.util.text.StringTextComponent. 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: BleachMainMenu.java    From bleachhack-1.14 with GNU General Public License v3.0 7 votes vote down vote up
public void init() {
	this.addButton(new Button(width / 2 - 100, height / 4 + 48, 200, 20, I18n.format("menu.singleplayer"), button -> {
		this.minecraft.displayGuiScreen(new WorldSelectionScreen(this));
    }));
	this.addButton(new Button(width / 2 - 100, height / 4 + 72, 200, 20, I18n.format("menu.multiplayer"), button -> {
        this.minecraft.displayGuiScreen(new MultiplayerScreen(this));
    }));
	this.addButton(new Button(this.width / 2 - 100, height / 4 + 96, 98, 20, I18n.format("fml.menu.mods"), button -> {
           this.minecraft.displayGuiScreen(new net.minecraftforge.fml.client.gui.GuiModList(this));
       }));
	this.addButton(new Button(width / 2 + 2, height / 4 + 96, 98, 20, "Login Manager", button -> {
        this.minecraft.displayGuiScreen(new LoginScreen(new StringTextComponent("LoginManager")));
    }));
	this.addButton(new Button(width / 2 - 100, height / 4 + 129, 98, 20, I18n.format("menu.options"), button -> {
        this.minecraft.displayGuiScreen(new OptionsScreen(this, this.minecraft.gameSettings));
    }));
    this.addButton(new Button(width / 2 + 2, height / 4 + 129, 98, 20, I18n.format("menu.quit"), button -> {
    	this.minecraft.shutdown();
    }));
    
    versions.clear();
    versions.addAll(github.readFileLines("latestversion.txt"));
    time = System.currentTimeMillis();
}
 
Example #2
Source File: TestRunner.java    From NoCubes with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public static void runTests(FMLServerStartedEvent event) {
	final TestRepository testRepository = new TestRepository();
	final MinecraftServer server = event.getServer();
	final long fails = testRepository.tests.parallelStream()
		.filter(test -> runTestWithCatch(test, server))
		.count();
	if (fails > 0)
		log(server, new StringTextComponent(fails + " TESTS FAILED").applyTextStyle(TextFormatting.RED));
	else
		log(server, new StringTextComponent("ALL TESTS PASSED").applyTextStyle(TextFormatting.GREEN));
	if (!TestUtil.IS_CI_ENVIRONMENT.get())
		return;
	if (fails > 0)
		throw new RuntimeException("Had failed tests");
	else
		event.getServer().initiateShutdown(false);
}
 
Example #3
Source File: CmdRename.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCommand(String command, String[] args) throws Exception {
	if (!mc.player.abilities.isCreativeMode) {
		BleachLogger.errorMessage("Not In Creative Mode!");
		return;
	}
	
	ItemStack i = mc.player.inventory.getCurrentItem();
	
	String name = "";
	for (int j = 0; j < args.length; j++) name += args[j] += " ";
	
	i.setDisplayName(new StringTextComponent(name.replace("&", "�").replace("��", "&")));
	BleachLogger.infoMessage("Renamed Item");
}
 
Example #4
Source File: TestRunner.java    From NoCubes with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return if the test FAILED
 */
private static boolean runTestWithCatch(final Test test, final MinecraftServer server) {
	try {
		test.action.run();
	} catch (Exception e) {
		log(server, new StringTextComponent("TEST FAILED: " + test.name).applyTextStyle(TextFormatting.RED));
		e.printStackTrace();
		return true;
	}
	return false;
}
 
Example #5
Source File: ServerCommandConfig.java    From Better-Sprinting with Mozilla Public License 2.0 5 votes vote down vote up
private static void sendMessageTranslated(CommandSource source, String translationName, boolean log){
	Entity entity = source.getEntity();
	
	if (entity instanceof PlayerEntity && ServerNetwork.hasBetterSprinting((PlayerEntity)entity)){
		source.sendFeedback(new TranslationTextComponent(translationName), log);
	}
	else{
		source.sendFeedback(new StringTextComponent(LanguageMap.getInstance().translateKey(translationName)), log);
	}
}
 
Example #6
Source File: MiningGadget.java    From MiningGadgets with MIT License 5 votes vote down vote up
@Override
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
    super.addInformation(stack, world, tooltip, flag);

    List<Upgrade> upgrades = UpgradeTools.getUpgrades(stack);
    Minecraft mc = Minecraft.getInstance();

    if (!InputMappings.isKeyDown(mc.getMainWindow().getHandle(), mc.gameSettings.keyBindSneak.getKey().getKeyCode())) {
        tooltip.add(new TranslationTextComponent("mininggadgets.tooltip.item.show_upgrades",
                mc.gameSettings.keyBindSneak.getLocalizedName().toLowerCase())
                .applyTextStyle(TextFormatting.GRAY));
    } else {
        tooltip.add(new TranslationTextComponent("mininggadgets.tooltip.item.break_cost", getEnergyCost(stack)).applyTextStyle(TextFormatting.RED));
        if (!(upgrades.isEmpty())) {
            tooltip.add(new TranslationTextComponent("mininggadgets.tooltip.item.upgrades").applyTextStyle(TextFormatting.AQUA));
            for (Upgrade upgrade : upgrades) {
                tooltip.add(new StringTextComponent(" - " +
                        I18n.format(upgrade.getLocal())
                ).applyTextStyle(TextFormatting.GRAY));
            }
        }
    }

    stack.getCapability(CapabilityEnergy.ENERGY, null)
            .ifPresent(energy -> tooltip.add(
                    new TranslationTextComponent("mininggadgets.gadget.energy",
                            MagicHelpers.tidyValue(energy.getEnergyStored()),
                            MagicHelpers.tidyValue(energy.getMaxEnergyStored())).applyTextStyles(TextFormatting.GREEN)));
}
 
Example #7
Source File: PacketOpenFilterContainer.java    From MiningGadgets with MIT License 5 votes vote down vote up
public static void handle(PacketOpenFilterContainer msg, Supplier<NetworkEvent.Context> ctx) {
    ctx.get().enqueueWork(() -> {
        ServerPlayerEntity sender = ctx.get().getSender();
        if (sender == null)
            return;

        Container container = sender.openContainer;
        if (container == null)
            return;

        ItemStack stack = MiningGadget.getGadget(sender);
        if( stack.isEmpty() )
            return;

        ItemStackHandler ghostInventory = new ItemStackHandler(30) {
            @Override
            protected void onContentsChanged(int slot) {
                stack.getOrCreateTag().put(MiningProperties.KEY_FILTERS, serializeNBT());
            }
        };

        ghostInventory.deserializeNBT(stack.getOrCreateChildTag(MiningProperties.KEY_FILTERS));
        sender.openContainer(new SimpleNamedContainerProvider(
                (windowId, playerInventory, playerEntity) -> new FilterContainer(windowId, playerInventory, ghostInventory), new StringTextComponent("")
        ));
    });

    ctx.get().setPacketHandled(true);
}
 
Example #8
Source File: CCBlockRendererDispatcher.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SuppressWarnings ("Convert2MethodRef")//Suppress these, the lambdas need to be synthetic functions instead of a method reference.
private static void handleCaughtException(Throwable t, BlockState inState, BlockPos pos, ILightReader world) {
    Block inBlock = inState.getBlock();
    TileEntity tile = world.getTileEntity(pos);

    StringBuilder builder = new StringBuilder("\n CCL has caught an exception whilst rendering a block\n");
    builder.append("  BlockPos:      ").append(String.format("x:%s, y:%s, z:%s", pos.getX(), pos.getY(), pos.getZ())).append("\n");
    builder.append("  Block Class:   ").append(tryOrNull(() -> inBlock.getClass())).append("\n");
    builder.append("  Registry Name: ").append(tryOrNull(() -> inBlock.getRegistryName())).append("\n");
    builder.append("  State:         ").append(inState).append("\n");
    builder.append(" Tile at position\n");
    builder.append("  Tile Class:    ").append(tryOrNull(() -> tile.getClass())).append("\n");
    builder.append("  Tile Id:       ").append(tryOrNull(() -> TileEntityType.getId(tile.getType()))).append("\n");
    builder.append("  Tile NBT:      ").append(tryOrNull(() -> tile.write(new CompoundNBT()))).append("\n");
    if (ProxyClient.messagePlayerOnRenderExceptionCaught) {
        builder.append("You can turn off player messages in the CCL config file.\n");
    }
    String logMessage = builder.toString();
    String key = ExceptionUtils.getStackTrace(t) + logMessage;
    if (!ExceptionMessageEventHandler.exceptionMessageCache.contains(key)) {
        ExceptionMessageEventHandler.exceptionMessageCache.add(key);
        logger.error(logMessage, t);
    }
    PlayerEntity player = Minecraft.getInstance().player;
    if (ProxyClient.messagePlayerOnRenderExceptionCaught && player != null) {
        long time = System.nanoTime();
        if (TimeUnit.NANOSECONDS.toSeconds(time - lastTime) > 5) {
            lastTime = time;
            player.sendMessage(new StringTextComponent("CCL Caught an exception rendering a block. See the log for info."));
        }
    }
}
 
Example #9
Source File: MiningSettingScreen.java    From MiningGadgets with MIT License 5 votes vote down vote up
public MiningSettingScreen(ItemStack gadget) {
    super(new StringTextComponent("title"));

    this.gadget = gadget;
    this.beamRange = MiningProperties.getBeamRange(gadget);
    this.volume = MiningProperties.getVolume(gadget);
    this.freezeDelay = MiningProperties.getFreezeDelay(gadget);
}
 
Example #10
Source File: MiningVisualsScreen.java    From MiningGadgets with MIT License 5 votes vote down vote up
public MiningVisualsScreen(ItemStack gadget) {
    super(new StringTextComponent("title"));
    this.gadget = gadget;
    this.red = MiningProperties.getColor(gadget, MiningProperties.COLOR_RED);
    this.green = MiningProperties.getColor(gadget, MiningProperties.COLOR_GREEN);
    this.blue = MiningProperties.getColor(gadget, MiningProperties.COLOR_BLUE);
    this.red_inner = MiningProperties.getColor(gadget, MiningProperties.COLOR_RED_INNER);
    this.green_inner = MiningProperties.getColor(gadget, MiningProperties.COLOR_GREEN_INNER);
    this.blue_inner = MiningProperties.getColor(gadget, MiningProperties.COLOR_BLUE_INNER);
}
 
Example #11
Source File: ClientEvents.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void handleScrapingMessage(ScrapingMessage message)
{
    Minecraft.getInstance().execute(() -> {
        Minecraft.getInstance().player.sendMessage(
                new TranslationTextComponent("text." + SurvivalistMod.MODID + ".scraping.message1",
                        makeClickable(message.stack.getTextComponent()),
                        new StringTextComponent("" + message.ret.getCount()),
                        makeClickable(message.ret.getTextComponent())), Util.field_240973_b_);
    });
}
 
Example #12
Source File: SupportButton.java    From XRay-Mod with GNU General Public License v3.0 5 votes vote down vote up
public SupportButton(int widthIn, int heightIn, int width, int height, ITextComponent text, TranslationTextComponent support, IPressable onPress) {
    super(widthIn, heightIn, width, height, text, onPress);

    for(String line : support.getString().split("\n")) {
        this.support.add(new StringTextComponent(line));
    }
}
 
Example #13
Source File: ClientEventHandler.java    From Better-Sprinting with Mozilla Public License 2.0 5 votes vote down vote up
@SubscribeEvent
public static void onClientTick(ClientTickEvent e){
	if (e.phase != Phase.END || mc.player == null){
		return;
	}
	
	if (showDisableWarningWhenPossible){
		mc.player.sendMessage(new StringTextComponent(ClientModManager.chatPrefix + I18n.format(ClientModManager.svDisableMod ? "bs.game.disabled" : "bs.game.reenabled")));
		showDisableWarningWhenPossible = false;
	}
	
	if (ClientModManager.keyBindOptionsMenu.isKeyDown()){
		mc.displayGuiScreen(new GuiSprint(null));
	}
}
 
Example #14
Source File: GuiBlockList.java    From XRay-Mod with GNU General Public License v3.0 5 votes vote down vote up
@Override // @mcp: func_231160_c_ = init
public void func_231160_c_() {
    this.blockList = new ScrollingBlockList((getWidth() / 2) + 1, getHeight() / 2 - 12, 202, 185, this.blocks);
    this.field_230705_e_.add(this.blockList); // @mcp: field_230705_e_ = children

    search = new TextFieldWidget(getFontRender(), getWidth() / 2 - 100, getHeight() / 2 + 85, 140, 18, new StringTextComponent(""));
    search.func_231049_c__(true); // @mcp: func_231049_c__ = changeFocus
    this.func_231035_a_(search);// @mcp: func_231035_a_ = setFocused

    addButton(new Button(getWidth() / 2 + 43, getHeight() / 2 + 84, 60, 20, new TranslationTextComponent("xray.single.cancel"), b -> this.onClose()));
}
 
Example #15
Source File: IntegrityCheck.java    From Better-Sprinting with Mozilla Public License 2.0 5 votes vote down vote up
@SubscribeEvent
public void onPlayerTick(ClientTickEvent e){
	if (e.phase == Phase.END && mc.player != null && mc.player.ticksExisted > 1){
		if (!LivingUpdate.checkIntegrity()){
			mc.player.sendMessage(new StringTextComponent(ClientModManager.chatPrefix + I18n.format("bs.game.integrity")));
		}
		
		unregister();
	}
}
 
Example #16
Source File: GuiSelectionScreen.java    From XRay-Mod with GNU General Public License v3.0 4 votes vote down vote up
public SupportButtonInner(int widthIn, int heightIn, int width, int height, String text, String i18nKey, IPressable onPress) {
    super(widthIn, heightIn, width, height, new StringTextComponent(text), new TranslationTextComponent(i18nKey), onPress);
}
 
Example #17
Source File: ServerCommandConfig.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
private static void sendMessage(CommandSource source, String text){
	source.sendFeedback(new StringTextComponent(text), false);
}
 
Example #18
Source File: ListScreen.java    From BoundingBoxOutlineReloaded with MIT License 4 votes vote down vote up
ListScreen(Screen lastScreen) {
    super(new StringTextComponent("Bounding Box Outline Reloaded"));
    this.lastScreen = lastScreen;
}
 
Example #19
Source File: GuiBase.java    From XRay-Mod with GNU General Public License v3.0 4 votes vote down vote up
public GuiBase(boolean hasSide ) {
    super(new StringTextComponent(""));
    this.hasSide = hasSide;
}
 
Example #20
Source File: SupportButton.java    From XRay-Mod with GNU General Public License v3.0 4 votes vote down vote up
public List<StringTextComponent> getSupport() {
    return support;
}
 
Example #21
Source File: GuiAddBlock.java    From XRay-Mod with GNU General Public License v3.0 4 votes vote down vote up
public CustomSlider(int xPos, int yPos, ITextComponent displayStr, double minVal, double maxVal, double currentVal, IPressable handler, ISlider par) {
    super(xPos, yPos, 202, 20, displayStr, new StringTextComponent(""), minVal, maxVal, currentVal, false, true, handler, par);
}
 
Example #22
Source File: BleachLogger.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public static void infoMessage(String s) {
	Minecraft.getInstance().ingameGUI.getChatGUI()
		.printChatMessage(new StringTextComponent("�5[BleachHack] �9�lINFO: �9" + s));
}
 
Example #23
Source File: GuiSprint.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
public GuiSprint(Screen parentScreen){
	super(new StringTextComponent("Better Sprinting"));
	this.parentScreen = parentScreen;
}
 
Example #24
Source File: ModificationTableTileEntity.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Override
public ITextComponent getDisplayName() {
    return new StringTextComponent(getType().getRegistryName().getPath());
}
 
Example #25
Source File: ToggleButton.java    From MiningGadgets with MIT License 4 votes vote down vote up
public List<String> getTooltip() {
    return Arrays.asList(this.getMessage(), new StringTextComponent("Enabled: " + this.enabled).setStyle(new Style().setColor(this.enabled ? TextFormatting.GREEN : TextFormatting.RED)).getFormattedText());
}
 
Example #26
Source File: ClickGuiScreen.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public ClickGuiScreen(ITextComponent titleIn) {
	super(new StringTextComponent("ClickGui"));
}
 
Example #27
Source File: ServerScraperScreen.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public ServerScraperScreen(MultiplayerScreen serverScreen) {
	super(new StringTextComponent("Server Scraper"));
	this.serverScreen = serverScreen;
}
 
Example #28
Source File: CleanUpScreen.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public CleanUpScreen(MultiplayerScreen serverScreen) {
	super(new StringTextComponent("Server Cleanup"));
	this.serverScreen = serverScreen;
}
 
Example #29
Source File: BleachLogger.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public static void noPrefixMessage(String s) {
	Minecraft.getInstance().ingameGUI.getChatGUI()
		.printChatMessage(new StringTextComponent(s));
}
 
Example #30
Source File: BleachLogger.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public static void errorMessage(String s) {
	Minecraft.getInstance().ingameGUI.getChatGUI()
		.printChatMessage(new StringTextComponent("�5[BleachHack] �c�lERROR: �c" + s));
}