Jump to content

[Solved] [1.6.4] question custom record sound not playing


Glistre

Recommended Posts

my custom record ..sound is not playing .  this is 1.6.4 but I wanted to update that version.

 

The record seems to work perfect and plays in the jukebox and says it is playing , however the sound is not coming out.

 

I have tried three methods  to pull/play the sound "getRecordResource"  seems to only be a 1.7.10 method not 1.6.4, onSound which does not work I think my setup would be different?  ; and getSoundFile and that seems like it is working but not pulling the sound .  I put my .ogg file in several places ...still not playing

 

Would anyone know what I need to do to make this work and pull the sound?

 

  package glistremod.items;

import glistremod.Main;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.minecraft.block.Block;
import net.minecraft.block.BlockJukeBox;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.client.event.sound.SoundLoadEvent;




public class MusicDisc extends ItemRecord {

private static final Map records = new HashMap();


public final String recordName;


public MusicDisc(int ItemID, String recordName)
{
super(ItemID, recordName);

this.setCreativeTab(CreativeTabs.tabMisc);
this.recordName = recordName;
this.maxStackSize = 1;




records.put(recordName, this);
}


@Override
public void registerIcons(IconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon("glistremod:" + "record_" + recordName);
}


@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
if (world.getBlockId(x, y, z) == Block.jukebox.blockID && world.getBlockMetadata(x, y, z) == 0)
{
if (world.isRemote)
return true;
else
{
((BlockJukeBox)Block.jukebox).insertRecord(world, x, y, z, itemStack);
world.playAuxSFXAtEntity((EntityPlayer)null, 1005, x, y, z, this.itemID);
--itemStack.stackSize;
return true;
}
} 
else
return false;
}


@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add(this.getRecordTitle());
}


@Override
public String getRecordTitle()
{
return StatCollector.translateToLocal(this.getUnlocalizedName() + ".desc");
}


@Override
public EnumRarity getRarity(ItemStack itemStack)
{
return EnumRarity.rare;
}


public static MusicDisc getRecord(String par0Str)
{
return (MusicDisc)records.get(par0Str);
}

public String getSoundFile()
    {
//           return "/assets/glistremod/records/record_Glistre.ogg";
return ("glistremod:" + "record_Glistre.ogg");
    }
}   
/*public void onSound(SoundLoadEvent event)
    {
        try 
        {
            event.manager.soundPoolSounds.addSound("x/record_Glistre.ogg");
//           event.manager.soundPoolSounds.addSound("x/sound2.ogg", mod_ModName.class.getResource("/x/sound2.ogg"));
            
        

    }
}*/

/*
public ResourceLocation getRecordResource(String name)
{
return new ResourceLocation("glistremod:" + name);
}
}*/

Link to comment
Share on other sites

Update to 1.7.10 or 1.8. MC 1.6.4 and older is not supported anymore.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Try to search your Vanilla minecraft folder for any .oggs

Then mark their location, and guess where the .ogg may be placed.

(Usually those files are somewhere in a folder which is very hard to find)

 

Seriously, if you are still on 1.6.4, you'll have to sometimes solve problems by yourself.

Link to comment
Share on other sites

I remember at 1.6.4 you have to register sounds to SoundPoolStreaming, I check my old codes and find something like this but I don't remember clearly how was it works;

 

package net.extend.mod.handler;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import net.extend.mod.ref;
import net.minecraft.client.audio.SoundManager;
import net.minecraftforge.client.event.sound.PlayStreamingEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class SoundLoadHandler {
@SideOnly(Side.CLIENT)
public void onSoundsLoaded(SoundLoadEvent event) {
	SoundManager src = event.manager;
	src.soundPoolStreaming.addSound(ref.uid + ":carol.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":jingle.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":wish.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":birgoruskabininde.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":ahsensiz.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":konewyear.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":numb.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":beautifulmind.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":somebodytoldme.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":kids.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":ghostsnstuff.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":vivalavida.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":applause.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":diamonds.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":moveslikejagger.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":rapgod.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":setfiretorain.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":survival.ogg");
}

@SideOnly(Side.CLIENT)
public void onPlayStreaming(PlayStreamingEvent event) {
	boolean isCont;
	isCont = event.name.contains(ref.uid);
	if (!isCont) {
		FMLClientHandler.instance().getClient().SoundManager.playStreaming(ref.uid + ":" + event.name, event.x + 0.5F, event.y + 0.5F, event.z + 0.5F);
	}
}

}

 

 

Link to comment
Share on other sites

I was not able to get that to work, what is ref.uid?  also the .SoundManager does not allow me to import

 

Thanks for your help though I am just lost.

 

I cannot find any .ogg files in any folders.

 

Seems like my record is registered fine but it either does not call the sound or cannot find it

 

I added this streaming method but does not call it

 public void onSound(SoundLoadEvent event)
     

        {
            event.manager.soundPoolStreaming.addSound("glistremod:records/record_Glistre");
            
    }

 

I do not want to give up yet and move to 1.7.10 until I finish this record thing.  Any help would be appreciated

Link to comment
Share on other sites

I did not have a SoundLoadHandler class.  there is a "SoundLoadEvent" class ...should I have just added your methods from the SoundLoadHandler class like you have to my SoundLoadEvent class?

 

I was not sure so I created a SoundLoadHandler class ...should not it extend another class ?  Here's what mine looks like ...I did not use "ref.uid" have no idea what that is I assumed it denotes your MODID or main class..

 

Anyway this is what I created it does not work/play the record...still says it is playing but no sound...

 

 

package glistremod;


import java.lang.annotation.Retention;
import java.lang.annotation.Target;

//import net.extend.mod.ref;
import net.minecraft.client.audio.SoundManager;
import net.minecraftforge.client.event.sound.PlayStreamingEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import cpw.mods.fml.client.FMLClientHandler;
import net.minecraftforge.event.EventPriority;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class SoundLoadHandler {
@SideOnly(Side.CLIENT)
public void onSoundsLoaded(SoundLoadEvent event) {
	SoundManager src = event.manager;
	src.soundPoolStreaming.addSound("glistremod" + ":Wolf_Howl.ogg");
/*		src.soundPoolStreaming.addSound(ref.uid + ":jingle.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":wish.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":birgoruskabininde.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":ahsensiz.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":konewyear.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":numb.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":beautifulmind.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":somebodytoldme.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":kids.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":ghostsnstuff.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":vivalavida.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":applause.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":diamonds.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":moveslikejagger.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":rapgod.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":setfiretorain.ogg");
	src.soundPoolStreaming.addSound(ref.uid + ":survival.ogg");*/
}

@SideOnly(Side.CLIENT)
public void onPlayStreaming(PlayStreamingEvent event) {
	boolean isCont;
	isCont = event.name.contains("glistre:");
	if (!isCont) {
		FMLClientHandler.instance().getClient().sndManager.playStreaming("glistremod" + ":" + event.name, event.x + 0.5F, event.y + 0.5F, event.z + 0.5F);
	}
}

}

 

Link to comment
Share on other sites

ref.uid is my mod reference.unique ID so it is extend, you need to type your modid there like

yourmodid:blabla.ogg

 

Ok, I found my old codes;

 

Adddisc function;

public class adddisc extends ItemRecord {

public String music;
public adddisc(int uid, String name, String music) {
	super(uid, music);

	this.setMaxStackSize(1);
        this.setCreativeTab(CreativeTabs.tabMisc);
        this.setUnlocalizedName(name);
        this.music = music;
        GameRegistry.registerItem(this, name);
}

@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister reg) {
	this.itemIcon = reg.registerIcon(ref.uid + ":" + (this.getUnlocalizedName().substring(5)));
}
}

 

This leds you to register discs to game.

 

How?:

in Main Class:

	public static Item discWish;

 

inside to PreInit:

		discWish = new adddisc(configref.discWishID, "discwish", "wish");

 

inside to Init;

	    MinecraftForge.EVENT_BUS.register(new SoundLoadHandler());

 

I didn't find anything else about this but it worked for me.

 

Link to comment
Share on other sites

Thank you very much.  . .for taking pity on a poor modder my brain is worn out

 

Could you possibly post your SoundLoadHandler code ...mine is named something else, missing or something...

 

Both your code for creating the record and mine works great, and my song seems to be playing, and no trouble seemingly to register or name the item/record. 

 

Maybe my problem perhaps is with the event:  MinecraftForge.Event_Bus.register (new SoundLoadHandler());

 

Is SoundLoadHandler a class in forge?  I have a class called SoundLoadEvent however when I try to use that I get an error ..

 

I tried using this :

 	@ForgeSubscribe 
public void onSound(SoundLoadEvent event)
     
        {
            event.manager.soundPoolStreaming.addSound("glistremod:wolf_howl");
            
    }

 

and this

@ForgeSubscribe 
public void onSoundLoaded(SoundLoadEvent event)
     

        {
            event.manager.soundPoolStreaming.addSound("glistremod:wolf_howl");
            
    }

 

to call the sound.

 

I am wondering if perhaps there was something wrong with my sounds.json or my record path was wrong but I have tried it one hundred different ways.

 

Thank you for your help.  I think I will see if perhaps there is a tut on the MinecraftForge.Event_Bus.

Link to comment
Share on other sites

Your sound loader should be like this;

 

public class SoundLoadHandler {
@SideOnly(Side.CLIENT)
public void onSoundsLoaded(SoundLoadEvent event) {
	SoundManager src = event.manager;
	src.soundPoolStreaming.addSound("glistremod:wolf_howl.ogg");
}

@SideOnly(Side.CLIENT)
public void onPlayStreaming(PlayStreamingEvent event) {
	boolean isCont;
	isCont = event.name.contains("glistremod");
	if (!isCont) {
		FMLClientHandler.instance().getClient().SoundManager.playStreaming("glistremod:" + event.name, event.x + 0.5F, event.y + 0.5F, event.z + 0.5F);
	}
}
}

 

And your ogg files should be inside the following folder;

Your forge File\mcp\src\minecraft\assets\glistremod\records\

Link to comment
Share on other sites

Thanks for your help I have tried this a hundred different ways, says its playing the record but no sound, I just cannot find the mistake:

 

My sounds.json looks like this it is not in the sounds folder but next to it:  I have tried several variations of the name such as "records/wolf_howl" and several others:

 

{
  "wolf_howl": {
    "category": "record",
    "sounds": [
      {
        "name": "wolf_howl",
        "stream": true
      }
    ]
  }
}

 

My SoundLoadHandler class:

 package glistremod;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import net.minecraft.client.audio.SoundManager;
import net.minecraftforge.client.event.sound.PlayStreamingEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import cpw.mods.fml.client.FMLClientHandler;
import net.minecraftforge.event.EventPriority;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class SoundLoadHandler {
@SideOnly(Side.CLIENT)
public void onSoundsLoaded(SoundLoadEvent event) {
	SoundManager src = event.manager;
	src.soundPoolStreaming.addSound("glistremod:wolf_howl.ogg");

}

@SideOnly(Side.CLIENT)
public void onPlayStreaming(PlayStreamingEvent event) {
	boolean isCont;
	isCont = event.name.contains("glistremod");
	if (!isCont) {
		FMLClientHandler.instance().getClient().sndManager.playStreaming("glistremod:" +  event.name, event.x + 0.5F, event.y + 0.5F, event.z + 0.5F);
	}
}

}

 

My MusicDisc class extends ItemRecord:

package glistremod.items;

import glistremod.Main;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockJukeBox;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.client.event.sound.PlayStreamingEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;




public class MusicDisc extends ItemRecord {

private static final Map records = new HashMap();
public String music;



public MusicDisc (int ItemID, String name, String music)

{
super(ItemID, music);
this.setCreativeTab(CreativeTabs.tabMisc);
this.setUnlocalizedName(name);
this.music = music;
this.setMaxStackSize(1); 
GameRegistry.registerItem(this, name);
}

@SideOnly(Side.CLIENT)

@Override
public void registerIcons(IconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("glistremod:" + this.getUnlocalizedName());
}


@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
if (world.getBlockId(x, y, z) == Block.jukebox.blockID && world.getBlockMetadata(x, y, z) == 0)
{
if (world.isRemote)
return true;
else
{
((BlockJukeBox)Block.jukebox).insertRecord(world, x, y, z, itemStack);
world.playAuxSFXAtEntity((EntityPlayer)null, 1005, x, y, z, this.itemID);
--itemStack.stackSize;
return true;
}
} 
else
return false;
}

    /**
     * allows items to add custom lines of information to the mouseover description
     */
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add(this.getRecordTitle());
}

    /**
     * Return the title for this record.
     */
@Override
public String getRecordTitle()
{
return StatCollector.translateToLocal(this.getUnlocalizedName() + ".desc");

}



@Override
public EnumRarity getRarity(ItemStack itemStack)
{
return EnumRarity.rare;
}

    /**
     * Return the record item corresponding to the given name.
     */
public static MusicDisc getRecord(String music)
{
return (MusicDisc)records.get(music);
}


public ResourceLocation getRecordResource(String name)
{
return new ResourceLocation("glistremod:wolf_howl.ogg");
}


public String getSoundFile()
    {

return ("glistremod:wolf_howl.ogg");
    }

}

 

My main class:

 

before preinit identified:

         public static Item wolf_howl;
        public static int wolf_howlID;

 

in the preinit method registered:

//  LOAD RECORD
//.setUnlocalizedName("wolf_howl").setCreativeTab(MyCreativeTab_1)

        wolf_howl = new MusicDisc(wolf_howlID, "wolf_howl", "wolf_howl");
//        GameRegistry.registerItem(wolf_howl, "wolf_howl");
        LanguageRegistry.addName(wolf_howl, "Wolf Howl");
    	LanguageRegistry.instance().addStringLocalization("item.wolf_howl.desc", "en_US", "Wolf Howl");     

 

and in init :

       MinecraftForge.EVENT_BUS.register(new SoundLoadHandler());

 

My file path is Forge\mcp\src\minecraft\assets\glistremod\records  to the sound file wolf_howl.ogg.

 

I just cannot see why in the world this is not playing a sound ...by any chance do you see any errors

 

or is actually possible to break forge?  Thank you

 

 

Link to comment
Share on other sites

GOT IT ... my last problem was that I need the @ForgeSubscribe annotation over the "events" in the SoundLoadHandler class (because it has two events" that need to be uploaded to the  EVENT_BUS in the registration:  via MinecraftForge.EVENT-BUS.register (new SoundLoadHandler ());

 

 

Wow so happy to get this working this problem should bring back some memories for all those who used to mod 1.6.4  ..this would have been so easy if there was a good tut on this problem out there.

 

LOL now I just have to make it work in 1.8  Thanks for helping xwerswoodx and forum!

 

package glistremod;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import net.minecraft.client.audio.SoundManager;
import net.minecraftforge.client.event.sound.PlayStreamingEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import cpw.mods.fml.client.FMLClientHandler;
import net.minecraftforge.event.EventPriority;
import net.minecraftforge.event.ForgeSubscribe;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class SoundLoadHandler {
@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onSoundsLoaded(SoundLoadEvent event) {
	SoundManager src = event.manager;
	src.soundPoolStreaming.addSound("glistremod:wolf_howl.ogg");
/*		src.soundPoolStreaming.addSound(ref.uid + ":jingle.ogg");
	*/
}
/*	@ForgeSubscribe 
public void onSound(SoundLoadEvent event)
        {
            event.manager.soundPoolStreaming.addSound("glistremod:wolf_howl");         
    }*/

@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onPlayStreaming(PlayStreamingEvent event) {
	boolean isCont;
	isCont = event.name.contains("glistremod");
	if (!isCont) {
		FMLClientHandler.instance().getClient().sndManager.playStreaming("glistremod:" +  event.name, event.x + 0.5F, event.y + 0.5F, event.z + 0.5F);
	}
}
}

 

 

http://minecraftforgetutorials.weebly.com/event-introduction.html

 

"You should notice something over the method header, this is called an Annotation. These essentially allow a method to have extra data assigned to the method, however in this case this annotation is telling Forge that it has to subscribe this method to the Event Bus, which we will be getting to later. You should also notice this method takes an argument, which is required for events. It also allows you to access certain things the event stores, in this case the item that the player picks up.

 

"So we have a class that has the event method within it, however if you try and run the game you will quickly realize that the code is never ran, we have the ForgeSubscribe annotation over the method but we have left out the Event Bus registration, we will now add that! Place this code into any of your init methods in your core mod class:

 

MinecraftForge.EVENT_BUS.register(new ItemPickupHandler());

 

This code registers the event class with the Forge Event Bus, which is a list of all the event handlers that have been registered, which t. . ."

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.



×
×
  • Create New...

Important Information

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