Jump to content

[1.6.4] Loading sounds


m_pro_m

Recommended Posts

Hello,

 

i am trying to load my custom sounds using this code:

@ForgeSubscribe
    public void onSound(SoundLoadEvent event)
    {
	try 
	{
		event.manager.addSound("randmusic:song1.ogg");
		System.out.println("[Random Music] Songs loaded !");
	} 
	catch (Exception e)
	{
	    System.out.println("[Random Music] Error loading music files ");
	}
    }

It's working fine, but I will have more and more songs in my mod's assets folder. And I don't want to update my code everytime I add a song.

So I need to get a count of files in the mod.zip (assets/sound/...). Is it event possible or will I have to update it everytime in code ?

I am talking about

event.manager.addSound("randmusic:song1.ogg");

Link to comment
Share on other sites

I'd suggest creating a song registry (if there is not already one, that is). Use the 'ZipFiles' enumeration ability to find all your songs and add them all at once.

 

Then, pick a random number: Random.nextInt(myRegister.length()) to decide which one to play.

 

Study the code in net.minecraft.client.resources.FileResourcePack as an idea what you can implement.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • [13abr.2024 23:04:08.876] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, thehappiestdeus, --version, 1.20.1-forge-47.2.23, --gameDir, C:\Users\********\AppData\Roaming\.minecraft, --assetsDir, C:\Users\********\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 6947100bd693327a9d73af48e609bc8e, --accessToken, ????????, --clientId, 0, --xuid, 0, --userType, msa, --versionType, release, --width, 854, --height, 480, --launchTarget, forgeclient, --fml.forgeVersion, 47.2.23, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] [13abr.2024 23:04:08.900] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.9 10.0.9 main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 11 arch amd64 version 10.0 [13abr.2024 23:04:12.324] [main/INFO] [net.minecraftforge.fml.loading.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow [13abr.2024 23:04:12.626] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 [13abr.2024 23:04:15.807] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 [13abr.2024 23:04:16.706] [pool-4-thread-1/INFO] [EARLYDISPLAY/]: GL info: NVIDIA GeForce GTX 1050/PCIe/SSE2 GL version 4.6.0 NVIDIA 551.61, NVIDIA Corporation [13abr.2024 23:04:18.403] [main/WARN] [gg.essential.loader.stage1.EssentialLoaderBase/]: Found newer Essential Loader (stage2) version 1.6.0 [stable], skipping at user request [13abr.2024 23:04:18.405] [main/INFO] [gg.essential.loader.stage1.EssentialLoaderBase/]: Starting Essential Loader (stage2) version 1.4.1 (4b3b87be87d34916028dffa85460d085) [stable] [13abr.2024 23:04:18.631] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/********/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar#100!/ Service=ModLauncher Env=CLIENT [13abr.2024 23:04:18.982] [main/WARN] [gg.essential.loader.stage2.EssentialLoaderBase/]: Found newer Essential version 1.3.1.3 [stable], skipping at user request [13abr.2024 23:04:20.965] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.20.1-47.2.23\fmlcore-1.20.1-47.2.23.jar is missing mods.toml file [13abr.2024 23:04:20.974] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.20.1-47.2.23\javafmllanguage-1.20.1-47.2.23.jar is missing mods.toml file [13abr.2024 23:04:20.981] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.20.1-47.2.23\lowcodelanguage-1.20.1-47.2.23.jar is missing mods.toml file [13abr.2024 23:04:20.991] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.20.1-47.2.23\mclanguage-1.20.1-47.2.23.jar is missing mods.toml file [13abr.2024 23:04:22.047] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select two dependency jars from JarJar which have the same identification: Mod File: and Mod File: . Using Mod File: [13abr.2024 23:04:22.056] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: curios. Using Mod File: C:\Users\********\AppData\Roaming\.minecraft\mods\curios-forge-5.7.2 1.20.1.jar [13abr.2024 23:04:22.056] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: resourcefullib. Using Mod File: C:\Users\********\AppData\Roaming\.minecraft\mods\resourcefullib-forge-1.20.1-2.1.24.jar [13abr.2024 23:04:22.058] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 22 dependencies adding them to mods collection [13abr.2024 23:04:31.937] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [13abr.2024 23:04:31.989] [main/ERROR] [mixin/]: Mixin config firstperson.mixins.json does not specify "minVersion" property [13abr.2024 23:04:32.169] [main/ERROR] [mixin/]: Mixin config entity_model_features.mixins.json does not specify "minVersion" property [13abr.2024 23:04:33.081] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [com.sonicether.soundphysics.MixinConnector] [13abr.2024 23:04:33.089] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.20.1-forge-47.2.23, --gameDir, C:\Users\********\AppData\Roaming\.minecraft, --assetsDir, C:\Users\********\AppData\Roaming\.minecraft\assets, --uuid, 6947100bd693327a9d73af48e609bc8e, --username, thehappiestdeus, --assetIndex, 5, --accessToken, ????????, --clientId, 0, --xuid, 0, --userType, msa, --versionType, release, --width, 854, --height, 480] [13abr.2024 23:04:33.497] [main/INFO] [ModernFix/]: Loaded configuration file for ModernFix 5.15.0 mc1.20.1: 77 options available, 0 override(s) found [13abr.2024 23:04:33.500] [main/INFO] [ModernFix/]: Applying Nashorn fix [13abr.2024 23:04:33.544] [main/INFO] [ModernFix/]: Applied Forge config corruption patch [13abr.2024 23:04:33.869] [main/INFO] [Embeddium/]: Loaded configuration file for Embeddium: 172 options available, 3 override(s) found [13abr.2024 23:04:33.873] [main/INFO] [Embeddium-GraphicsAdapterProbe/]: Searching for graphics cards... [13abr.2024 23:04:34.631] [main/INFO] [Embeddium-GraphicsAdapterProbe/]: Found graphics card: GraphicsAdapterInfo[vendor=NVIDIA, name=NVIDIA GeForce GTX 1050, version=DriverVersion=31.0.15.5161] [13abr.2024 23:04:34.632] [main/INFO] [Embeddium-GraphicsAdapterProbe/]: Found graphics card: GraphicsAdapterInfo[vendor=INTEL, name=Intel(R) UHD Graphics 630, version=DriverVersion=31.0.101.2111] [13abr.2024 23:04:34.644] [main/WARN] [Embeddium-Workarounds/]: Sodium has applied one or more workarounds to prevent crashes or other issues on your system: [NVIDIA_THREADED_OPTIMIZATIONS] [13abr.2024 23:04:34.645] [main/WARN] [Embeddium-Workarounds/]: This is not necessarily an issue, but it may result in certain features or optimizations being disabled. You can sometimes fix these issues by upgrading your graphics driver. [13abr.2024 23:04:34.668] [main/WARN] [mixin/]: Reference map 'entity_model_features_forge_1.20.1-forge-refmap.json' for entity_model_features.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:34.868] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:34.879] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras_forge.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.002] [main/WARN] [mixin/]: Reference map 'nitrogen_internals.refmap.json' for nitrogen_internals.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.135] [main/INFO] [Radium Config/]: Loaded configuration file for Radium: 125 options available, 1 override(s) found [13abr.2024 23:04:35.152] [main/WARN] [mixin/]: Reference map 'trashslot.refmap.json' for trashslot.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.360] [main/WARN] [mixin/]: Reference map '${refmap_target}refmap.json' for corgilib.forge.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.404] [main/WARN] [mixin/]: Reference map 'coroutil.refmap.json' for coroutil.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.599] [main/WARN] [mixin/]: Reference map 'chiselsandbits.refmap.json' for chisels-and-bits.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.634] [main/WARN] [mixin/]: Reference map 'cristellib-forge-refmap.json' for cristellib.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.822] [main/INFO] [Essential Logger - Plugin/]: Starting Essential v1.3.1.1 (#3a090c5c88) [stable] [13abr.2024 23:04:40.482] [main/WARN] [mixin/]: Error loading class: dev/tr7zw/skinlayers/render/CustomizableModelPart (java.lang.ClassNotFoundException: dev.tr7zw.skinlayers.render.CustomizableModelPart) [13abr.2024 23:04:42.465] [main/WARN] [Radium Config/]: Force-disabling mixin 'alloc.blockstate.StateMixin' as option 'mixin.alloc.blockstate' (added by mods [ferritecore]) disables it and children [13abr.2024 23:04:43.118] [main/WARN] [mixin/]: Error loading class: vectorwing/farmersdelight/client/renderer/HangingCanvasSignRenderer (java.lang.ClassNotFoundException: vectorwing.farmersdelight.client.renderer.HangingCanvasSignRenderer) [13abr.2024 23:04:43.129] [main/WARN] [mixin/]: Error loading class: vectorwing/farmersdelight/client/renderer/CanvasSignRenderer (java.lang.ClassNotFoundException: vectorwing.farmersdelight.client.renderer.CanvasSignRenderer) [13abr.2024 23:04:45.276] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.world.sky.WorldRendererMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.277] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.world.sky.ClientWorldMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.278] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.world.sky.BackgroundRendererMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.285] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.gui.font.GlyphRendererMixin' as rule 'mixin.features.render.gui.font' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.285] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.gui.font.FontSetMixin' as rule 'mixin.features.render.gui.font' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.286] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.shadows.EntityRenderDispatcherMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.286] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.fast_render.ModelPartMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.288] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.fast_render.CuboidMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.291] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.cull.EntityRendererMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [13abr.2024 23:04:46.387] [main/INFO] [MixinExtras|Service/]: Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.3.5). [13abr.2024 23:04:51.658] [pool-6-thread-1/INFO] [net.minecraft.server.Bootstrap/]: ModernFix reached bootstrap stage (53.35 s after launch) [13abr.2024 23:04:52.021] [pool-6-thread-1/WARN] [mixin/]: @Final field delegatesByName:Ljava/util/Map; in modernfix-forge.mixins.json:perf.forge_registry_alloc.ForgeRegistryMixin should be final [13abr.2024 23:04:52.023] [pool-6-thread-1/WARN] [mixin/]: @Final field delegatesByValue:Ljava/util/Map; in modernfix-forge.mixins.json:perf.forge_registry_alloc.ForgeRegistryMixin should be final [13abr.2024 23:04:52.518] [pool-6-thread-1/INFO] [ModernFix/]: Injecting BlockStateBase cache population hook into getNeighborPathNodeType from me.jellysquid.mods.lithium.mixin.ai.pathing.AbstractBlockStateMixin [13abr.2024 23:04:52.519] [pool-6-thread-1/INFO] [ModernFix/]: Injecting BlockStateBase cache population hook into getPathNodeType from me.jellysquid.mods.lithium.mixin.ai.pathing.AbstractBlockStateMixin [13abr.2024 23:04:52.520] [pool-6-thread-1/INFO] [ModernFix/]: Injecting BlockStateBase cache population hook into getAllFlags from me.jellysquid.mods.lithium.mixin.util.block_tracking.AbstractBlockStateMixin [13abr.2024 23:04:57.799] [pool-6-thread-1/INFO] [net.minecraft.server.Bootstrap/]: Vanilla bootstrap took 6125 milliseconds  
    • k i opened rit and luanched. no matter what launcher i use, it always says 2 mods loaded, but it has 0 mdos loaded. i tried several times with multiMC
    • i downloaded it. what do i do next? how do i open the luancher
    • It happened suddenly to me and a friend and we don't know how to fix it Blocks like the lava, the "UGH" sound, the door sound, etc.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.