Hi guys, I wanted to add some minimap icons but following tutorials they all told me to add a variable for every icon.. Not gonna happen so I made a way to add it in the easy way.
It's my first release so be gentle
Create a new class called CustomMinimapIcon.java
Add this into the class:
Code:
/**
* CustomMinimapIcon class to make custom minimap icons
*
* @author Beagon
*/
public class CustomMinimapIcon {
private int x, y;
private Sprite sprite;
/**
* Create a new {@link CustomMinimapIcon}.
*
* @param int x
* The X coordinate on the map
* @param int y
* The Y coordinate on the map
* @param Sprite
* The sprite to display
*/
public CustomMinimapIcon(int x, int y, Sprite sprite) {
this.x = x;
this.y = y;
this.sprite = sprite;
}
/**
* Sets the X coordinate.
* @return CustomMinimapIcon
*/
public CustomMinimapIcon setX(int x) {
this.x = x;
return this;
}
/**
* Gets the X coordinate.
* @param int X
* The X coordinate on the map
* @return int
*/
public int getX() {
return this.x;
}
/**
* Sets the Y coordinate.
* @param int y
* The Y coordinate on the map
* @return CustomMinimapIcon
*/
public CustomMinimapIcon setY(int y) {
this.y = y;
return this;
}
/**
* Gets the Y coordinate.
* @return int
*/
public int getY() {
return this.y;
}
/**
* Sets the icon Sprite
* @param Sprite sprite
* The sprite of the icon
* @return CustomMinimapIcon
*/
public CustomMinimapIcon setSprite(Sprite sprite) {
this.sprite = sprite;
return this;
}
/**
* Gets the sprite.
* @return Sprite
*/
public Sprite getSprite() {
return this.sprite;
}
}
Then in Client.java add this variable:
Code:
private ArrayList<CustomMinimapIcon> customMinimapIcons = new ArrayList<CustomMinimapIcon>();
Now find
Code:
markMinimap(currentMapFunctionSprites[j5], k, i3);
After it add:
Code:
for (int iconI = 0; iconI < customMinimapIcons.size(); iconI++) {
markMinimap(customMinimapIcons.get(iconI).getSprite(), ((customMinimapIcons.get(iconI).getX() - baseX) * 4 + 2) - myPlayer.x / 32, ((customMinimapIcons.get(iconI).getY() - baseY) * 4 + 2) - myPlayer.y / 32);
}
Now the last thing to make it work is find:
Code:
mapDotTeam = new Sprite(mediaArchives, "mapdots", 4);
Underneath it add the line you were waiting for:
Code:
customMinimapIcons.add(new CustomMinimapIcon(X, Y, new Sprite(mediaArchive, "mapfunction", SpriteID)));
This adds the icon!
For example:
Code:
customMinimapIcons.add(new CustomMinimapIcon(3215, 3424, new Sprite(mediaArchive, "mapfunction", 5)));
This would add a bank icon to Varrock Square:
You can add as many of those lines as you want underneath each other.
I hope you find any use in this!
Greetings
Beagon