Posted April 5, 201411 yr Is there anyway of knowing which slot the player is currently mousing over? Also, what side would I be checking on? (Server or client) Kain
April 6, 201411 yr Hi Yes there is. Look in GuiContainer.drawScreen for inspiration, in particular this bit for (int j1 = 0; j1 < this.inventorySlots.inventorySlots.size(); ++j1) { Slot slot = (Slot)this.inventorySlots.inventorySlots.get(j1); this.drawSlotInventory(slot); if (this.isMouseOverSlot(slot, par1, par2) && slot.func_111238_b()) { this.theSlot = slot; GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); int k1 = slot.xDisplayPosition; i1 = slot.yDisplayPosition; this.drawGradientRect(k1, i1, k1 + 16, i1 + 16, -2130706433, -2130706433); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); } } par1, par2 are mouseXpos and mouseYpos, which you can get from int k = Mouse.getX() * i / this.mc.displayWidth; int l = j - Mouse.getY() * j / this.mc.displayHeight - 1; (this.mc is Minecraft). inventorySlots has public access. Need to check mc.currentScreen is actually the inventory container, of course. You will need to do it on client because none of this exists on the server. -TGG
April 6, 201411 yr Author One small question, what do I plugin for i and j when finding the mouse's position? int k = Mouse.getX() * i / this.mc.displayWidth; int l = j - Mouse.getY() * j / this.mc.displayHeight - 1; Kain
April 6, 201411 yr Hi Ah, yeah, I should have copied that too (from EntityRenderer.updateCameraAndRender) ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); int i = scaledresolution.getScaledWidth(); int j = scaledresolution.getScaledHeight(); int k = Mouse.getX() * i / this.mc.displayWidth; int l = j - Mouse.getY() * j / this.mc.displayHeight - 1; -TGG
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.