net.minecraft.util.text.TranslationTextComponent Java Examples
The following examples show how to use
net.minecraft.util.text.TranslationTextComponent.
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: JsonStore.java From XRay-Mod with GNU General Public License v3.0 | 6 votes |
public List<BlockData.SerializableBlockData> populateDefault() { List<BlockData.SerializableBlockData> oresData = new ArrayList<>(); Tags.Blocks.ORES.func_230236_b_().forEach(e -> { if( e.getRegistryName() == null ) return; oresData.add(new BlockData.SerializableBlockData(new TranslationTextComponent(e.getTranslationKey()).getString(), e.getRegistryName().toString(), (rand.nextInt(255) << 16) + (rand.nextInt(255) << 8) + rand.nextInt(255), false, 0) ); }); for (int i = 0; i < oresData.size(); i++) oresData.get(i).setOrder(i); XRay.logger.info("Setting up default syncRenderList"); this.write(oresData); return oresData; }
Example #2
Source File: GuiSelectionScreen.java From XRay-Mod with GNU General Public License v3.0 | 6 votes |
@Override // @mcp: func_230432_a_ = render public void func_230432_a_(MatrixStack stack, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) { BlockData blockData = this.block; FontRenderer font = Minecraft.getInstance().fontRenderer; // @mcp: func_238407_a_ = drawString font.func_238407_a_(stack, ITextProperties.func_240652_a_(blockData.getEntryName()), left + 40, top + 7, 0xFFFFFF); font.func_238407_a_(stack, ITextProperties.func_240652_a_(blockData.isDrawing() ? "Enabled" : "Disabled"), left + 40, top + 17, blockData.isDrawing() ? Color.GREEN.getRGB() : Color.RED.getRGB()); RenderHelper.enableStandardItemLighting(); Minecraft.getInstance().getItemRenderer().renderItemAndEffectIntoGUI(blockData.getItemStack(), left + 15, top + 7); RenderHelper.disableStandardItemLighting(); if (mouseX > left && mouseX < (left + entryWidth) && mouseY > top && mouseY < (top + entryHeight) && mouseY < (this.parent.getTop() + this.parent.getHeight()) && mouseY > this.parent.getTop()) { this.parent.parent.func_238654_b_( stack, Arrays.asList(new TranslationTextComponent("xray.tooltips.edit1"), new TranslationTextComponent("xray.tooltips.edit2")), left + 15, (entryIdx == this.parent.func_231039_at__().size() - 1 ? (top - (entryHeight - 20)) : (top + (entryHeight + 15))) // @mcp: func_231039_at__ = getEntries ); // @mcp: func_230457_a_ = renderTooltip } RenderSystem.enableAlphaTest(); RenderSystem.enableBlend(); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); Minecraft.getInstance().getRenderManager().textureManager.bindTexture(GuiSelectionScreen.CIRCLE); GuiBase.drawTexturedQuadFit((left + entryWidth) - 37, top + (entryHeight / 2f) - 9, 14, 14, new int[]{255, 255, 255}, 50f); GuiBase.drawTexturedQuadFit((left + entryWidth) - 35, top + (entryHeight / 2f) - 7, 10, 10, blockData.getColor()); RenderSystem.disableAlphaTest(); RenderSystem.disableBlend(); }
Example #3
Source File: Controller.java From XRay-Mod with GNU General Public License v3.0 | 6 votes |
public static void toggleXRay() { if ( !xrayActive) // enable drawing { Render.syncRenderList.clear(); // first, clear the buffer executor = Executors.newSingleThreadExecutor(); xrayActive = true; // then, enable drawing requestBlockFinder( true ); // finally, force a refresh if( !Configuration.general.showOverlay.get() && XRay.mc.player != null ) XRay.mc.player.sendStatusMessage(new TranslationTextComponent("xray.toggle.activated"), false); } else // disable drawing { if( !Configuration.general.showOverlay.get() && XRay.mc.player != null ) XRay.mc.player.sendStatusMessage(new TranslationTextComponent("xray.toggle.deactivated"), false); shutdownExecutor(); } }
Example #4
Source File: ScrapingDisabledWarning.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SubscribeEvent public static void addInformation(ItemTooltipEvent ev) { if (!ConfigManager.SERVER.enableScraping.get() && EnchantmentHelper.getEnchantmentLevel(SurvivalistMod.SCRAPING.get(), ev.getItemStack()) > 0) { List<ITextComponent> list = ev.getToolTip(); /*int lastScraping = -1; for (int i = 0; i < list.size(); i++) { if (list.get(i).getFormattedText().startsWith(I18n.format("enchantment.survivalist.scraping"))) { lastScraping = i; } } if (lastScraping >= 0) { list.add(lastScraping + 1, "" + TextFormatting.DARK_GRAY + TextFormatting.ITALIC + I18n.format("tooltip.survivalist.scraping.disabled")); }*/ list.add(new TranslationTextComponent("tooltip.survivalist.scraping.disabled").func_240701_a_(TextFormatting.DARK_GRAY, TextFormatting.ITALIC)); } }
Example #5
Source File: MiningVisualsScreen.java From MiningGadgets with MIT License | 5 votes |
@Override protected void init() { int baseX = width / 2, baseY = height / 2; String buttonText; if (MiningProperties.getBreakType(gadget) == MiningProperties.BreakTypes.SHRINK) buttonText = new TranslationTextComponent("mininggadgets.tooltip.screen.shrink").getUnformattedComponentText(); else buttonText = new TranslationTextComponent("mininggadgets.tooltip.screen.fade").getUnformattedComponentText(); blockBreakButton = new Button(baseX - (150 / 2), baseY - 50, 150, 20, buttonText, (button) -> { if (blockBreakButton.getMessage().contains("Shrink")) button.setMessage(new TranslationTextComponent("mininggadgets.tooltip.screen.fade").getUnformattedComponentText()); else button.setMessage(new TranslationTextComponent("mininggadgets.tooltip.screen.shrink").getUnformattedComponentText()); PacketHandler.sendToServer(new PacketChangeBreakType()); }); addButton(blockBreakButton); sliderRedInner = new Slider(baseX - (150), baseY - 25, 150, 20, new TranslationTextComponent("mininggadgets.tooltip.screen.red_outer").getUnformattedComponentText() + ": ", "", 0, 255, this.red, false, true, s -> { }, this); sliderGreenInner = new Slider(baseX - (150), baseY + 5, 150, 20, new TranslationTextComponent("mininggadgets.tooltip.screen.green_outer").getUnformattedComponentText() + ": ", "", 0, 255, this.green, false, true, s -> { }, this); sliderBlueInner = new Slider(baseX - (150), baseY + 35, 150, 20, new TranslationTextComponent("mininggadgets.tooltip.screen.blue_outer").getUnformattedComponentText() + ": ", "", 0, 255, this.blue, false, true, s -> { }, this); sliderRedOuter = new Slider(baseX + (25), baseY - 25, 150, 20, new TranslationTextComponent("mininggadgets.tooltip.screen.red_inner").getUnformattedComponentText() + ": ", "", 0, 255, this.red_inner, false, true, s -> { }, this); sliderGreenOuter = new Slider(baseX + (25), baseY + 5, 150, 20, new TranslationTextComponent("mininggadgets.tooltip.screen.green_inner").getUnformattedComponentText() + ": ", "", 0, 255, this.green_inner, false, true, s -> { }, this); sliderBlueOuter = new Slider(baseX + (25), baseY + 35, 150, 20, new TranslationTextComponent("mininggadgets.tooltip.screen.blue_inner").getUnformattedComponentText() + ": ", "", 0, 255, this.blue_inner, false, true, s -> { }, this); addButton(sliderRedInner); addButton(sliderGreenInner); addButton(sliderBlueInner); addButton(sliderRedOuter); addButton(sliderGreenOuter); addButton(sliderBlueOuter); }
Example #6
Source File: GuiHelp.java From XRay-Mod with GNU General Public License v3.0 | 5 votes |
@Override // @mcp: func_231160_c_ = init public void func_231160_c_() { super.func_231160_c_(); areas.clear(); areas.add(new LinedText("xray.message.help.gui")); areas.add(new LinedText("xray.message.help.warning")); this.addButton(new Button((getWidth() / 2) - 100, (getHeight() / 2) + 80, 200, 20, new TranslationTextComponent("xray.single.close"), b -> this.onClose())); }
Example #7
Source File: GuiBlockList.java From XRay-Mod with GNU General Public License v3.0 | 5 votes |
@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 #8
Source File: SupportButton.java From XRay-Mod with GNU General Public License v3.0 | 5 votes |
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 #9
Source File: GuiSelectionScreen.java From XRay-Mod with GNU General Public License v3.0 | 5 votes |
@Override // @mcp: func_231044_a_ = mouseClicked public boolean func_231044_a_(double x, double y, int mouse) { if( search.func_231044_a_(x, y, mouse) ) this.func_231035_a_(search); // @mcp: func_231035_a_ = setFocused if (mouse == 1 && distButtons.func_231047_b_(x, y)) { // @mcp: func_231047_b_ = isMouseOver Controller.decrementCurrentDist(); distButtons.func_238482_a_(new TranslationTextComponent("xray.input.distance", Controller.getRadius())); // @mcp: func_238482_a_ = setMessage distButtons.func_230988_a_(Minecraft.getInstance().getSoundHandler()); // @mcp: func_230988_a_ = PlayDownSound } return super.func_231044_a_(x, y, mouse); }
Example #10
Source File: ServerCommandConfig.java From Better-Sprinting with Mozilla Public License 2.0 | 5 votes |
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 #11
Source File: ClientEvents.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
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: Frequency.java From EnderStorage with MIT License | 5 votes |
public ITextComponent getTooltip() { return new TranslationTextComponent(getLeft().getUnlocalizedName())// .appendText("/")// .appendSibling(new TranslationTextComponent(getMiddle().getUnlocalizedName()))// .appendText("/")// .appendSibling(new TranslationTextComponent(getRight().getUnlocalizedName())); }
Example #13
Source File: ItemEnderPouch.java From EnderStorage with MIT License | 5 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { ItemStack stack = player.getHeldItem(hand); if (player.isShiftKeyDown()) { return new ActionResult<>(ActionResultType.PASS, stack); } if (!world.isRemote) { Frequency frequency = Frequency.readFromStack(stack); EnderStorageManager.instance(world.isRemote).getStorage(frequency, EnderItemStorage.TYPE).openContainer((ServerPlayerEntity) player, new TranslationTextComponent(stack.getTranslationKey())); } return new ActionResult<>(ActionResultType.SUCCESS, stack); }
Example #14
Source File: MiningGadget.java From MiningGadgets with MIT License | 5 votes |
@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 #15
Source File: UpgradeCard.java From MiningGadgets with MIT License | 5 votes |
@Override public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) { super.addInformation(stack, world, tooltip, flag); if (stack.getItem() instanceof UpgradeCard) { Upgrade upgrade = ((UpgradeCard) stack.getItem()).upgrade; int cost = upgrade.getCostPerBlock(); if (cost > 0) tooltip.add(new TranslationTextComponent("mininggadgets.tooltip.item.upgrade_cost", cost).applyTextStyle(TextFormatting.AQUA)); cost = 0; if (upgrade == Upgrade.LIGHT_PLACER) cost = Config.UPGRADECOST_LIGHT.get(); if (upgrade == Upgrade.FREEZING) cost = Config.UPGRADECOST_FREEZE.get(); if (cost > 0) tooltip.add(new TranslationTextComponent("mininggadgets.tooltip.item.use_cost", cost).applyTextStyle(TextFormatting.AQUA)); if( upgrade.getBaseName().equals(Upgrade.BATTERY_1.getBaseName()) ) { UpgradeBatteryLevels.getBatteryByLevel(upgrade.getTier()).ifPresent(e -> { tooltip.add(new TranslationTextComponent("mininggadgets.tooltip.item.battery_boost", MagicHelpers.tidyValue(e.getPower())).applyTextStyle(TextFormatting.AQUA)); }); } tooltip.add(new TranslationTextComponent(this.upgrade.getTooltop()).applyTextStyle(TextFormatting.GRAY)); } }
Example #16
Source File: MiningVisualsScreen.java From MiningGadgets with MIT License | 5 votes |
@Override public void render(int mouseX, int mouseY, float partialTicks) { this.renderBackground(); super.render(mouseX, mouseY, partialTicks); drawCenteredString(getMinecraft().fontRenderer, new TranslationTextComponent("mininggadgets.tooltip.screen.visual_settings").getUnformattedComponentText(), (width / 2), (height / 2) - 70, Color.WHITE.getRGB()); //drawCenteredString(getMinecraft().fontRenderer, "Toggle Upgrades", (width / 2), (height / 2) + 20, Color.WHITE.getRGB()); }
Example #17
Source File: SawmillTileEntity.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public ITextComponent getDisplayName() { return new TranslationTextComponent("text.survivalist.sawmill"); }
Example #18
Source File: SawmillScreen.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected ITextComponent func_230479_g_() { return new TranslationTextComponent("gui.recipebook.toggleRecipes.smeltable"); }
Example #19
Source File: DryingRackTileEntity.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public ITextComponent getDisplayName() { return new TranslationTextComponent("text.survivalist.rack.inventory"); }
Example #20
Source File: TileEnderChest.java From EnderStorage with MIT License | 4 votes |
@Override public boolean activate(PlayerEntity player, int subHit, Hand hand) { getStorage().openContainer((ServerPlayerEntity) player, new TranslationTextComponent(getBlockState().getBlock().getTranslationKey())); return true; }
Example #21
Source File: GuiSelectionScreen.java From XRay-Mod with GNU General Public License v3.0 | 4 votes |
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 #22
Source File: FilterScreen.java From MiningGadgets with MIT License | 4 votes |
@Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { font.drawString(new TranslationTextComponent("mininggadgets.tooltip.single.filters").getUnformattedComponentText(), 8, 6, 4210752); font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8, (this.ySize - 96 + 3), 4210752); }
Example #23
Source File: MiningSettingScreen.java From MiningGadgets with MIT License | 4 votes |
private static String getTrans(String key, Object... args) { return new TranslationTextComponent(MiningGadgets.MOD_ID + "." + key, args).getUnformattedComponentText(); }
Example #24
Source File: MiningSettingScreen.java From MiningGadgets with MIT License | 4 votes |
@Override protected void init() { List<Widget> leftWidgets = new ArrayList<>(); int baseX = width / 2, baseY = height / 2; // Filters out the non-toggleable options toggleableList.clear(); toggleableList = UpgradeTools.getUpgrades(this.gadget).stream().filter(Upgrade::isToggleable).collect(Collectors.toList()); containsFreeze = UpgradeTools.containsUpgradeFromList(toggleableList, Upgrade.FREEZING); boolean containsVoid = UpgradeTools.containsUpgradeFromList(toggleableList, Upgrade.VOID_JUNK); isWhitelist = MiningProperties.getWhiteList(gadget); isPrecision = MiningProperties.getPrecisionMode(gadget); int top = baseY - (containsFreeze ? 80 : 60); // Right size // Remove 6 from x to center it as the padding on the right pushes off center... (I'm a ui nerd) int index = 0, x = baseX + 10, y = top + (containsVoid ? 45 : 20); for (Upgrade upgrade : toggleableList) { ToggleButton btn = new ToggleButton(x + (index * 30), y, UpgradeTools.getName(upgrade), new ResourceLocation(MiningGadgets.MOD_ID, "textures/item/upgrade_" + upgrade.getName() + ".png"), send -> this.toggleUpgrade(upgrade, send)); addButton(btn); upgradeButtons.put(upgrade, btn); // Spaces the upgrades index ++; if( index % 4 == 0 ) { index = 0; y += 35; } } // Don't add if we don't have voids if( containsVoid ) { addButton(new Button(baseX + 10, top + 20, 95, 20, getTrans("tooltip.screen.edit_filters"), (button) -> { PacketHandler.sendToServer(new PacketOpenFilterContainer()); })); addButton(new WhitelistButton(baseX + 10 + (115 - 20), top + 20, 20, 20, isWhitelist, (button) -> { isWhitelist = !isWhitelist; ((WhitelistButton) button).setWhitelist(isWhitelist); PacketHandler.sendToServer(new PacketToggleFilters()); })); } // Left size currentSize = MiningProperties.getRange(gadget); Button sizeButton; leftWidgets.add(sizeButton = new Button(baseX - 135, 0, 125, 20, new TranslationTextComponent("mininggadgets.tooltip.screen.size", currentSize).getUnformattedComponentText(), (button) -> { currentSize = currentSize == 1 ? 3 : 1; button.setMessage(getTrans("tooltip.screen.size", currentSize)); PacketHandler.sendToServer(new PacketChangeMiningSize()); })); leftWidgets.add(rangeSlider = new Slider(baseX - 135, 0, 125, 20, getTrans("tooltip.screen.range") + ": ", "", 1, MiningProperties.getBeamMaxRange(gadget), this.beamRange, false, true, s -> {}, this)); leftWidgets.add(new Button(baseX - 135, 0, 125, 20, getTrans("tooltip.screen.visuals_menu"), (button) -> { ModScreens.openVisualSettingsScreen(gadget); })); //Precision Mode leftWidgets.add(new Button(baseX - 135, 0, 125, 20, getTrans("tooltip.screen.precision_mode", isPrecision), (button) -> { isPrecision = !isPrecision; button.setMessage(getTrans("tooltip.screen.precision_mode", isPrecision)); PacketHandler.sendToServer(new PacketTogglePrecision()); })); // volume slider leftWidgets.add(volumeSlider = new Slider(baseX - 135, 0, 125, 20, getTrans("tooltip.screen.volume") + ": ", "%", 0, 100, Math.min(100, volume * 100), false, true, s -> {}, this)); // Freeze delay if( containsFreeze ) leftWidgets.add(freezeDelaySlider = new Slider(baseX - 135, 0, 125, 20, getTrans("tooltip.screen.freeze_delay") + ": ", " " + getTrans("tooltip.screen.ticks"), 0, 10, MiningProperties.getFreezeDelay(gadget), false, true, s -> {}, this)); // Button logic if( !UpgradeTools.containsActiveUpgrade(gadget, Upgrade.THREE_BY_THREE) ) sizeButton.active = false; // Lay the buttons out, too lazy to figure out the math every damn time. // Ordered by where you add them. for(int i = 0; i < leftWidgets.size(); i ++) { leftWidgets.get(i).y = (top + 20) + (i * 25); addButton(leftWidgets.get(i)); } }
Example #25
Source File: BleachMainMenu.java From bleachhack-1.14 with GNU General Public License v3.0 | 4 votes |
public BleachMainMenu() { super(new TranslationTextComponent("narrator.screen.title")); }
Example #26
Source File: CommandHelper.java From BoundingBoxOutlineReloaded with MIT License | 4 votes |
static void feedback(CommandContext<CommandSource> context, String format, Object... values) { context.getSource().sendFeedback(new TranslationTextComponent(format, values), false); }