Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Check out ItemRecord.java, especially the onItemUse method. That is where the code for the built-in music discs is, so you should be able to extend that class in order to make your own.

  • Author

I've gotten as far as a working item, now there is just one more problem, getting the sound to play....

If I change the name for the sound to cat, it plays, so my item works, but the name I need doesn't work.

Do I need to convert to .mus?

I've gotten as far as a working item, now there is just one more problem, getting the sound to play....

If I change the name for the sound to cat, it plays, so my item works, but the name I need doesn't work.

Do I need to convert to .mus?

 

In your class for the record you will see somewhere it says about the record name being the name for your music disc. Your sound file name would need to be called YourRecordName.ogg and would need to be in the /resources/mod/streaming folder. That is what worked for me anyway...

  • Author

package daki;

import java.util.List;

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.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemGroovyDisc extends ItemRecord
{
public final String recordName;
public ItemGroovyDisc(int id) {
	  super(id, "groovy.ogg");
	  this.setCreativeTab(CreativeTabs.tabMisc);
	  this.maxStackSize = 1;
	  this.recordName = "groovy.ogg";
	  
}
public String getTextureFile()
    {
            return "/Daki/dakiitems.png";
    }


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;
        }
    }
    @Override
    public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
    par3List.add("groovy");
    }

}

That's my record class, this whole thing is very confusing to me, I'm relatively new to modding and have have added multiple items and mobs before but these records are just so different.

I'd appreciate it if someone could point out what I'm doing wrong, and groovy.ogg is in my \resources\mod\streaming folder.

 

EDIT: I got it!

I added:

public String getSoundFile()

    {

            return "/resources/mod/streaming/groovy.ogg";

    }

 

  • 2 months later...

Hi I used your code and got my music disk working :) but I have a problem with the texture no matter where I like the texture to it never shows up in game.

and help I how I can fix this?

 

 

EDIT: I got it to Work :)

 

I just used this code

    @Override
    public void registerIcons(IconRegister iconRegister) {
        this.blockIcon = iconRegister.registerIcon("Folder:Texture");
    }

in place of your texture code and it worked

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.