Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to use ISoundHandler?


Recommended Posts

I am trying to get my mod to register sound with it but I keep getting error to the console:



C:\Users\****\Desktop\MCPs\mcp62_forge_updated\jars\mods\Psientic\psi\fx\swoosh.ogg true

Error in class 'LibraryLWJGLOpenAL'

    No codec found for file 'swoosh.1' in method 'loadSound'

Error in class 'LibraryLWJGLOpenAL'

    Source 'sound_1' was not created because an error occurred while loading swoosh.1

Error in class 'LibraryLWJGLOpenAL'

    Source 'sound_1' not found in method 'play'



And as you can see from my code:



package net.minecraft.src.psientic.mods.data;

import java.io.File;
import java.net.URL;

import net.minecraft.src.SoundManager;
import net.minecraft.src.mod_psientic;
import net.minecraft.src.forge.adaptors.SoundHandlerAdaptor;

public class CaveshroomSoundHandler extends SoundHandlerAdaptor{
public void onSetupAudio(SoundManager soundManager){


public void onLoadSoundSettings(SoundManager soundManager){
	URL resource = mod_psientic.getInstance().getClass().getResource("swoosh.ogg");
	File file = new File("C:/Users/****/Desktop/MCPs/mcp62_forge_updated/jars/mods/Psientic/psi/fx/swoosh.ogg");
	System.out.println(file + " " + file.exists());
	soundManager.addSound("swoosh.1", file);
	soundManager.playSound("swoosh", 0, 0, 0, 1.0F, 1.0F);



the file is in .ogg format which should be supported so I have no idea why it says that there is no codec for that.


Here is the sound effect I tried to get to play.


I know that it isn't wise to use absolute path for that file but it's just for testing purposes as I weren't able to find correct relative one. I will try to make that happen after ensuring it actually plays it.


Link to comment
Share on other sites

because you're telling it that the file name is 'swoosh.1'

'1' is a unknown codec, hence the error.

:o;D Such a noob mistake.. I assumed that what comes after that dot is secondary "category" as in other sounds added to soundPoolSounds (First thing I did was to print what that contained and tried to copy that).


Anyway thanks for helping... I will try to it.


Edit: And it works! This topic can be locked now.

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.

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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Got the rotation working. I had to look at LivingEntityRenderer#render and setupRotations a little more closely, and I realized that I needed to change the custom entity's yBodyRot and yBodyRotO.  private static boolean renderingCustomEntity = false; private static CustomEntity customEntity; private static void refreshCustomEntity(LocalPlayer localPlayer, LivingEntity livingEntity) { if (customEntity == null || customEntity.isRemoved()) { customEntity = ModEntities.CUSTOM_ENTITY.get().create(localPlayer.clientLevel); } if (!customEntity.level.dimension().equals(livingEntity.level.dimension())) { customEntity.discard(); } } @SubscribeEvent public static void replaceMobModel(RenderLivingEvent.Pre<LivingEntity, EntityModel<LivingEntity>> event) { LocalPlayer localPlayer = Minecraft.getInstance().player; if (localPlayer != null && event.getEntity() instanceof Mob mob) { if (/* put your own condition here */) { if (!renderingCustomEntity) { try { renderingCustomEntity = true; event.setCanceled(true); refreshCustomEntity(localPlayer, mob); // (truth be told, my custom entity does not have a "head", so these lines aren't needed) // customEntity.setYHeadRot(mob.getYHeadRot()); // customEntity.yHeadRotO = mob.yHeadRotO; customEntity.setYBodyRot(mob.yBodyRot); customEntity.yBodyRotO = mob.yBodyRotO; customEntity.setPose(mob.getPose()); Minecraft.getInstance().getEntityRenderDispatcher().getRenderer(customEntity).render( customEntity, customEntity.yBodyRot, event.getPartialTick(), event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight() ); } finally { renderingCustomEntity = false; } } } } }   As shown in my code, if the mob whose model is replaced moves to a different dimension, I unload the custom entity with Entity#discard and then reinitialize it on the next tick. I wonder if I also have to unload the custom entity when the mob it is "replacing" dies.
    • Thank you for the video, but I found the issue. I had to update the Gradle from 7.2 to 7.3 in gradle/wrapper/gradle-wrapper.properties.
    • Some zip managers like to take control of the .jar file extension away from Java. Make sure you have Java installed and try running Jarfix once, then try the installer again.
    • Whenever i try and download forge specifically 1.18.2 it will download as a JAR file as a note page and theirs no way to install it i have watched a few videos but none show how to fix this problem
    • Hello, I dont really understand why the nbt tag in the code below is not attached to the item. @Override public InteractionResult interactLivingEntity(ItemStack pStack, Player pPlayer, LivingEntity pInteractionTarget, InteractionHand pUsedHand) { if (pPlayer.getLevel().isClientSide()) { if (pInteractionTarget instanceof Mob mob) { System.out.println("ITEMSTACK " + pStack); CompoundTag nbtTag = null; System.out.println("nbt tag " + nbtTag); if (!(pStack.hasTag())) { nbtTag = new CompoundTag(); CompoundTag nbtMobTag = new CompoundTag(); mob.save(nbtMobTag); nbtTag.put("mob", nbtMobTag); System.out.println("IN NBT NULL " + nbtTag); pStack.setTag(nbtTag); System.out.println("AFTER TAG SET " + pStack.hasTag()); pPlayer.sendMessage(new TextComponent("Shard used on " + mob.getDisplayName().getString()), pPlayer.getUUID()); } else { nbtTag = pStack.getTag(); System.out.println("item has tag"); System.out.println(nbtTag.contains("mob")); } } } return InteractionResult.PASS; } @Override public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltipComponents, TooltipFlag pIsAdvanced) { CompoundTag nbtTag = pStack.getTag(); if (nbtTag != null) { if (nbtTag.contains("mob")) { Mob targetMob = null; targetMob.deserializeNBT(nbtTag.getCompound("mob")); pTooltipComponents.add(new TextComponent("Mob : " + targetMob.getDisplayName().getString())); } } } Everytime I right click with the Item on a LivingEntity, It goes on the if(!pStack.hasTag()), but It shouldn't because we set the tag on the first right click on an Entity   Do you have a solution ?
  • Topics

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.