net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent Java Examples
The following examples show how to use
net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.
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: 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 #2
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 #3
Source File: GuiCustom.java From Custom-Main-Menu with MIT License | 5 votes |
@Override protected void actionPerformed(GuiButton button) throws IOException { if (button instanceof GuiCustomWrappedButton && this.guiConfig.name.equals("mainmenu")) { GuiCustomWrappedButton wrapped = (GuiCustomWrappedButton) button; if (wrapped.wrappedButton != null) { ActionPerformedEvent.Pre event = new ActionPerformedEvent.Pre(new GuiFakeMain(), wrapped.wrappedButton, new ArrayList<GuiButton>()); if (MinecraftForge.EVENT_BUS.post(event)) { return; } event.getButton().playPressSound(this.mc.getSoundHandler()); if (this.equals(this.mc.currentScreen)) { MinecraftForge.EVENT_BUS.post(new ActionPerformedEvent.Post(new GuiFakeMain(), wrapped.wrappedButton, new ArrayList<GuiButton>())); } } } else if (button.id >= 6000 && button instanceof GuiCustomButton) { GuiCustomButton custom = (GuiCustomButton) button; // It's one of mine :o if (custom.b.action != null) { custom.b.action.perform(custom.b, this); } } }