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

Posted

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");
	}
}

 

  • Author

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

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.