<commit_before>package mtr.sound.bve;

import mtr.mappings.Utilities;
import mtr.mappings.UtilitiesClient;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
import org.apache.commons.io.IOUtils;

import java.nio.charset.StandardCharsets;
import java.util.List;

public class BveTrainSoundConfig {

	public final String baseName;
	public final String audioBaseName;
	public final ConfigFile soundCfg;
	public final MotorDataBase motorData;

	public BveTrainSoundConfig(ResourceManager manager, String baseName) {
		this.baseName = baseName;
		final String configBaseName = "mtr:sounds/" + baseName;
		audioBaseName = "mtr:" + baseName + "_";
		soundCfg = new ConfigFile(readResource(manager, new ResourceLocation(configBaseName + "/sound.cfg")), this);
		if (soundCfg.motorNoiseDataType == 4) {
			motorData = new MotorData4(manager, configBaseName);
		} else {
			motorData = new MotorData5(manager, configBaseName);
		}
	}

	public static String readResource(ResourceManager manager, ResourceLocation location) {
		try {
			final List<Resource> resources = UtilitiesClient.getResources(manager, location);
			if (resources.size() < 1) {
				return "";
			}
			return IOUtils.toString(Utilities.getInputStream(resources.get(0)), StandardCharsets.UTF_8);
		} catch (Exception e) {
			return "";<commit_msg>Add support for BVE sound from other namespaces<commit_after>package mtr.sound.bve;

import mtr.mappings.Utilities;
import mtr.mappings.UtilitiesClient;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
import org.apache.commons.io.IOUtils;

import java.nio.charset.StandardCharsets;
import java.util.List;

public class BveTrainSoundConfig {

	public final String baseName;
	public final String audioBaseName;
	public final ConfigFile soundCfg;
	public final MotorDataBase motorData;

	public BveTrainSoundConfig(ResourceManager manager, String baseName) {
		ResourceLocation baseLocation = new ResourceLocation(baseName.contains(":") ? baseName : "mtr:" + baseName);

		this.baseName = baseLocation.toString();
		final String configBaseName = baseLocation.getNamespace() + ":sounds/" + baseLocation.getPath();
		audioBaseName = baseLocation.getNamespace() + ":" + baseLocation.getPath() + "_";
		soundCfg = new ConfigFile(readResource(manager, new ResourceLocation(configBaseName + "/sound.cfg")), this);
		if (soundCfg.motorNoiseDataType == 4) {
			motorData = new MotorData4(manager, configBaseName);
		} else {
			motorData = new MotorData5(manager, configBaseName);
		}
	}

	public static String readResource(ResourceManager manager, ResourceLocation location) {
		try {
			final List<Resource> resources = UtilitiesClient.getResources(manager, location);
			if (resources.size() < 1) {
				return "";
			}
			return IOUtils.toString(Utilities.getInputStream(resources.get(0)), StandardCharsets.UTF_8);
		} catch (Exception e) {
			return "";
{'fraction_non_alphanumeric': 0.10548523206751055, 'fraction_numerical': 0.0038948393378773127, 'mean_word_length': 5.585470085470085, 'pattern_counts': {'":': 3, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '934798', 'n_tokens_mistral': 958, 'n_tokens_neox': 903, 'n_words': 205}