net.minecraft.client.gui.GuiButton Java Examples
The following examples show how to use
net.minecraft.client.gui.GuiButton.
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: GuiScreenEditKeys.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void actionPerformed(GuiButton button) { switch (button.id) { case 1: CustomKeyWrapper key = new CustomKeyWrapper(new CustomKey(mod, 30, 1), 10, 10); selected = key; mod.getRenderer().getCustomKeys().add(key); break; case 2: listeningForNewKey = true; changeKey.displayString = "Listening..."; break; case 3: CustomKey theKey = selected.getKey(); theKey.setType(theKey.getType() + 1); if (theKey.getType() > 2) { theKey.setType(0); break; } break; case 4: mod.getRenderer().getCustomKeys().remove(selected); selected = null; break; } }
Example #2
Source File: GuiProgWidgetItemFilter.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void actionPerformed(GuiButton button){ if(button.id == 0) { searchGui = new GuiSearcher(FMLClientHandler.instance().getClient().thePlayer); searchGui.setSearchStack(widg.getFilter()); FMLClientHandler.instance().showGuiScreen(searchGui); } else if(button.id == 1) { invSearchGui = new GuiInventorySearcher(FMLClientHandler.instance().getClient().thePlayer); invSearchGui.setSearchStack(widg.getFilter()); FMLClientHandler.instance().showGuiScreen(invSearchGui); } else if(button.id == 2) { if(--widg.specificMeta < 0) widg.specificMeta = 15; } else if(button.id == 3) { if(++widg.specificMeta > 15) widg.specificMeta = 0; } super.actionPerformed(button); }
Example #3
Source File: GuiReactorControlRod.java From BigReactors with MIT License | 6 votes |
@Override protected void actionPerformed(GuiButton button) { switch(button.id) { case 2: CommonPacketHandler.INSTANCE.sendToServer(new ControlRodChangeNameMessage(entity.xCoord, entity.yCoord, entity.zCoord, this.rodName.getText())); this.rodName.setFocused(false); break; case 0: case 1: default: int change = 10; if(isShiftKeyDown()) { if(isAltKeyDown()) { change = 1; } else { change = 100; } } else if(isAltKeyDown()) { change = 5; } if(button.id == 1) { change = -change; } CommonPacketHandler.INSTANCE.sendToServer(new ControlRodChangeInsertionMessage(entity.xCoord, entity.yCoord, entity.zCoord, change, isCtrlKeyDown())); } }
Example #4
Source File: GuiScreenBackground.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
protected void actionPerformed(GuiButton button) { switch (button.id) { case 0: sidebar.chromaEnabled = !sidebar.chromaEnabled; button.displayString = "Chroma: " + getSuffix(sidebar.chromaEnabled); setSlidersVisibility(); break; case 6: mc.displayGuiScreen(parent); break; case 7: sidebar.chromaType = GuiSidebar.ChromaType.next(sidebar.chromaType); buttonChromaType.displayString = "Chroma type: " + sidebar.chromaType.getName(); break; } }
Example #5
Source File: FabricatorGui.java From EmergingTechnology with MIT License | 6 votes |
private boolean shouldRenderButton(GuiButton button) { if (button instanceof GuiFabricatorButton) { GuiFabricatorButton fabButton = (GuiFabricatorButton) button; return fabButton.id == selection; } if (button.id == playButtonId) { return !this.printing; } if (button.id == stopButtonId) { return this.printing; } if (button.id == previousButtonId || button.id == nextButtonId) { return !this.printing; } return false; }
Example #6
Source File: FabricatorGui.java From EmergingTechnology with MIT License | 6 votes |
@Override protected void actionPerformed(GuiButton button) { if (button.id == previousButtonId) { previousPage(); } if (button.id == nextButtonId) { nextPage(); } if (button.id == playButtonId) { this.printing = true; updateFabricatorPrinting(); } if (button.id == stopButtonId) { this.printing = false; updateFabricatorPrinting(); } }
Example #7
Source File: GuiShieldSelection.java From Levels with GNU General Public License v2.0 | 6 votes |
@SideOnly(Side.CLIENT) @Override protected void actionPerformed(GuiButton button) throws IOException { EntityPlayerSP player = mc.player; ItemStack stack = player.inventory.getCurrentItem(); NBTTagCompound nbt = NBTHelper.loadStackNBT(stack); if (player != null && stack != null && nbt != null) { if (Experience.getAttributeTokens(nbt) > 0) { if (stack.getItem() instanceof ItemShield) { for (int i = 0; i < attributes.length; i++) { if (button == attributes[i]) Levels.network.sendToServer(new PacketAttributeSelection(i)); } } } } }
Example #8
Source File: GuiProblemScreen.java From VanillaFix with MIT License | 6 votes |
@Override protected void actionPerformed(GuiButton button) { if (button.id == 1) { try { if (hasteLink == null) { hasteLink = HasteUpload.uploadToHaste(ModConfig.crashes.hasteURL, "mccrash", report.getCompleteReport()); } ReflectionHelper.findField(GuiScreen.class, "clickedLinkURI", "field_175286_t").set(this, new URI(hasteLink)); mc.displayGuiScreen(new GuiConfirmOpenLink(this, hasteLink, 31102009, false)); } catch (Throwable e) { log.error("Exception when crash menu button clicked:", e); button.displayString = I18n.format("vanillafix.gui.failed"); button.enabled = false; } } }
Example #9
Source File: GuiPortalPanel.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void actionPerformed(GuiButton button) throws IOException { super.actionPerformed(button); if (button.id >= 0 && button.id < 8) { PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(this.tepp.getWorld().provider.getDimension(), this.tepp.getPos(), ReferenceGuiIds.GUI_ID_TILE_ENTITY_GENERIC, 0, button.id)); } else if (button.id == 8) { PacketHandler.INSTANCE.sendToServer(new MessageSendString(Type.BLOCK, this.nameField.getText())); this.nameLast = this.nameField.getText(); } }
Example #10
Source File: GuiBowSelection.java From Levels with GNU General Public License v2.0 | 6 votes |
@SideOnly(Side.CLIENT) @Override protected void actionPerformed(GuiButton button) throws IOException { EntityPlayerSP player = mc.player; ItemStack stack = player.inventory.getCurrentItem(); NBTTagCompound nbt = NBTHelper.loadStackNBT(stack); if (player != null && stack != null && nbt != null) { if (Experience.getAttributeTokens(nbt) > 0) { if (stack.getItem() instanceof ItemBow) { for (int i = 0; i < attributes.length; i++) { if (button == attributes[i]) Levels.network.sendToServer(new PacketAttributeSelection(i)); } } } } }
Example #11
Source File: MainMenuGuiService.java From ForgeHax with MIT License | 6 votes |
@SubscribeEvent public void onGui(GuiScreenEvent.InitGuiEvent.Post event) { if (event.getGui() instanceof GuiMainMenu) { GuiMainMenu gui = (GuiMainMenu) event.getGui(); event .getButtonList() .stream() .skip(4) // skip first 4 button .forEach( button -> { button.y += 24; }); // lower the rest of the buttons to make room for ours event .getButtonList() .add( customButton = new GuiButton( 666, gui.width / 2 - 100, gui.height / 4 + 48 + (24 * 3), // put button in 4th row "Command Input")); } }
Example #12
Source File: GuiWirelessSniffer.java From WirelessRedstone with MIT License | 6 votes |
protected void actionPerformed(GuiButton guibutton) { switch(guibutton.id) { case 0: page++; break; case 1: page--; break; } if(page < 0) { page = RedstoneEther.numfreqs / 1000 - 1; } else if(page > RedstoneEther.numfreqs / 1000 - 1) { page = 0; } }
Example #13
Source File: CreativeMenuHandler.java From Cyberware with MIT License | 6 votes |
@SubscribeEvent public void handleButtons(InitGuiEvent event) { if (event.getGui() instanceof GuiContainerCreative) { GuiContainerCreative gui = (GuiContainerCreative) event.getGui(); int i = (gui.width - 136) / 2; int j = (gui.height - 195) / 2; List<GuiButton> buttons = event.getButtonList(); buttons.add(salvaged = new CEXButton(355, i + 166 + 4, j + 29 + 8, 0)); buttons.add(manufactured = new CEXButton(356, i + 166 + 4, j + 29 + 31, 1)); int selectedTabIndex = ReflectionHelper.getPrivateValue(GuiContainerCreative.class, (GuiContainerCreative) gui, 2); if (selectedTabIndex != Cyberware.creativeTab.getTabIndex()) { salvaged.visible = false; manufactured.visible = false; } event.setButtonList(buttons); } }
Example #14
Source File: GuiRecipe.java From NotEnoughItems with MIT License | 6 votes |
@Override protected void actionPerformed(GuiButton guibutton) throws IOException { super.actionPerformed(guibutton); switch (guibutton.id) { case 0: prevType(); break; case 1: nextType(); break; case 2: prevPage(); break; case 3: nextPage(); break; case 4: overlayRecipe(page * currenthandlers.get(recipetype).recipiesPerPage()); break; case 5: overlayRecipe(page * currenthandlers.get(recipetype).recipiesPerPage() + 1); break; } }
Example #15
Source File: GuiPeripheral.java From AgriCraft with MIT License | 6 votes |
private void updateButtons() { for (int i = 1; i < buttonList.size(); i++) { Object obj = buttonList.get(i); if (obj == null) { continue; } GuiButton button = (GuiButton) obj; if (button instanceof GuiButtonMethod) { if (!guideActive) { ((GuiButtonMethod) button).disable(); } else { int index = i - BUTTON_ID_SCROLL_TOP - 1; if (index >= scrollPosition && index < scrollPosition + BUTTON_AMOUNT) { ((GuiButtonMethod) button).enable(this.guiTop + 8 + 16 * (index - scrollPosition)); } else { ((GuiButtonMethod) button).disable(); } } } else { button.visible = guideActive; } } }
Example #16
Source File: GuiRecipe.java From NotEnoughItems with MIT License | 6 votes |
@Override protected void actionPerformed(GuiButton guibutton) throws IOException { super.actionPerformed(guibutton); switch (guibutton.id) { case 0: prevType(); break; case 1: nextType(); break; case 2: prevPage(); break; case 3: nextPage(); break; case 4: overlayRecipe(page * currenthandlers.get(recipetype).recipiesPerPage()); break; case 5: overlayRecipe(page * currenthandlers.get(recipetype).recipiesPerPage() + 1); break; } }
Example #17
Source File: CustomLevelheadConfigurer.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void actionPerformed(GuiButton button) { Consumer<GuiButton> guiButtonConsumer = clicks.get(button); if (guiButtonConsumer != null) { guiButtonConsumer.accept(button); } }
Example #18
Source File: CreateServerButton.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 2) { mc.displayGuiScreen(parent); } super.actionPerformed(button); }
Example #19
Source File: GuiAnvil.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { if (clickedMouseButton == 0) { for (int l = 0; l < this.buttonList.size(); ++l) { GuiButton guibutton = (GuiButton)this.buttonList.get(l); if (guibutton.mousePressed(this.mc, mouseX, mouseY)) { ActionPerformedEvent.Pre event = new ActionPerformedEvent.Pre(this, guibutton, this.buttonList); if (MinecraftForge.EVENT_BUS.post(event)) break; if(selectedButton == event.getButton()) continue; else { this.mouseReleased(mouseX, mouseY, 0); } this.selectedButton = event.getButton(); event.getButton().playPressSound(this.mc.getSoundHandler()); this.actionPerformed(event.getButton()); if (this.equals(this.mc.currentScreen)) MinecraftForge.EVENT_BUS.post(new ActionPerformedEvent.Post(this, event.getButton(), this.buttonList)); } } } }
Example #20
Source File: MwGuiOptions.java From mapwriter with MIT License | 5 votes |
@SuppressWarnings("unchecked") public void initGui() { this.optionSlot = new MwGuiOptionSlot(this, this.mc, this.mw); this.optionSlot.registerScrollButtons(7, 8); this.buttonList.add(new GuiButton(200, (this.width / 2) - 50, this.height - 28, 100, 20, "Done")); }
Example #21
Source File: GuiKnapping.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { // 1-st Check if the click falls inside the Knapping Grid boundaries. // (Doing so reduces the lag & allows for super methods to run when inventory slots are clicked.) if (mouseY > 88+guiTop || mouseX > 88+guiLeft || mouseY < 16+guiTop || mouseX < 16+guiLeft) { super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); return; } if (clickedMouseButton == 0) { for (int l = 0; l < this.buttonList.size(); ++l) { GuiButton guibutton = (GuiButton)this.buttonList.get(l); if (guibutton.mousePressed(this.mc, mouseX, mouseY)) { ActionPerformedEvent.Pre event = new ActionPerformedEvent.Pre(this, guibutton, this.buttonList); if (MinecraftForge.EVENT_BUS.post(event)) break; if(selectedButton == event.getButton()) continue; else { this.mouseReleased(mouseX, mouseY, 0); } this.selectedButton = event.getButton(); event.getButton().playPressSound(this.mc.getSoundHandler()); this.actionPerformed(event.getButton()); if (this.equals(this.mc.currentScreen)) MinecraftForge.EVENT_BUS.post(new ActionPerformedEvent.Post(this, event.getButton(), this.buttonList)); } } } else super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); }
Example #22
Source File: GuiChunkLoader.java From ChickenChunks with MIT License | 5 votes |
public void initGui() { buttonList.clear(); buttonList.add(new GuiButton(1, width / 2 - 20, height / 2 - 45, 20, 20, "+")); buttonList.add(new GuiButton(2, width / 2 - 80, height / 2 - 45, 20, 20, "-")); buttonList.add(laserButton = new GuiButton(3, width / 2 + 7, height / 2 - 60, 75, 20, "-")); buttonList.add(shapeButton = new GuiButton(4, width / 2 + 7, height / 2 - 37, 75, 20, "-")); updateNames(); super.initGui(); }
Example #23
Source File: GTGuiCompWorktable.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override @SideOnly(Side.CLIENT) public void onButtonClick(GuiIC2 gui, GuiButton button) { if (button.id == 2) { this.block.getNetwork().initiateClientTileEntityEvent(this.block, 2); } if (button.id == 1) { this.block.getNetwork().initiateClientTileEntityEvent(this.block, 1); } }
Example #24
Source File: GTGuiCompTypeFilter.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override @SideOnly(Side.CLIENT) public void onButtonClick(GuiIC2 gui, GuiButton button) { super.onButtonClick(gui, button); if (button.id == 5) { this.tile.getNetwork().initiateClientTileEntityEvent(this.tile, 5); } }
Example #25
Source File: ButtonTooltip.java From MediaMod with GNU General Public License v3.0 | 5 votes |
private boolean isButtonHoveredOver(int mouseX, int mouseY, GuiButton button) { if (mouseX >= button.xPosition && mouseX <= button.xPosition + button.getButtonWidth() && mouseY >= button.yPosition) { return mouseY <= button.yPosition + button.height; } return false; }
Example #26
Source File: CellViewer.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
@Override protected void actionPerformed(GuiButton b) { if (b.id == 1) { container.setPage(container.currentPage - 1); buttonLeft.enabled = container.currentPage > 0; buttonRight.enabled = container.currentPage < (container.slots.size() - 1); } if (b.id == 2) { container.setPage(container.currentPage + 1); buttonLeft.enabled = container.currentPage > 0; buttonRight.enabled = container.currentPage < (container.slots.size() - 1); } }
Example #27
Source File: MoCGUIEntityNamer.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@Override public void initGui() { buttonList.clear(); //1.5 Keyboard.enableRepeatEvents(true); buttonList.add(new GuiButton(0, (width / 2) - 100, (height / 4) + 120, "Done")); //1.5 }
Example #28
Source File: GuiBlockTrackOptions.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void initGui(IGuiScreen gui){ gui.getButtonList().add(new GuiButton(10, 30, 128, 150, 20, "Move Stat Screen...")); for(int i = 0; i < BlockTrackEntryList.instance.trackList.size(); i++) { ((GuiHelmetMainScreen)gui).addWidget(new GuiKeybindCheckBox(i, 5, 32 + i * 12, 0xFFFFFFFF, BlockTrackEntryList.instance.trackList.get(i).getEntryName())); } }
Example #29
Source File: GuiModIdConfig.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
/** * Adds the buttons (and other controls) to the screen in question. */ @Override public void initGui() { modId = new GuiTextField(this.fontRendererObj, this.width / 2 - 99, this.height / 6 + 66, 198, 18); modId.setText(Main.modId); modVersion = new GuiTextField(this.fontRendererObj, this.width / 2 - 99, this.height / 6 + 66 + 36, 198, 18); modVersion.setText(Main.modVersion); saveButton = new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, "Save"); this.buttonList.add(saveButton); }
Example #30
Source File: GuiHelm.java From archimedes-ships with MIT License | 5 votes |
@SuppressWarnings("unchecked") @Override public void initGui() { super.initGui(); Keyboard.enableRepeatEvents(true); int btnx = guiLeft - 100; int btny = guiTop + 20; buttonList.clear(); btnRename = new GuiButton(4, btnx, btny, 100, 20, StatCollector.translateToLocal("gui.shipstatus.rename")); buttonList.add(btnRename); btnAssemble = new GuiButton(1, btnx, btny += 20, 100, 20, StatCollector.translateToLocal("gui.shipstatus.compile")); buttonList.add(btnAssemble); btnUndo = new GuiButton(2, btnx, btny += 20, 100, 20, StatCollector.translateToLocal("gui.shipstatus.undo")); btnUndo.enabled = tileEntity.getPrevAssembleResult() != null && tileEntity.getPrevAssembleResult().getCode() != AssembleResult.RESULT_NONE; buttonList.add(btnUndo); btnMount = new GuiButton(3, btnx, btny += 20, 100, 20, StatCollector.translateToLocal("gui.shipstatus.mount")); btnMount.enabled = tileEntity.getAssembleResult() != null && tileEntity.getAssembleResult().getCode() == AssembleResult.RESULT_OK; buttonList.add(btnMount); txtShipName = new GuiTextField(fontRendererObj, guiLeft + 8 + xSize / 2, guiTop + 21, 120, 10); txtShipName.setMaxStringLength(127); txtShipName.setEnableBackgroundDrawing(false); txtShipName.setVisible(true); txtShipName.setCanLoseFocus(false); txtShipName.setTextColor(0xFFFFFF); txtShipName.setText(tileEntity.getShipInfo().shipName); }