Drawing GroundItems

Discussion in 'Developer Support' started by Geashaw, Feb 21, 2015.

  1. So I came up with the most idiot Saturday evening thought;

    Code (Text):
    1. GroundItem runes = GroundItems.newQuery().names("Air rune", "Law rune", "Nature rune").results().nearest();
    3. if (runes != null) {
    4.     String s = runes.getDefinition().getName();
    5.     if (s != null) {
    6.         int x = runes.getModel().getPosition().getX();
    7.         int y = runes.getModel().getPosition().getY();
    8.         g.drawString("" + s, x, y);
    9.     }
    10. }
    What would I have to change to make it draw the name on the item. Perhaps drawing a rectangle as well :$
  2. Use getBounds instead of getModel. then just translate it by the appropriate x and y based on the bounds width and height
  3. I found that runes.getBounds() was not possible for someway. Perhaps because it's a GroundItem?
  4. Oooh derp i was thinking it was an inventory item. Okay so getModel.getBoundingRectangle?
  5. Right, though the GroundItem part should work for that right? And drawing the string name as well should then probably work.
  6. @Aidden it's not too bad ...


    Any suggestions? :)
  7. getModelBounds should return a renderable rectangular prism,
    possibly reducing text size and centering it?
  8. Decided to only draw item names since those rectangles were really ugly...

  9. Hmmm, the boxes usually don't seem too bad, the rectangles however do look pretty derp

Share This Page