mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 18:46:43 +00:00
Added method to find objects of particular type in a world
This commit is contained in:
parent
80f45f1eb0
commit
be8dd14d36
@ -45,9 +45,7 @@ public class HarvestTask extends NPCTask {
|
|||||||
|
|
||||||
if (pause == 0) {
|
if (pause == 0) {
|
||||||
//Get biomass
|
//Get biomass
|
||||||
/* todo replace by some sort of .collect call with object
|
ArrayList<GameObject> biomass = npc.getWorld().findGameObjects("net.simon987.biomassplugin.BiomassBlob");
|
||||||
id (See https://github.com/simon987/Much-Assembly-Required/pull/66)*/
|
|
||||||
ArrayList<GameObject> biomass = npc.getWorld().findObjects(0x4000);
|
|
||||||
|
|
||||||
//Get closest one
|
//Get closest one
|
||||||
int minDist = Integer.MAX_VALUE;
|
int minDist = Integer.MAX_VALUE;
|
||||||
|
@ -131,6 +131,19 @@ public class World implements MongoSerializable {
|
|||||||
return matchingObjects;
|
return matchingObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<GameObject> findGameObjects(String type) {
|
||||||
|
|
||||||
|
ArrayList<GameObject> matchingObjects = new ArrayList<>(2);
|
||||||
|
|
||||||
|
for (GameObject obj : gameObjects.values()) {
|
||||||
|
if ((obj.getClass().getName().equals(type))) {
|
||||||
|
matchingObjects.add(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchingObjects;
|
||||||
|
}
|
||||||
|
|
||||||
public void addObject(GameObject object) {
|
public void addObject(GameObject object) {
|
||||||
gameObjects.put(object.getObjectId(), object);
|
gameObjects.put(object.getObjectId(), object);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user