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 get the following message when I put in the disc:

[10:47:37] [Client thread/WARN]: Unable to play empty soundEvent: starfield:Bliss

 

I have the file set up correctly I believe, but I'm not sure about the class and sounds.json.

 

sounds.json is in assets/starfield. The ogg file is in assets/starfield/records

 

sounds.json:

{
"Bliss": {"category": "master","records": [{"name": "Bliss","stream": true}]}
}

 

MusicDisc.class:

package sqm.minecraft.starfield.items;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import sqm.minecraft.starfield.common.Starfield;
import net.minecraft.block.BlockJukebox;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;

public class MusicDisc extends ItemRecord
{
private static final Map records = new HashMap();


public final String recordName;


public MusicDisc(String recordName)
{
super(recordName);


this.recordName = recordName;
this.maxStackSize = 1;




records.put(recordName, this);
}


@Override
public void registerIcons(IIconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon(Starfield.MODID + ":" + "record_" + recordName);
}


@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
//TODO: world.getBlock()
if (world.getBlock(x, y, z) == Blocks.jukebox && world.getBlockMetadata(x, y, z) == 0)
{
if (world.isRemote)
return true;
else
{
//TODO: .insertRecord()
((BlockJukebox)Blocks.jukebox).func_149926_b(world, x, y, z, itemStack);
//TODO: Item.getIdFromItem()
world.playAuxSFXAtEntity((EntityPlayer)null, 1005, x, y, z, Item.getIdFromItem(this));
--itemStack.stackSize;
return true;
}
} 
else
return false;
}


@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add(this.getRecordNameLocal());
}


@Override
//TODO: getRecordTitle()
public String getRecordNameLocal()
{
return StatCollector.translateToLocal(this.getUnlocalizedName() + ".desc");
}


@Override
public EnumRarity getRarity(ItemStack itemStack)
{
return EnumRarity.rare;
}


public static MusicDisc getRecord(String par0Str)
{
return (MusicDisc)records.get(par0Str);
}


@Override
public ResourceLocation getRecordResource(String name)
{
return new ResourceLocation("starfield:"+this.recordName);
}
}

Creator of the Starfield Mod.

my first advice in use all lowercase for filenames, disk names mod id etc. only use uppercase in the lang file as translated text

 

these are sections of my records mod (no ogg files provided)

the main class of the mod is LoonRecords

 

definition of LoonRecords.modid

public static final String modid="loonrecords";

 

public static ItemGoldRecord diskadeline=new ItemGoldRecord("adeline");

// called during FMLPreInitializationEvent
GameRegistry.registerItem(diskadeline, "record_adeline");

 

here is the ItemGoldRecord class

import java.util.ArrayList;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

public class ItemGoldRecord extends ItemRecord {
public static ArrayList<ItemGoldRecord> list=new ArrayList<ItemGoldRecord>();
private String recordname;

protected ItemGoldRecord(String name) {
	super(name);
	list.add(this);
	setUnlocalizedName("record");
	setTextureName("record_"+name);
	setCreativeTab(CreativeTabs.tabMisc);
	recordname=name;
}

@Override
public ResourceLocation getRecordResource(String arg0) {
	ResourceLocation r=super.getRecordResource(LoonRecords.modid+":"+arg0);
	return r;
}

@Override
public void registerIcons(IIconRegister reg) {
	itemIcon=reg.registerIcon(LoonRecords.modid+":record_"+recordname);
}

@Override
public String getUnlocalizedName() {
	return "record."+recordname;
}

@Override
public String getUnlocalizedName(ItemStack arg0) {
	return getUnlocalizedName();
}
}

this class keeps a list of all records added with it (i use the list for the villager that sells them in my mod)

 

 

thats the code side of it , you will notice all text is lowercase

 

in  resources  assetts.loonrecords sounds.json file

{
  "records.adeline": {
    "category": "record",
    "sounds": [
      {
        "name": "records/adeline",
        "stream": true
      }
    ]
  },

this file needs to be carefully written,

to add more records repeat all but the first "{"

when finished remove the lase "," and put a "}" on the last line

use spaces not tabs

 

 

 

in  resources  assetts.loonrecords.lang in en_US.lang file

record.adeline.name=Music Disk Adeline
item.record.adeline.desc=Balad for Adeline

 

in  resources  assetts.loonrecords.sounds.records is the adaline.oog  file

 

 

hope this helps

 

  • 3 months later...

Sorry for my English I'm using google translator

 

When I put the disc in the jukebox music does not sound.

 

On the console:

 

[23:59:23] [thread Client / WARN]: Unable to play unknown SoundEvent: mineprueba: records.adeline

I would :

 

1) change record name Bliss to lower case bliss;

2) change your sounds json to read : records.bliss instead of Bliss;  change the Bliss after name to bliss;

3) delete the "+record_  from the itemIcon method;

4) in the resource location method change this.recordName to just name;

5) move the record to new package assets.starfield.sounds.

 

That will work for you.  I know it does because I typed it all in my mod like that to test it and it works.

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.