Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Drawing GroundItems

Joined
Jan 8, 2015
Messages
1,426
So I came up with the most idiot Saturday evening thought;

Code:
GroundItem runes = GroundItems.newQuery().names("Air rune", "Law rune", "Nature rune").results().nearest();

if (runes != null) {
    String s = runes.getDefinition().getName();
    if (s != null) {
        int x = runes.getModel().getPosition().getX();
        int y = runes.getModel().getPosition().getY();
        g.drawString("" + s, x, y);
    }
}

What would I have to change to make it draw the name on the item. Perhaps drawing a rectangle as well :$
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
7,032
So I came up with the most idiot Saturday evening thought;

Code:
GroundItem runes = GroundItems.newQuery().names("Air rune", "Law rune", "Nature rune").results().nearest();

if (runes != null) {
    String s = runes.getDefinition().getName();
    if (s != null) {
        int x = runes.getModel().getPosition().getX();
        int y = runes.getModel().getPosition().getY();
        g.drawString("" + s, x, y);
    }
}

What would I have to change to make it draw the name on the item. Perhaps drawing a rectangle as well :$
Use getBounds instead of getModel. then just translate it by the appropriate x and y based on the bounds width and height
 
Joined
Jan 8, 2015
Messages
1,426
Use getBounds instead of getModel. then just translate it by the appropriate x and y based on the bounds width and height

I found that runes.getBounds() was not possible for someway. Perhaps because it's a GroundItem?
 
Joined
Jan 8, 2015
Messages
1,426
Oooh derp i was thinking it was an inventory item. Okay so getModel.getBoundingRectangle?

Right, though the GroundItem part should work for that right? And drawing the string name as well should then probably work.
 
Joined
Jan 8, 2015
Messages
1,426
@Aidden it's not too bad ...

240e22a91c.jpg


Any suggestions? :)
 
Top