Jump to content

Create custom Music Disc [1.12.2]


Spygineer

Recommended Posts

I need help with my mod, I'd like to create a Music Disc, I've tried to create a class that extends from ItemRecord. I can place the disc in the juke box and I can get it back, but the music won't play. I've tried the sound with the /playsound command, and it does work.

 

Here is my Item class:

public class ItemModRecord extends ItemRecord implements IHasModel
{
    public ItemModRecord(String name, CreativeTabs tab, SoundEvent soundIn)
    { 
    	super(name, soundIn);
    	setCreativeTab(tab);
    	setUnlocalizedName(name);
    	setRegistryName(name);
    	
    	ModItems.ITEMS.add(this);
    }
    
    @Override
	public void RegisterModels() 
	{
		Main.proxy.registerItemRenderer(this, 0, "inventory");
	}
}

 

Link to comment
Share on other sites

Oh, well, here is my Soundhandler class:

and the item instance:

public class ModSoundHandler 
{
	public static SoundEvent CARDBOARD_STEP;
	public static SoundEvent CARDBOARD_DIG;
	public static SoundEvent CARDBOARD_PLACE;
	public static SoundEvent CARDBOARD_FALL;
	public static SoundEvent CARDBOARD_BREAK;
	public static SoundEvent CARDBOARD_OPEN;
	public static SoundEvent RECORD_MUSIC_TEST;
	
	public static void RegisterSounds()
	{
		CARDBOARD_STEP = registerSound("block.cardboard.step");
		CARDBOARD_DIG = registerSound("block.cardboard.dig");
		CARDBOARD_PLACE = registerSound("block.cardboard.place");
		CARDBOARD_FALL = registerSound("block.cardboard.fall");
		CARDBOARD_BREAK = registerSound("block.cardboard.break");
		CARDBOARD_OPEN = registerSound("block.cardboard.open");
		RECORD_MUSIC_TEST = registerSound("record.test");
	}
	
	static SoundEvent registerSound(String name)
	{
		SoundEvent event = new SoundEvent(new ResourceLocation(Main.ModID, name));
		event.setRegistryName(name);
		ForgeRegistries.SOUND_EVENTS.register(event);
		
		return event;
	}
}
public static final Item RECORD_TEST = new ItemModRecord("music_disc", CreativeTabs.MISC, ModSoundHandler.RECORD_MUSIC_TEST);

 

Edited by Spygineer
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
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.