Jump to content

Recommended Posts

Posted

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]

 

Posted

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.

 

 

 

Posted

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.

 

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

    • Honestly, the forums are a back burner thing. Not many people use it. Best option is discord. I know that I haven't looked at the forums for more then admin tasks in quite a while. You're also best off not following tutorials which give you code. Knowing programming and reading the MC/Forge code yourself would be the best way to go.
    • on my last computer, i had a similar problem with forge/ neoforge mods but instead them launcher screen was black
    • I am trying to make a mod, all it is, a config folder that tells another mod to not require a dependency, pretty simple right.. well, I dont want whoever downloads my mod to have to download 4 other mods and then decide if they want 2 more that they kinda really need.. i want to make my mod basically implement all of these mods, i really dont care how it does it, ive tried putting them in every file location you can think of, ive downloaded intellij, mcreator, and tried vmware but thats eh (had it from school). I downloaded them in hopes theyd create the correct file i needed but honestly im only more lost now. I have gotten my config file to work, if i put all these mods into my own mods folder and the config file into the config and it works (unvbelievably) but i want to share this to everyone else, lets just say this mod will legitimately get 7M downloads.  I tried putting them in a run folder then having it create all the contents in that for a game (mods,config..etc) then i drop the mods in and all the sudden i cant even open the game, like it literally works with my own world i play on, but i cant get it to work on any coding platform, they all have like built in java versions you cant switch, its a nightmare. I am on 1.20.1 I need Java 17 (i dont think the specific versions of 17 matter) I have even tried recreating the mods i want to implement and deleting import things like net.adamsandler.themodsname and replacing it with what mine is. that only creates other problems, where im at right now is i got the thing to start opening then it crashes, closest ive gotten it, then it just says this  exception in thread "main" cpw.mods.niofs.union.unionfilesystem$uncheckedioexception: java.util.zip.zipexception: zip end header not found caused by: java.util.zip.zipexception: zip end header not found basically saying theres something wrong with my java.exe file, so i tried downloading so many different versions of java and putting them all in so many different spots, nothing, someone online says its just a mod that isnt built right so i put the mod into an editor and bunch of errors came up, id post it but i deleted it on accident, i just need help integrating mods
    • Vanilla 1.16.5 Crash Report [#L2KYKaK] - mclo.gs  
    • Hello, probably the last update, if anyone has the same problem or this can be of any help, the answer was pretty simple, textures started rendering just using a Tesselator instead of a VertexConsumer given by a MultibufferSource and a RenderType, pretty simple
  • Topics

×
×
  • Create New...

Important Information

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