net.minecraft.client.gui.widget.button.Button Java Examples
The following examples show how to use
net.minecraft.client.gui.widget.button.Button.
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 |
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: ScreenInjector.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
@SubscribeEvent public void initGui(InitGuiEvent.Post event) { if (!(Minecraft.getInstance().currentScreen instanceof MultiplayerScreen)) return; event.addWidget(new Button(5, 7, 50, 18, "Scraper", button -> { Minecraft.getInstance().displayGuiScreen(new ServerScraperScreen((MultiplayerScreen) event.getGui())); })); event.addWidget(new Button(58, 7, 50, 18, "Cleanup", button -> { Minecraft.getInstance().displayGuiScreen(new CleanUpScreen((MultiplayerScreen) event.getGui())); })); }
Example #3
Source File: LoginScreen.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void init() { this.addButton(new Button(width / 2 - 100, height / 3 + 84, 200, 20, "Done", (button) -> { minecraft.displayGuiScreen(new BleachMainMenu()); })); this.addButton(new Button(width / 2 - 100, height / 3 + 62, 200, 20, "Login", (button) -> { loginResult = LoginManager.login(userField.getText(), passField.getText()); })); this.userField = new TextFieldWidget(this.font, width / 2 - 98, height / 4 + 10, 196, 18, ""); this.passField = new TextFieldWidget(this.font, width / 2 - 98, height / 4 + 40, 196, 18, ""); super.init(); }
Example #4
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 #5
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 #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: 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)); } }