类net.minecraft.util.text.StringTextComponent源码实例Demo

下面列出了怎么用net.minecraft.util.text.StringTextComponent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: bleachhack-1.14   文件: BleachMainMenu.java
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();
}
 
源代码2 项目: NoCubes   文件: TestRunner.java
@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);
}
 
源代码3 项目: bleachhack-1.14   文件: CmdRename.java
@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");
}
 
源代码4 项目: MiningGadgets   文件: MiningVisualsScreen.java
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);
}
 
源代码5 项目: MiningGadgets   文件: MiningSettingScreen.java
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);
}
 
源代码6 项目: MiningGadgets   文件: PacketOpenFilterContainer.java
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);
}
 
源代码7 项目: MiningGadgets   文件: MiningGadget.java
@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)));
}
 
源代码8 项目: NoCubes   文件: TestRunner.java
/**
 * @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;
}
 
@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."));
        }
    }
}
 
源代码10 项目: Survivalist   文件: ClientEvents.java
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_);
    });
}
 
源代码11 项目: Better-Sprinting   文件: ClientEventHandler.java
@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));
	}
}
 
源代码12 项目: Better-Sprinting   文件: IntegrityCheck.java
@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();
	}
}
 
源代码13 项目: Better-Sprinting   文件: ServerCommandConfig.java
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);
	}
}
 
源代码14 项目: XRay-Mod   文件: SupportButton.java
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));
    }
}
 
源代码15 项目: XRay-Mod   文件: GuiBlockList.java
@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()));
}
 
源代码16 项目: bleachhack-1.14   文件: BleachLogger.java
public static void infoMessage(String s) {
	Minecraft.getInstance().ingameGUI.getChatGUI()
		.printChatMessage(new StringTextComponent("�5[BleachHack] �9�lINFO: �9" + s));
}
 
源代码17 项目: bleachhack-1.14   文件: BleachLogger.java
public static void warningMessage(String s) {
	Minecraft.getInstance().ingameGUI.getChatGUI()
		.printChatMessage(new StringTextComponent("�5[BleachHack] �e�lWARNING: �e" + s));
}
 
源代码18 项目: bleachhack-1.14   文件: BleachLogger.java
public static void errorMessage(String s) {
	Minecraft.getInstance().ingameGUI.getChatGUI()
		.printChatMessage(new StringTextComponent("�5[BleachHack] �c�lERROR: �c" + s));
}
 
源代码19 项目: bleachhack-1.14   文件: BleachLogger.java
public static void noPrefixMessage(String s) {
	Minecraft.getInstance().ingameGUI.getChatGUI()
		.printChatMessage(new StringTextComponent(s));
}
 
源代码20 项目: bleachhack-1.14   文件: CleanUpScreen.java
public CleanUpScreen(MultiplayerScreen serverScreen) {
	super(new StringTextComponent("Server Cleanup"));
	this.serverScreen = serverScreen;
}
 
源代码21 项目: bleachhack-1.14   文件: ServerScraperScreen.java
public ServerScraperScreen(MultiplayerScreen serverScreen) {
	super(new StringTextComponent("Server Scraper"));
	this.serverScreen = serverScreen;
}
 
源代码22 项目: bleachhack-1.14   文件: ClickGuiScreen.java
public ClickGuiScreen(ITextComponent titleIn) {
	super(new StringTextComponent("ClickGui"));
}
 
源代码23 项目: MiningGadgets   文件: ToggleButton.java
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());
}
 
@Override
public ITextComponent getDisplayName() {
    return new StringTextComponent(getType().getRegistryName().getPath());
}
 
源代码25 项目: Better-Sprinting   文件: GuiSprint.java
public GuiSprint(Screen parentScreen){
	super(new StringTextComponent("Better Sprinting"));
	this.parentScreen = parentScreen;
}
 
源代码26 项目: Better-Sprinting   文件: ServerCommandConfig.java
private static void sendMessage(CommandSource source, String text){
	source.sendFeedback(new StringTextComponent(text), false);
}
 
源代码27 项目: XRay-Mod   文件: GuiSelectionScreen.java
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);
}
 
源代码28 项目: XRay-Mod   文件: GuiBase.java
public GuiBase(boolean hasSide ) {
    super(new StringTextComponent(""));
    this.hasSide = hasSide;
}
 
源代码29 项目: XRay-Mod   文件: SupportButton.java
public List<StringTextComponent> getSupport() {
    return support;
}
 
源代码30 项目: XRay-Mod   文件: GuiAddBlock.java
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);
}
 
 类所在包
 同包方法