mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-10 14:26:45 +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) {
|
||||
//Get biomass
|
||||
/* todo replace by some sort of .collect call with object
|
||||
id (See https://github.com/simon987/Much-Assembly-Required/pull/66)*/
|
||||
ArrayList<GameObject> biomass = npc.getWorld().findObjects(0x4000);
|
||||
ArrayList<GameObject> biomass = npc.getWorld().findGameObjects("net.simon987.biomassplugin.BiomassBlob");
|
||||
|
||||
//Get closest one
|
||||
int minDist = Integer.MAX_VALUE;
|
||||
|
@ -131,6 +131,19 @@ public class World implements MongoSerializable {
|
||||
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) {
|
||||
gameObjects.put(object.getObjectId(), object);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user