- 48
- 1
- 4
Спавню моба, ему добавляю compoundNBT, в котором строка с рандомным HashCode
Теперь мне нужно найти количество этих Entity в мире с таким же хешем в compound.
Есть идеи, как?
Пробовал:
Но на Minecraft.getInstance().world.getAllEntities(); ловится null
Теперь мне нужно найти количество этих Entity в мире с таким же хешем в compound.
Есть идеи, как?
Пробовал:
Java:
public int getCountEntities() {
int count = 0;
assert Minecraft.getInstance().world != null;
Iterable<Entity> iterator = Minecraft.getInstance().world.getAllEntities();
for (Entity ent : iterator) {
if (ent instanceof MonsterEntity) {
CompoundNBT compoundNBT = new CompoundNBT();
ent.read(compoundNBT);
if (compoundNBT.contains("hashSpawnCode")) {
String hashCodeEntity = compoundNBT.getString("hashSpawnCode");
if (hashCodeEntity.equals(hashCode)) {
count++;
}
}
}
}
return count;
}