use of net.modificationstation.stationapi.api.resource.RecursiveReader in project StationAPI by ModificationStation.
the class MixinSoundHelper method loadModAudio.
@Environment(EnvType.CLIENT)
private static void loadModAudio(SoundMap array, String channel) {
try {
for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) {
ModMetadata stationMod = modContainer.getMetadata();
Path basePath = Paths.get("/assets/" + stationMod.getId() + "/stationapi/sounds/" + channel);
if (MixinSoundHelper.class.getResource(basePath.toString().replace("\\", "/")) != null) {
RecursiveReader recursiveReader = new RecursiveReader("/assets/" + stationMod.getId() + "/stationapi/sounds/" + channel, (filepath) -> filepath.endsWith(".ogg") || filepath.endsWith(".mp3") || filepath.endsWith(".wav"));
for (URL audioUrl : recursiveReader.read()) {
String audioID = audioUrl.toString().replace("\\", "/").split("/stationapi/sounds/" + channel)[1].replaceFirst("/", "");
((CustomSoundMap) array).putSound(stationMod.getId() + ":" + audioID, audioUrl);
}
}
}
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
Aggregations