org.lwjgl.input.Mouse Java Examples

The following examples show how to use org.lwjgl.input.Mouse. 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 Project: FEMultiPlayer-V2   Author: eliatlarge   File: Game.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #2
Source Project: jmonkeyengine   Author: jMonkeyEngine   File: LwjglCanvas.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void pauseCanvas(){
    if (Mouse.isCreated()){
        if (Mouse.isGrabbed()){
            Mouse.setGrabbed(false);
            mouseWasGrabbed = true;
        }
        mouseWasCreated = true;
        Mouse.destroy();
    }
    if (Keyboard.isCreated()){
        keyboardWasCreated = true;
        Keyboard.destroy();
    }

    renderable.set(false);
    destroyContext();
}
 
Example #3
Source Project: ForgeHax   Author: fr1kin   File: GuiWindowMod.java    License: MIT License 6 votes vote down vote up
public void handleMouseInput() throws IOException {
  int i = Mouse.getEventDWheel();
  
  i = MathHelper.clamp(i, -1, 1);
  buttonListOffset -= i * 10;
  
  if (buttonListOffset < 0) {
    buttonListOffset = 0; // dont scroll up if its already at the top
  }
  
  int lowestButtonY = (GuiButton.height + 1) * buttonList.size() + windowY;
  int lowestAllowedOffset = lowestButtonY - height - windowY + 3;
  if (lowestButtonY - buttonListOffset < bottomY) {
    buttonListOffset = lowestAllowedOffset;
  }
}
 
Example #4
Source Project: ehacks-pro   Author: radioegor146   File: ExtendedDestroyer.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        boolean nowState = Mouse.isButtonDown(0);
        if (position.sideHit != -1 && nowState && !prevState) {
            ByteBuf buf = Unpooled.buffer(0);
            buf.writeByte(14);
            buf.writeInt(position.blockX);
            buf.writeInt(position.blockY);
            buf.writeInt(position.blockZ);
            C17PacketCustomPayload packet = new C17PacketCustomPayload("cfm", buf);
            Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet);
        }
        prevState = nowState;
    } catch (Exception ignored) {

    }
}
 
Example #5
Source Project: ehacks-pro   Author: radioegor146   File: CarpenterOpener.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && Mouse.isButtonDown(1)) {
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
            ByteBuf buf = Unpooled.buffer(0);
            buf.writeInt(0);
            buf.writeInt(position.blockX);
            buf.writeInt(position.blockY);
            buf.writeInt(position.blockZ);
            buf.writeInt(position.sideHit);
            C17PacketCustomPayload packet = new C17PacketCustomPayload("CarpentersBlocks", buf);
            Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet);
        }
    } catch (Exception e) {

    }
}
 
Example #6
Source Project: enderutilities   Author: maruohon   File: GuiEnderUtilities.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void handleMouseInput() throws IOException
{
    int dWheel = Mouse.getEventDWheel();

    if (dWheel != 0)
    {
        int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
        int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;

        for (int i = 0; i < this.buttonList.size(); i++)
        {
            GuiButton button = this.buttonList.get(i);

            if (button.mousePressed(this.mc, mouseX, mouseY))
            {
                this.actionPerformedWithButton(button, 10 + dWheel / 120);
                break;
            }
        }
    }
    else
    {
        super.handleMouseInput();
    }
}
 
Example #7
Source Project: Cyberware   Author: Flaxbeard   File: GuiEngineeringTable.java    License: MIT License 6 votes vote down vote up
public void drawButton(Minecraft mc, int mouseX, int mouseY)
{
	if (this.visible)
	{
		float trans = 0.4F;
		boolean down = Mouse.isButtonDown(0);
		boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
	
		
		mc.getTextureManager().bindTexture(ENGINEERING_GUI_TEXTURES);

	
		int i = 39;
		int j = 34;
		if (down && flag)
		{
			i = 0;
			j = 166;
		}
		this.drawTexturedModalRect(this.xPosition, this.yPosition, i, j, 21, 21);
	}
}
 
Example #8
Source Project: ehacks-pro   Author: radioegor146   File: SpaceFire.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        if (position.entityHit instanceof EntityLivingBase && Mouse.isButtonDown(0)) {
            Object packetPipeLine = Class.forName("micdoodle8.mods.galacticraft.core.GalacticraftCore").getField("packetPipeline").get(null);
            Method sendMethod = packetPipeLine.getClass().getMethod("sendToServer", Class.forName("micdoodle8.mods.galacticraft.core.network.IPacket"));
            Object packetObj = Class.forName("micdoodle8.mods.galacticraft.core.network.PacketSimple").getConstructor(new Class[]{Class.forName("micdoodle8.mods.galacticraft.core.network.PacketSimple$EnumSimplePacket"), Object[].class}).newInstance(Class.forName("micdoodle8.mods.galacticraft.core.network.PacketSimple$EnumSimplePacket").getMethod("valueOf", String.class).invoke(null, "S_SET_ENTITY_FIRE"), new Object[]{position.entityHit.getEntityId()});
            sendMethod.invoke(packetPipeLine, packetObj);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    } catch (Exception e) {

    }
}
 
Example #9
Source Project: malmo   Author: microsoft   File: MalmoModClient.java    License: MIT License 6 votes vote down vote up
@Override
public void mouseXYChange()
{
    if (this.isOverriding)
    {
        this.deltaX = 0;
        this.deltaY = 0;
        if (Mouse.isGrabbed())
            Mouse.setGrabbed(false);
    }
    else
    {
        super.mouseXYChange();
        if (this.observer != null)
            this.observer.onXYZChange(this.deltaX, this.deltaY, Mouse.getDWheel());
    }
}
 
Example #10
Source Project: Slyther   Author: gegy1000   File: DefaultController.java    License: MIT License 6 votes vote down vote up
@Override
public void update(SlytherClient client) {
    ClientSnake player = client.player;
    accelerating = Mouse.isButtonDown(0) || Mouse.isButtonDown(1);
    int mouseX = Mouse.getX() - (Display.getWidth() / 2);
    int mouseY = (Display.getHeight() - Mouse.getY()) - (Display.getHeight() / 2);
    if (mouseX != lastMouseX || mouseY != lastMouseY) {
        lastMouseX = mouseX;
        lastMouseY = mouseY;
        int dist = mouseX * mouseX + mouseY * mouseY;
        if (dist > 256) {
            targetAngle = (float) Math.atan2(mouseY, mouseX);
            player.eyeAngle = targetAngle;
        } else {
            targetAngle = player.wantedAngle;
        }
    }
}
 
Example #11
Source Project: Hyperium   Author: HyperiumClient   File: CPSKey.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderKey(int x, int y) {
    int yOffset = this.yOffset;

    if (!mod.getSettings().isShowingMouseButtons()) yOffset -= 24;
    if (!mod.getSettings().isShowingSpacebar()) yOffset -= 18;
    if (!mod.getSettings().isShowingSneak()) yOffset -= 18;
    if (!mod.getSettings().isShowingWASD()) yOffset -= 48;

    Mouse.poll();

    int textColor = getColor();

    if (mod.getSettings().isKeyBackgroundEnabled()) {
        Gui.drawRect(x + xOffset, y + yOffset, x + xOffset + 70, y + yOffset + 16,
            new Color(mod.getSettings().getKeyBackgroundRed(), mod.getSettings().getKeyBackgroundGreen(), mod.getSettings().getKeyBackgroundBlue(),
                mod.getSettings().getKeyBackgroundOpacity()).getRGB());
    }

    String name = (mod.getSettings().isLeftClick() ? getLeftCPS() : getRightCPS()) + " CPS";
    if (mod.getSettings().isChroma()) {
        drawChromaString(name, ((x + (xOffset + 70) / 2) - mc.fontRendererObj.getStringWidth(name) / 2), y + (yOffset + 4), 1.0F);
    } else {
        drawCenteredString(name, x + (xOffset + 70) / 2, y + (yOffset + 4), textColor);
    }
}
 
Example #12
Source Project: MinecraftX-RAY   Author: uyjulian   File: XrayModChooserGui.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 #13
Source Project: LiquidBounce   Author: CCBlueX   File: SlowlyStyle.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static float drawSlider(final float value, final float min, final float max, final int x, final int y, final int width, final int mouseX, final int mouseY, final Color color) {
    final float displayValue = Math.max(min, Math.min(value, max));

    final float sliderValue = (float) x + (float) width * (displayValue - min) / (max - min);

    RenderUtils.drawRect(x, y, x + width, y + 2, Integer.MAX_VALUE);
    RenderUtils.drawRect(x, y, sliderValue, y + 2, color);
    RenderUtils.drawFilledCircle((int) sliderValue, y + 1, 3, color);

    if (mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 3 && Mouse.isButtonDown(0)) {
        double i = MathHelper.clamp_double(((double) mouseX - (double) x) / ((double) width - 3), 0, 1);

        BigDecimal bigDecimal = new BigDecimal(Double.toString((min + (max - min) * i)));
        bigDecimal = bigDecimal.setScale(2, 4);
        return bigDecimal.floatValue();
    }

    return value;
}
 
Example #14
Source Project: GregTech   Author: GregTechCE   File: AdvancedTextWidget.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #15
Source Project: ehacks-pro   Author: radioegor146   File: ShowContainer.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        boolean nowState = Mouse.isButtonDown(1);
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && !prevState && nowState) {
            TileEntity tileEntity = Wrapper.INSTANCE.world().getTileEntity(position.blockX, position.blockY, position.blockZ);
            if (tileEntity instanceof IInventory) {
                ItemStack[] stacks = new ItemStack[0];
                Wrapper.INSTANCE.mc().displayGuiScreen(new ShowContainerGui(new ShowContainerContainer(stacks, tileEntity.getClass().getSimpleName())));
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            } else {
                InteropUtils.log("Not a container", this);
            }
        }
        prevState = nowState;
    } catch (Exception ignored) {

    }
}
 
Example #16
Source Project: Hyperium   Author: HyperiumClient   File: Utils.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
public void setCursor(ResourceLocation cursor) {
    try {
        BufferedImage image = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(cursor).getInputStream());
        int w = image.getWidth();
        int h = image.getHeight();
        int[] pixels = new int[(w * h)];
        image.getRGB(0, 0, w, h, pixels, 0, w);
        ByteBuffer buffer = BufferUtils.createByteBuffer(w * h * 4);

        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                int pixel = pixels[(h - 1 - y) * w + x];
                buffer.put((byte) (pixel & 0xFF));
                buffer.put((byte) (pixel >> 8 & 0xFF));
                buffer.put((byte) (pixel >> 16 & 0xFF));
                buffer.put((byte) (pixel >> 24 & 0xFF));
            }
        }

        buffer.flip();
        Mouse.setNativeCursor(new Cursor(w, h, 0, h - 1, 1, buffer.asIntBuffer(), null));
    } catch (Exception ignored) {
    }
}
 
Example #17
Source Project: ehacks-pro   Author: radioegor146   File: FakeDestroy.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        boolean nowState = Mouse.isButtonDown(0);
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        if (position.sideHit != -1 && !prevState && nowState) {
            removedBlocks.add(new BlockInfo(new int[]{position.blockX, position.blockY, position.blockZ}, Wrapper.INSTANCE.world().getBlock(position.blockX, position.blockY, position.blockZ), Wrapper.INSTANCE.world().getBlockMetadata(position.blockX, position.blockY, position.blockZ)));
            Wrapper.INSTANCE.world().setBlockToAir(position.blockX, position.blockY, position.blockZ);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
        prevState = nowState;
    } catch (Exception ignored) {

    }
}
 
Example #18
Source Project: Hyperium   Author: HyperiumClient   File: GuiScreenEditKeys.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #19
Source Project: slick2d-maven   Author: nguillaumin   File: AppletGameContainer.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
    * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.opengl.ImageData, int, int)
    */
   public void setMouseCursor(ImageData data, int hotSpotX, int hotSpotY) throws SlickException {
      try {
         Cursor cursor = CursorLoader.get().getCursor(data, hotSpotX, hotSpotY);
         Mouse.setNativeCursor(cursor);
      } catch (Throwable e) {
         Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
      }
   }
 
Example #20
Source Project: SkyblockAddons   Author: BiscuitDevelopment   File: ButtonLocation.java    License: MIT License 5 votes vote down vote up
/**
 * This just updates the hovered status and draws the box around each feature. To avoid repetitive code.
 */
public void checkHoveredAndDrawBox(float boxXOne, float boxXTwo, float boxYOne, float boxYTwo, float scale) {
    ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
    float minecraftScale = sr.getScaleFactor();
    float floatMouseX = Mouse.getX() / minecraftScale;
    float floatMouseY = (Minecraft.getMinecraft().displayHeight - Mouse.getY()) / minecraftScale;

    hovered = floatMouseX >= boxXOne * scale && floatMouseY >= boxYOne * scale && floatMouseX < boxXTwo * scale && floatMouseY < boxYTwo * scale;
    int boxAlpha = 70;
    if (hovered) {
        boxAlpha = 120;
    }
    int boxColor = ChatFormatting.GRAY.getColor(boxAlpha).getRGB();
    main.getUtils().drawRect(boxXOne, boxYOne, boxXTwo, boxYTwo, boxColor);

    this.boxXOne = boxXOne;
    this.boxXTwo = boxXTwo;
    this.boxYOne = boxYOne;
    this.boxYTwo = boxYTwo;

    if (this.feature == Feature.DEFENCE_ICON) {
        this.boxXOne *= scale;
        this.boxXTwo *= scale;
        this.boxYOne *= scale;
        this.boxYTwo *= scale;
    }

    this.scale = scale;
}
 
Example #21
Source Project: SkyblockAddons   Author: BiscuitDevelopment   File: ButtonResize.java    License: MIT License 5 votes vote down vote up
@Override
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
    ScaledResolution sr = new ScaledResolution(mc);
    float minecraftScale = sr.getScaleFactor();
    float floatMouseX = Mouse.getX() / minecraftScale;
    float floatMouseY = (mc.displayHeight - Mouse.getY()) / minecraftScale;

    cornerOffsetX = floatMouseX;
    cornerOffsetY = floatMouseY;

    return hovered;
}
 
Example #22
Source Project: OpenModsLib   Author: OpenMods   File: Trackball.java    License: MIT License 5 votes vote down vote up
public void update(int mouseX, int mouseY) {
	float mx = mouseX / radius;
	float my = mouseY / radius;

	boolean buttonState = Mouse.isButtonDown(mouseButton);
	if (!isDragging && buttonState) {
		isDragging = true;
		target.startDrag(mx, my);
	} else if (isDragging && !buttonState) {
		isDragging = false;
		target.endDrag(mx, my);
	}

	target.applyTransform(mx, my, isDragging);
}
 
Example #23
Source Project: Hyperium   Author: HyperiumClient   File: ElementRenderer.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private void renderElements() {
    if (fontRendererObj == null) fontRendererObj = Minecraft.getMinecraft().fontRendererObj;

    // Mouse Button Left
    boolean m = Mouse.isButtonDown(0);
    if (m != last) {
        last = m;
        if (m) clicks.add(System.currentTimeMillis());
    }

    // Mouse Button Right
    boolean rm = Mouse.isButtonDown(1);
    if (rm != rLast) {
        rLast = rm;
        if (rm) rClicks.add(System.currentTimeMillis());
    }

    // Others
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    List<DisplayElement> elementList = mod.getDisplayElements();
    elementList.forEach(element -> {
        startDrawing(element);
        try {
            element.draw();
        } catch (Exception ignored) {
        }
        endDrawing(element);
    });
}
 
Example #24
Source Project: WearableBackpacks   Author: copygirl   File: GuiContainerScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void handleMouseInput() throws IOException {
	super.handleMouseInput();
	
	int mouseX = Mouse.getEventX() * width / mc.displayWidth;
	int mouseY = height - Mouse.getEventY() * height / mc.displayHeight - 1;
	
	int scroll = Integer.signum(Mouse.getEventDWheel());
	if (scroll != 0) container.onMouseScroll(scroll, mouseX, mouseY);
}
 
Example #25
Source Project: The-5zig-Mod   Author: 5zig   File: Gui2ndChat.java    License: MIT License 5 votes vote down vote up
@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
	try {
		return button == 0 && (clickChatComponent != null ? (Boolean) clickChatComponent.invoke(MinecraftFactory.getVars().getMinecraftScreen(),
				getChatComponent(Mouse.getX(), Mouse.getY())) : ((axu) MinecraftFactory.getVars().getMinecraftScreen()).a(getChatComponent(Mouse.getX(), Mouse.getY())));
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
Example #26
Source Project: PneumaticCraft   Author: MineMaarten   File: GuiSearcher.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handles mouse input.
 */
@Override
public void handleMouseInput(){
    super.handleMouseInput();
    int i = Mouse.getEventDWheel();

    if(i != 0 && needsScrollBars()) {
        int j = ((ContainerSearcher)inventorySlots).itemList.size() / 9 - 5 + 1;

        if(i > 0) {
            i = 1;
        }

        if(i < 0) {
            i = -1;
        }

        currentScroll = (float)(currentScroll - (double)i / (double)j);

        if(currentScroll < 0.0F) {
            currentScroll = 0.0F;
        }

        if(currentScroll > 1.0F) {
            currentScroll = 1.0F;
        }

        ((ContainerSearcher)inventorySlots).scrollTo(currentScroll);
    }
}
 
Example #27
Source Project: The-5zig-Mod   Author: 5zig   File: GuiListChat.java    License: MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example #28
Source Project: MikuMikuStudio   Author: chototsu   File: LwjglMouseInput.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setCursorVisible(boolean visible){
    cursorVisible = visible;
    if (!context.isRenderable())
        return;
    
    Mouse.setGrabbed(!visible);
}
 
Example #29
Source Project: The-5zig-Mod   Author: 5zig   File: Gui2ndChat.java    License: MIT License 5 votes vote down vote up
@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
	try {
		return button == 0 && (clickChatComponent != null ? (Boolean) clickChatComponent.invoke(MinecraftFactory.getVars().getMinecraftScreen(),
				getChatComponent(Mouse.getX(), Mouse.getY())) : ((bgr) MinecraftFactory.getVars().getMinecraftScreen()).a(getChatComponent(Mouse.getX(), Mouse.getY())));
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
Example #30
Source Project: ToroQuest   Author: ToroCraft   File: VillageLordGuiContainer.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
		}
	}
}