public void readFromNbt(NbtCompound tag) { foreach (NbtCompound compound in tag) { string compoundName = compound.Name; // Find the matching stat IStatistic stat = null; foreach (RegisteredStat regStat in this.registeredStats) { if (regStat != null && regStat.stat.saveName == compoundName) { stat = regStat.stat; } } if (stat != null) { stat.readFromNbt(compound); } } }