Java Code Examples for org.lwjgl.input.Mouse#getEventButton()
The following examples show how to use
org.lwjgl.input.Mouse#getEventButton() .
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: AdvancedTextWidget.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@SideOnly(Side.CLIENT) private boolean handleCustomComponentClick(ITextComponent textComponent) { Style style = textComponent.getStyle(); if (style.getClickEvent() != null) { ClickEvent clickEvent = style.getClickEvent(); String componentText = clickEvent.getValue(); if (clickEvent.getAction() == Action.OPEN_URL && componentText.startsWith("@!")) { String rawText = componentText.substring(2); ClickData clickData = new ClickData(Mouse.getEventButton(), isShiftDown(), isCtrlDown()); writeClientAction(1, buf -> { clickData.writeToBuf(buf); buf.writeString(rawText); }); return true; } } return false; }
Example 2
Source File: GuiScreenEditKeys.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleInput() throws IOException { if (listeningForNewKey) { if (Mouse.next()) { int button = Mouse.getEventButton(); if (Mouse.isButtonDown(button)) { selected.getKey().setKey(button - 100); listeningForNewKey = false; changeKey.displayString = "Change key"; return; } } if (Keyboard.next()) { int key = Keyboard.getEventKey(); if (Keyboard.isKeyDown(key)) { selected.getKey().setKey(key); listeningForNewKey = false; changeKey.displayString = "Change key"; return; } } } super.handleInput(); }
Example 3
Source File: FastEat.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
@Override public void onTicks() { if (this.isActive() && Mouse.getEventButton() == 1 && Mouse.isButtonDown(1)) { if (this.mode == 1) { int[] ignoredBlockIds = new int[]{23, 25, 26, 54, 58, 61, 62, 64, 69, 71, 77, 84, 92, 96, 107, 116, 117, 118, 120, 130, 137, 143, 145, 146, 149, 150, 154, 158}; for (int id : ignoredBlockIds) { if (Block.getIdFromBlock(Wrapper.INSTANCE.world().getBlock(Wrapper.INSTANCE.mc().objectMouseOver.blockX, Wrapper.INSTANCE.mc().objectMouseOver.blockY, Wrapper.INSTANCE.mc().objectMouseOver.blockZ)) != id) { continue; } return; } } if (Wrapper.INSTANCE.player().inventory.getCurrentItem() == null) { return; } Item item = Wrapper.INSTANCE.player().inventory.getCurrentItem().getItem(); if (Wrapper.INSTANCE.player().onGround && (item instanceof ItemFood || item instanceof ItemPotion) && (Wrapper.INSTANCE.player().getFoodStats().needFood() || item instanceof ItemPotion || item instanceof ItemAppleGold)) { Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C09PacketHeldItemChange(Wrapper.INSTANCE.player().inventory.currentItem)); for (int i = 0; i < 1000; ++i) { Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C03PacketPlayer(false)); } Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C07PacketPlayerDigging(5, 0, 0, 0, 255)); } } }
Example 4
Source File: Game.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 6 votes |
/** * Gets the input. * * @return the input */ public static void getInput() { Keyboard.poll(); keys.clear(); while(Keyboard.next()) { KeyboardEvent ke = new KeyboardEvent(Keyboard.getEventKey(), Keyboard.getEventCharacter(), Keyboard.isRepeatEvent(), Keyboard.getEventKeyState(), KeyboardEvent.generateModifiers()); keys.add(ke); } Mouse.poll(); mouseEvents.clear(); while(Mouse.next()) { MouseEvent me = new MouseEvent( Mouse.getEventX(), Mouse.getEventY(), Mouse.getEventDWheel(), Mouse.getEventButton(), Mouse.getEventButtonState()); mouseEvents.add(me); } }
Example 5
Source File: ContainerEventHandler.java From NotEnoughItems with MIT License | 6 votes |
@SubscribeEvent (priority = EventPriority.LOWEST, receiveCanceled = true)//We need to be called before JEI. public void onGuiMouseEventpre(MouseInputEvent.Pre event) { if (Mouse.getEventButton() == -1 || event.getGui() == null || !Mouse.getEventButtonState()) { return; } Point mouse = GuiDraw.getMousePosition(); int eventButton = Mouse.getEventButton(); if (JEIIntegrationManager.searchBoxOwner == EnumItemBrowser.JEI) { GuiTextFieldFilter fieldFilter = JEIIntegrationManager.getTextFieldFilter(); if (fieldFilter != null && fieldFilter.isMouseOver(mouse.x, mouse.y)) { if (eventButton == 0) { if (fieldFilter.isFocused() && (System.currentTimeMillis() - lastSearchBoxClickTime < 500)) {//double click NEIClientConfig.world.nbt.setBoolean("searchinventories", !SearchField.searchInventories()); NEIClientConfig.world.saveNBT(); lastSearchBoxClickTime = 0L; } else { lastSearchBoxClickTime = System.currentTimeMillis(); } } else if (eventButton == 1) { NEIClientConfig.setSearchExpression("", false); LayoutManager.searchField.setText("", false); } } } }
Example 6
Source File: GuiJSU.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleMouseInput() throws IOException { int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth - this.guiLeft; int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1 - this.guiTop; if (Mouse.getEventDWheel() != 0 && this.areaInventory.isMouseOver(mouseX, mouseY)) { this.scrollBar.handleMouseInput(mouseX, mouseY); } else if ((Mouse.getEventButton() != 0 && Mouse.isButtonDown(0) == false) || this.scrollBar.handleMouseInput(mouseX, mouseY) == false) { super.handleMouseInput(); } }
Example 7
Source File: GuiSoundBlock.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleMouseInput() throws IOException { int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth - this.guiLeft; int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1 - this.guiTop; if (Mouse.getEventDWheel() != 0 && (this.areaSoundList.isMouseOver(mouseX, mouseY) || this.scrollBar.isMouseOver(mouseX, mouseY))) { this.scrollBar.handleMouseInput(mouseX, mouseY); } else if ((Mouse.getEventButton() != 0 && Mouse.isButtonDown(0) == false) || this.scrollBar.handleMouseInput(mouseX, mouseY) == false) { super.handleMouseInput(); } }
Example 8
Source File: Game.java From FEMultiplayer with GNU General Public License v3.0 | 6 votes |
public static void getInput() { Keyboard.poll(); keys.clear(); while(Keyboard.next()) { KeyboardEvent ke = new KeyboardEvent( Keyboard.getEventKey(), Keyboard.getEventCharacter(), Keyboard.isRepeatEvent(), Keyboard.getEventKeyState()); keys.add(ke); } Mouse.poll(); mouseEvents.clear(); while(Mouse.next()) { MouseEvent me = new MouseEvent( Mouse.getEventX(), Mouse.getEventY(), Mouse.getEventDWheel(), Mouse.getEventButton(), Mouse.getEventButtonState()); mouseEvents.add(me); } }
Example 9
Source File: XrayModChooserGui.java From MinecraftX-RAY with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void handleMouseInput() throws IOException { super.handleMouseInput(); int mouseScrollWheelStatus = Mouse.getEventDWheel(); int mouseButtonStatus = Mouse.getEventButton(); boolean mouseButtonState = Mouse.getEventButtonState(); if ((mouseScrollWheelStatus > 0) && (this.listPos > 0)) { --this.listPos; } else if ((mouseScrollWheelStatus < 0) && (this.listPos < this.idList.size() - 1)) { ++this.listPos; } if ((mouseButtonState) && (mouseButtonStatus != -1)) { if ((this.invisibleIdList.indexOf(this.idList.get(this.listPos)) >= 0)) { this.invisibleIdList.remove(this.idList.get(this.listPos)); } else { this.invisibleIdList.add(this.idList.get(this.listPos)); } } }
Example 10
Source File: VillageLordGuiContainer.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
private void drawDonateButton(int mouseX, int mouseY) { GuiButton submitButton = new GuiButton(0, guiLeft + 105, guiTop + 15, buttonWidth, buttonHeight, I18n.format("quest.gui.button.donate")); submitButton.drawButton(mc, mouseX, mouseY, 1); if (Mouse.getEventButtonState() && Mouse.getEventButton() != -1) { if (submitButton.mousePressed(mc, mouseX, mouseY) && mouseCooldownOver()) { mousePressed = Minecraft.getSystemTime(); MessageQuestUpdate message = new MessageQuestUpdate(); message.action = Action.DONATE; message.lordEntityId = inventory.getEntityId(); ToroQuestPacketHandler.INSTANCE.sendToServer(message); } } }
Example 11
Source File: VillageLordGuiContainer.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
protected void drawActionButton(String label, Action action, int mouseX, int mouseY, int xOffset) { GuiButton abandonButton = new GuiButton(0, guiLeft + 105 + xOffset, guiTop + 130, buttonWidth, buttonHeight, I18n.format(label)); abandonButton.drawButton(mc, mouseX, mouseY, 1); if (Mouse.getEventButtonState() && Mouse.getEventButton() != -1) { if (abandonButton.mousePressed(mc, mouseX, mouseY) && mouseCooldownOver()) { mousePressed = Minecraft.getSystemTime(); MessageQuestUpdate message = new MessageQuestUpdate(); message.action = action; message.lordEntityId = inventory.getEntityId(); ToroQuestPacketHandler.INSTANCE.sendToServer(message); } } }
Example 12
Source File: Scrollbar.java From Chisel with GNU General Public License v2.0 | 5 votes |
public void handleMouseInput() { if(Mouse.getEventButton() == 0 && !Mouse.getEventButtonState()) { dragged = false; } if(!active) { return; } float initialOffset = offset; int direction = Mouse.getEventDWheel(); if(direction != 0) { offset += direction > 0 ? -step : step; } if(offset < 0) { offset = 0; } if(offset > 1) { offset = 1; } if(initialOffset != offset) { onScrolled(offset); } }
Example 13
Source File: GuiCapture.java From OpenPeripheral-Addons with MIT License | 5 votes |
@Override public void handleMouseInput() { super.handleMouseInput(); final int button = Mouse.getEventButton(); final int wheel = Mouse.getEventDWheel(); final int mx = Mouse.getEventX(); final int my = Mouse.getEventY(); final float scaleX = (float)this.width / this.mc.displayWidth; final float scaleY = (float)this.height / this.mc.displayHeight; final float x = mx * scaleX; final float y = this.height - my * scaleY; if (button != -1 || wheel != 0) { final ScaledResolution resolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); final DrawableHitInfo hit = TerminalManagerClient.instance.findDrawableHit(guid, resolution, x, y); if (button != -1) { final boolean state = Mouse.getEventButtonState(); createMouseButtonEvent(button, state, hit).sendToServer(); final boolean draggingStarted = updateButtonCounter(state); if (draggingStarted) resetDraggingLimiter(x, y); } if (wheel != 0) createMouseWheelEvent(wheel, hit).sendToServer(); } { final float dx = (x - lastDragX); final float dy = (y - lastDragY); if (canSendDragEvent(dx, dy)) { createDragEvent(dx, dy).sendToServer(); resetDraggingLimiter(x, y); } } }
Example 14
Source File: ClickButtonWidget.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
protected void triggerButton() { ClickData clickData = new ClickData(Mouse.getEventButton(), isShiftDown(), isCtrlDown()); writeClientAction(1, clickData::writeToBuf); playButtonClickSound(); }
Example 15
Source File: HyperiumMinecraft.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public void runTickMouseButton() { // Activates for EVERY mouse button. int i = Mouse.getEventButton(); boolean state = Mouse.getEventButtonState(); EventBus.INSTANCE.post(state ? new MouseButtonEvent(i, true) : new MouseButtonEvent(i, false)); }
Example 16
Source File: GuiScreenPlus.java From Chisel with GNU General Public License v2.0 | 4 votes |
@Override public void handleMouseInput() { mouseEvent.handled = false; mouseEvent.x = Mouse.getEventX() * width / mc.displayWidth - this.screenX; mouseEvent.y = height - Mouse.getEventY() * height / mc.displayHeight - 1 - this.screenY; if(oldX == -1) { oldX = mouseEvent.x; oldY = mouseEvent.y; } mouseEvent.dx = mouseEvent.x - oldX; mouseEvent.dy = mouseEvent.y - oldY; oldX = mouseEvent.x; oldY = mouseEvent.y; mouseEvent.down = Mouse.getEventButtonState(); mouseEvent.button = Mouse.getEventButton(); mouseEvent.wheel = Mouse.getEventDWheel(); if(mouseEvent.wheel != 0) { if(mouseEvent.wheel < 0) { mouseEvent.wheel = -1; } else { mouseEvent.wheel = 1; } root.mouseWheel(mouseEvent); } else if(mouseEvent.button >= 0 && mouseEvent.button < downButtons.length) { if(downButtons[mouseEvent.button] != mouseEvent.down) { downButtons[mouseEvent.button] = mouseEvent.down; if(mouseEvent.down) { root.mouseDown(mouseEvent); } else { root.mouseUp(mouseEvent); } } else if(mouseEvent.dx != 0 || mouseEvent.dy != 0) { root.mouseMove(mouseEvent); } } else if(mouseEvent.dx != 0 || mouseEvent.dy != 0) { root.mouseMove(mouseEvent); } if(!mouseEvent.handled) { super.handleMouseInput(); } }