Paradox68 Posted October 14, 2015 Share Posted October 14, 2015 How would you get the x and y coordinates on the screen of the inventory item? It's probably super simple I just can't figure it out. Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted October 14, 2015 Share Posted October 14, 2015 InventorySlotDestination.getSlot(inventory.getSlot(item)) returns a rectangle Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted October 14, 2015 Share Posted October 14, 2015 (edited) There is no native support in the Item class, or even ItemContainer for that matter. You (sadly) need to make an inventory destination and get the rectangle through there. EDIT: For bank, you can get it like so: public Rectangle getRectForItem(Item i) { int slot = getBank().getSlot(i); int tab = getBank().getTabForAbsoluteSlot(slot); return getBank().getAbsoluteSlotPosition(tab, slot); } Edited October 14, 2015 by Bobrocket Quote Link to comment Share on other sites More sharing options...
Paradox68 Posted October 14, 2015 Author Share Posted October 14, 2015 InventorySlotDestination.getSlot(inventory.getSlot(item)) returns a rectangle That makes it super simple. Thanks dude! There is no native support in the Item class, or even ItemContainer for that matter. You (sadly) need to make an inventory destination and get the rectangle through there. Thank you for the information...... Quote Link to comment Share on other sites More sharing options...
Apaec Posted October 14, 2015 Share Posted October 14, 2015 Unfortunately from the current api it seems you can only draw the first slot as mousedestination returns the first item in the inventory (L->R,T->B) But in order not to overlap the number, you can do something like: g.drawRect( (int) this.inventory .getMouseDestination( this.inventory.getSlot(item)) .getBoundingBox().getX() - 1, (int) this.inventory .getMouseDestination( this.inventory.getSlot(item)) .getBoundingBox().getY() - 1, (int) this.inventory .getMouseDestination( this.inventory.getSlot(item)) .getBoundingBox().getWidth() + 2, (int) this.inventory .getMouseDestination( this.inventory.getSlot(item)) .getBoundingBox().getHeight() + 2); where the additions correct the rectangle dimensions apa Quote Link to comment Share on other sites More sharing options...
Paradox68 Posted October 14, 2015 Author Share Posted October 14, 2015 Unfortunately from the current api it seems you can only draw the first slot as mousedestination returns the first item in the inventory (L->R,T-> But in order not to overlap the number, you can do something like: g.drawRect( (int) this.inventory .getMouseDestination( this.inventory.getSlot(item)) .getBoundingBox().getX() - 1, (int) this.inventory .getMouseDestination( this.inventory.getSlot(item)) .getBoundingBox().getY() - 1, (int) this.inventory .getMouseDestination( this.inventory.getSlot(item)) .getBoundingBox().getWidth() + 2, (int) this.inventory .getMouseDestination( this.inventory.getSlot(item)) .getBoundingBox().getHeight() + 2); where the additions correct the rectangle dimensions apa Actually this is the method i went with: if (getInventory().contains(other)) { Rectangle rec = new Rectangle(InventorySlotDestination.getSlot(inventory.getSlot(other))); g.setColor(Color.ORANGE); g.draw(rec); } Quote Link to comment Share on other sites More sharing options...
Apaec Posted October 14, 2015 Share Posted October 14, 2015 Actually this is the method i went with: if (getInventory().contains(other)) { Rectangle rec = new Rectangle(InventorySlotDestination.getSlot(inventory.getSlot(other))); g.setColor(Color.ORANGE); g.draw(rec); } That will work just fine too however the rect may overlap with the stack size should the item be stackable apa Quote Link to comment Share on other sites More sharing options...
Paradox68 Posted October 14, 2015 Author Share Posted October 14, 2015 There is no native support in the Item class, or even ItemContainer for that matter. You (sadly) need to make an inventory destination and get the rectangle through there. EDIT: For bank, you can get it like so: public Rectangle getRectForItem(Item i) { int slot = getBank().getSlot(i); int tab = getBank().getTabForAbsoluteSlot(slot); return getBank().getAbsoluteSlotPosition(tab, slot); } This method isn't working for drawing in bank. Not sure why, it seems logical but it just wont draw the rect in the right spot. It's drawing it on a completely different item. Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted October 14, 2015 Share Posted October 14, 2015 This method isn't working for drawing in bank. Not sure why, it seems logical but it just wont draw the rect in the right spot. It's drawing it on a completely different item. The bank API might not have been updated recently then, no clue lmao Quote Link to comment Share on other sites More sharing options...
Paradox68 Posted October 14, 2015 Author Share Posted October 14, 2015 The bank API might not have been updated recently then, no clue lmao Just to be sure i'm not crazy, proper usage could be if (getBank().isOpen()) { g.draw(getRectForItem(getBank().getItem(toMake2)); } assuming toMake2 returns an int or a string. Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted October 14, 2015 Share Posted October 14, 2015 Just to be sure i'm not crazy, proper usage could be if (getBank().isOpen()) { g.draw(getRectForItem(getBank().getItem(toMake2)); } assuming toMake2 returns an int or a string. g.draw(new BankSlotDestination(bot, bank.getSlot(ITEM_ID_OR_SOMETHING)).getBoundingBox()); Quote Link to comment Share on other sites More sharing options...
FrostBug Posted October 14, 2015 Share Posted October 14, 2015 (edited) EDIT: nvm, Flamezzz posted it Edited October 14, 2015 by FrostBug Quote Link to comment Share on other sites More sharing options...
Paradox68 Posted October 14, 2015 Author Share Posted October 14, 2015 g.draw(new BankSlotDestination(bot, bank.getSlot(ITEM_ID_OR_SOMETHING)).getBoundingBox()); Hngh dat coding. You're a smart cookie. Thanks dude. Quote Link to comment Share on other sites More sharing options...