Skip to content

Commit

Permalink
fix scenario music
Browse files Browse the repository at this point in the history
  • Loading branch information
khjxiaogu committed Jan 29, 2025
1 parent d76d113 commit bf2fa25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ public static ResourceLocation getPathOf(ResourceLocation orig,String path) {
}
public static <T> Optional<Holder<T>> getPathFrom(IForgeRegistry<T> registry,ResourceLocation orig,String path) {
ResourceLocation rl= new ResourceLocation(orig.getNamespace(),path+ClientUtils.mc().getLanguageManager().getSelected()+"/"+orig.getPath());
System.out.println(rl);
if(registry.containsKey(rl)) {
return registry.getHolder(rl);
}
System.out.println(new ResourceLocation(orig.getNamespace(),path+orig.getPath()));
return registry.getHolder(new ResourceLocation(orig.getNamespace(),path+orig.getPath()));
}
public static void register(Class<?> clazz) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import dev.ftb.mods.ftbquests.quest.task.Task;
import dev.latvian.mods.itemfilters.api.ItemFiltersAPI;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.client.resources.sounds.SoundInstance.Attenuation;
import net.minecraft.nbt.ListTag;
Expand Down Expand Up @@ -284,10 +285,13 @@ public void freeLayer(IClientScene runner,@Param("n")@Param("name")String name)
public void bgm(IClientScene runner,@Param("n")@Param("name")String name) {
//ISound sound=SimpleSound.music();
ClientUtils.mc().getMusicManager().stopPlaying();
FHScenarioClient.getPathFrom(ForgeRegistries.SOUND_EVENTS,new ResourceLocation(name),"")
//ForgeRegistries.SOUND_EVENTS.getKeys().forEach(System.out::println);
/*FHScenarioClient.getPathFrom(ForgeRegistries.SOUND_EVENTS,new ResourceLocation(name),"")
.ifPresentOrElse(t->ClientUtils.mc().getMusicManager().startPlaying(new Music(t, 0, 0, true)), ()->{
FHMain.LOGGER.error("[FHScenario] Music "+name+" Not found");
});
});*/
ClientUtils.mc().getSoundManager().play(SimpleSoundInstance.forMusic(SoundEvent.createVariableRangeEvent(new ResourceLocation(name))));



}
Expand Down

0 comments on commit bf2fa25

Please sign in to comment.