Jump to content

Music Discs Adding Music to the disc.


phase

Recommended Posts

Hey there!

 

I was wondering how to add music to a music disc.

I already have the disc made and it works fine in-game.

When I put it in the Jukebox, it just doesn't play music.

 

Code:

 

 

 

My "ItemRecord" File that I made to add some custom things.

package certus.phase.com.music;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import certus.phase.com.Certus;
import net.minecraft.block.Block;
import net.minecraft.block.BlockJukeBox;
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.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;

public class EthericRecord extends Item
{

    /** List of all record items and their names. */
    private static final Map records = new HashMap();

    /** The name of the record. */
    public final String recordName;
    
    /** The Author of the record.*/
    public final String authorName;


    public EthericRecord(int id, String songTitle, String songAuthor)
    {
        super(id);
        this.recordName = songTitle;
        this.authorName = songAuthor;
        this.maxStackSize = 1;
        this.setCreativeTab(Certus.nirtosTab);
        records.put(songTitle, this);
    }

    @SideOnly(Side.CLIENT)

    /**
     * Gets an icon index based on an item's damage value
     */
    public Icon getIconFromDamage(int par1)
    {
        return this.itemIcon;
    }

    /**
     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
     */
    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    {
        if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)
        {
            if (par3World.isRemote)
            {
                return true;
            }
            else
            {
                ((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack);
                par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID);
                --par1ItemStack.stackSize;
                return true;
            }
        }
        else
        {
            return false;
        }
    }

    @SideOnly(Side.CLIENT)

    /**
     * allows items to add custom lines of information to the mouseover description
     */
    public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
    {
	par3List.add("~Etheric Mod Record~");
	par3List.add("Artist: " + this.getRecordAuthor());  
        par3List.add("Song: " + this.getRecordTitle());
        
    }

    @SideOnly(Side.CLIENT)

    /**
     * Return the title for this record.
     */
    public String getRecordTitle()
    {
        return this.recordName;
    }
    
    
    @SideOnly(Side.CLIENT)

    /**
     * Return the title for this record.
     */
    public String getRecordAuthor()
    {
        return this.authorName;
    }

    @SideOnly(Side.CLIENT)

    /**
     * Return an item rarity from EnumRarity
     */
    public EnumRarity getRarity(ItemStack par1ItemStack)
    {
        return EnumRarity.rare;
    }

    @SideOnly(Side.CLIENT)

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

 

 

 

 

 

The Disc File

package certus.phase.com.nirtos;

import java.util.List;

import certus.phase.com.Certus;
import certus.phase.com.Info;
import certus.phase.com.music.EthericRecord;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;

public class NirtosDisc extends EthericRecord {

public NirtosDisc(int id, String songTitle, String songAuthor) {
super(id, songTitle, songAuthor);
setCreativeTab(Certus.nirtosTab);
setUnlocalizedName("NirtosDisc");
func_111206_d(Info.TEX.toLowerCase() + ":" + "Nirtos_Disc");
         }

}

 

 

 

And yes, I've tried this:

[lmgtfy]minecraft forge music disc 1.6.2[/lmgtfy]

 

Link to comment
Share on other sites

I had the same issue till yesterday,solution is pretty simple.

 

Go in your Main Class and add this :

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
MinecraftForge.EVENT_BUS.register(new SoundLoader());
MinecraftForge.EVENT_BUS.register(this);
}

 

This tell the game to Load the SoundLoader class while in PreInit phase.

 

Then create the SoundLoader.class and paste this code :

package DubGun;

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

public class EventSounds {

@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onSoundsLoaded(SoundLoadEvent event)
{

SoundManager manager = event.manager;

manager.soundPoolStreaming.addSound("<your mod name lowercased>:unlocalizedname.ogg");

}
}

Your record music file must be in /assets/modname_lowercased/records

It must be a .ogg file.

 

In the main class,in 'setUnlocalizedName' set a name.

Then go in /assets/modname_lowercased/records and rename your .ogg file THE SAME AS THE UNLOCALIZED NAME.

(If my unlocalizedname is 'dumbexample' the .ogg file's name MUST be dumbexample.ogg)

 

Then go in the SoundLoader class

In <your mod name lowercased> write the same as the folder the folder records is in. (Records is in mac_dumbexample, then write mac_dumbexample)

In unlocalizedname write the same unlocalizedname you used for your record then add .ogg at the end.

 

 

 

Link to comment
Share on other sites

URG!!! I can't seem to get it to work... :P

 

public class SoundLoader {

@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onSoundsLoaded(SoundLoadEvent event)
{

SoundManager manager = event.manager;

manager.soundPoolStreaming.addSound(Info.TEX + ":NirtosDisc.ogg");
manager.soundPoolStreaming.addSound(Info.TEX + ":DiscVechs.ogg");
manager.soundPoolStreaming.addSound(Info.TEX + ":DiscBTeam.ogg");

}
}

 

that is my SoundLoader

 

 

public class NirtosDisc extends ItemRecord {

public NirtosDisc(int id, String songTitle, String songAuthor) {
super(id, songTitle);
setCreativeTab(Certus.nirtosTab);
setUnlocalizedName("NirtosDisc");
func_111206_d(Info.TEX.toLowerCase() + ":" + "Nirtos_Disc");
         }
public class SoundManager {
	   @SideOnly(Side.CLIENT)
       @ForgeSubscribe
    public void onSoundsLoaded(SoundLoadEvent event)
    {
        net.minecraft.client.audio.SoundManager manager = event.manager;
             manager.soundPoolStreaming.addSound(Info.TEX + ":test");
            }
    }



}

that is my disc.

 

 

 

When I put the disc in the jukebox, it just doesn't play any sound.

 

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



×
×
  • Create New...

Important Information

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