The Meaning of Life, the Universe, and Everything.
Join Date:
2/6/2014
Posts:
63
Member Details
So I seem to get the same problem a lot of others are running into. My music disc is there and has the texture, but when I go to play it, I hear nothing. The Jukebox shows the correct music disc playing... but I hear nothing playing...
The sounds.json is under the directory \resources\assets\mymod\
The "hieghts.ogg" is under \resources\assets\mymod\sounds\records\
So I seem to get the same problem a lot of others are running into. My music disc is there and has the texture, but when I go to play it, I hear nothing. The Jukebox shows the correct music disc playing... but I hear nothing playing...
The sounds.json is under the directory \resources\assets\mymod\
The "hieghts.ogg" is under \resources\assets\mymod\sounds\records\
A: Make MyMod lowercase for ResourceLocations and Icons and related things (i.e. anything you are referencing in the assets package). It'll work in the development environment but I highly doubt it will work when you compile your mod.
B: Your record item class has nothing in it that would make the record play in the jukebox. You should head back to the original post and redo the record class.
Thanks! I had all the code in there from the first post, but I was removing functions here and there.
I changed the MusicDisc and updated all the resource locations to be "mymod:" instead.
I think this is how I had it originally.
Still no luck...
So I decided to try the AdditionalRecords mod and see if that even works... and it did not!
Turns out no custom music dics work for me.
I looked closer and I found I get this error with the AdditionalRecords mod...
Pulled from the latest.log file
[00:17:59] [Client thread/WARN]: Unable to play unknown soundEvent: minecraft:records.cd1
I decided to take out my Optifine and fast-craft mods... and then it worked!
So for some reason one of those mods prevents custom music discs???
You've got to put your own music into Additional Records But this Optifine/Fastcraft error though, I find it kind of weird since those mostly work on rendering and chunks. I'm going to try it out with fastcraft and see if its the culprit. Glad your record works now though.
You've got to put your own music into Additional Records But this Optifine/Fastcraft error though, I find it kind of weird since those mostly work on rendering and chunks. I'm going to try it out with fastcraft and see if its the culprit. Glad your record works now though.
It turned out to be something with the old OptFine I was using. I think it was OptiFine_1.7.10_HD_A4 if you want to investigate it.
I know this thread is really, really old and I am probably doing something really, really dumb, but I have been working on this for days. My custom record seems to be called no problem but no matter WHAT i do I absolutely cannot get it to play...it does not play in either 1.6.4 or 1.7.10.
This forum has some really smart people could anyone help?
[/p]
[p]package glistremod.items;[/p]
[p]import glistremod.Main;[/p]
[p]import java.util.HashMap;
import java.util.List;
import java.util.Map;[/p]
[p]import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockJukeBox;
import net.minecraft.client.renderer.texture.IconRegister;
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.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.client.event.sound.PlayStreamingEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;[/p]
[p]
public class MusicDisc extends ItemRecord {[/p]
[p]private static final Map records = new HashMap();[/p]
[p]
public final String recordName;[/p]
[p]
public MusicDisc(int ItemID, String recordName)
{
super(ItemID, recordName);[/p]
[p]this.setCreativeTab(CreativeTabs.tabMisc);
this.recordName = recordName;
this.maxStackSize = 1;
records.put(recordName, this);
}[/p]
[p]@SideOnly(Side.CLIENT)[/p]
[p]@Override
public void registerIcons(IconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon("glistremod:" + recordName);
}[/p]
[p]
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
if (world.getBlockId(x, y, z) == Block.jukebox.blockID && world.getBlockMetadata(x, y, z) == 0)
{
if (world.isRemote)
return true;
else
{
((BlockJukeBox)Block.jukebox).insertRecord(world, x, y, z, itemStack);
//world.playAuxSFX(1005, x, y, z, this.itemID);
world.playAuxSFXAtEntity((EntityPlayer)null, 1005, x, y, z, this.itemID);
--itemStack.stackSize;
return true;
}
}
else
return false;
}[/p]
[p]/**
* allows items to add custom lines of information to the mouseover description
*/
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add(this.getRecordTitle());
}[/p]
[p]/**
* Return the title for this record.
*/
@Override
public String getRecordTitle()
{
return StatCollector.translateToLocal(this.getUnlocalizedName() + ".desc");
}[/p]
[p]/**
* *Possibly returns record titles from Vanilla minecraft
*/
/* public String getRecordTitle()
{
return "C418 - " + this.recordName;
}*/[/p]
[p]@Override
public EnumRarity getRarity(ItemStack itemStack)
{
return EnumRarity.rare;
}[/p]
[p]/**
* Return the record item corresponding to the given name.
*/
public static MusicDisc getRecord(String recordName)
{
return (MusicDisc)records.get(recordName);
}[/p]
[p]
public ResourceLocation getRecordResource(String name)
{
return new ResourceLocation("glistremod:sounds/Wolf_Howl.ogg");
}[/p]
[p]
public String getSoundFile()
{[/p]
[p]return ("glistremod:sounds/Wolf_Howl.ogg");
}
@ForgeSubscribe
public void onSound(SoundLoadEvent event)[/p]
[p]{
event.manager.soundPoolStreaming.addSound("glistremod:sounds/Wolf_Howl");
}[/p]
[p]
// event.manager.soundPoolSounds.addSound("x/sound2.ogg", mod_ModName.class.getResource("/x/sound2.ogg"));[/p]
[p]public void onPlayStreaming(PlayStreamingEvent event) {
boolean isCont;
isCont = event.name.contains("Wolf_Howl");
if (!isCont) {
FMLClientHandler.instance().getClient().sndManager.playStreaming("glistremod"+ ":" + event.name, event.x + 0.5F, event.y + 0.5F, event.z + 0.5F);
}
}
}
I know this thread is really, really old and I am probably doing something really, really dumb, but I have been working on this for days. My custom record seems to be called no problem but no matter WHAT i do I absolutely cannot get it to play...it does not play in either 1.6.4 or 1.7.10.
This forum has some really smart people could anyone help?
</p> <p>package glistremod.items;</p> <p>import glistremod.Main;</p> <p>import java.util.HashMap;<br>import java.util.List;<br>import java.util.Map;</p> <p>import cpw.mods.fml.client.FMLClientHandler;<br>import cpw.mods.fml.relauncher.Side;<br>import cpw.mods.fml.relauncher.SideOnly;<br>import net.minecraft.block.Block;<br>import net.minecraft.block.BlockJukeBox;<br>import net.minecraft.client.renderer.texture.IconRegister;<br>import net.minecraft.creativetab.CreativeTabs;<br>import net.minecraft.entity.player.EntityPlayer;<br>import net.minecraft.item.EnumRarity;<br>import net.minecraft.item.Item;<br>import net.minecraft.item.ItemRecord;<br>import net.minecraft.item.ItemStack;<br>import net.minecraft.util.ResourceLocation;<br>import net.minecraft.util.StatCollector;<br>import net.minecraft.world.World;<br>import net.minecraftforge.client.event.sound.PlayStreamingEvent;<br>import net.minecraftforge.client.event.sound.SoundLoadEvent;<br>import net.minecraftforge.event.ForgeSubscribe;</p> <br><p> public class MusicDisc extends ItemRecord {</p> <p>private static final Map records = new HashMap();</p> <p> public final String recordName;</p> <p> public MusicDisc(int ItemID, String recordName)<br> {<br> super(ItemID, recordName);</p> <p>this.setCreativeTab(CreativeTabs.tabMisc);<br> this.recordName = recordName;<br> this.maxStackSize = 1;<br> records.put(recordName, this);<br> }</p> <p>@SideOnly(Side.CLIENT)</p> <p>@Override<br> public void registerIcons(IconRegister iconRegister)<br> {<br> itemIcon = iconRegister.registerIcon("glistremod:" + recordName);<br> }</p> <p> @Override<br> public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)<br> {<br> if (world.getBlockId(x, y, z) == Block.jukebox.blockID && world.getBlockMetadata(x, y, z) == 0)<br> {<br> if (world.isRemote)<br> return true;<br> else<br> {<br> ((BlockJukeBox)Block.jukebox).insertRecord(world, x, y, z, itemStack);<br>//world.playAuxSFX(1005, x, y, z, this.itemID);<br> world.playAuxSFXAtEntity((EntityPlayer)null, 1005, x, y, z, this.itemID);<br> --itemStack.stackSize;<br> return true;<br> }<br> } <br> else<br> return false;<br> }</p> <p>/**<br> * allows items to add custom lines of information to the mouseover description<br> */<br> @Override<br> public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)<br> {<br> par3List.add(this.getRecordTitle());<br> }</p> <p>/**<br> * Return the title for this record.<br> */<br> @Override<br> public String getRecordTitle()<br> {<br> return StatCollector.translateToLocal(this.getUnlocalizedName() + ".desc");<br> <br> }</p> <p>/**<br> * *Possibly returns record titles from Vanilla minecraft<br> */<br>/* public String getRecordTitle()<br> {<br> return "C418 - " + this.recordName;<br> }*/</p> <p>@Override<br> public EnumRarity getRarity(ItemStack itemStack)<br> {<br> return EnumRarity.rare;<br> }</p> <p>/**<br> * Return the record item corresponding to the given name.<br> */<br> public static MusicDisc getRecord(String recordName)<br> {<br> return (MusicDisc)records.get(recordName);<br> }</p> <p> public ResourceLocation getRecordResource(String name)<br>{<br>return new ResourceLocation("glistremod:sounds/Wolf_Howl.ogg");<br>}</p> <p> public String getSoundFile()<br> {</p> <p>return ("glistremod:sounds/Wolf_Howl.ogg");<br> }<br>@ForgeSubscribe <br>public void onSound(SoundLoadEvent event)</p> <p>{<br> event.manager.soundPoolStreaming.addSound("glistremod:sounds/Wolf_Howl");<br> <br> }</p> <p> // event.manager.soundPoolSounds.addSound("x/sound2.ogg", mod_ModName.class.getResource("/x/sound2.ogg"));</p> <p>public void onPlayStreaming(PlayStreamingEvent event) {<br> boolean isCont;<br> isCont = event.name.contains("Wolf_Howl");<br> if (!isCont) {<br> FMLClientHandler.instance().getClient().sndManager.playStreaming("glistremod"+ ":" + event.name, event.x + 0.5F, event.y + 0.5F, event.z + 0.5F);<br> }<br> }<br>}
All the code appears to be right, but the sound still wont play.
"src\main\resources\assets\piratecody_nethercraft" is where my sounds.json is
"src\main\resources\assets\piratecody_nethercraft\records"
I kept all the names the same from your code. (with the "kitten").
I replaced "Dragonborn" with my mod id.
So I seem to get the same problem a lot of others are running into. My music disc is there and has the texture, but when I go to play it, I hear nothing. The Jukebox shows the correct music disc playing... but I hear nothing playing...
The sounds.json is under the directory \resources\assets\mymod\
The "hieghts.ogg" is under \resources\assets\mymod\sounds\records\
Here is my sounds.json
{ "records.heights": {"category": "record","sounds": [ {"name": "records/heights","stream": true }]}}
In my main java file I register the item
...
recordHeights = registerItem(new MusicDisc("heights").setUnlocalizedName("record_heights"));
Could you post your item class too? And are you sure you aren't spelling the name of the sound file wrong?
Monoblocks and Vehicular Movement: The greatest additions to a modern Minecraft city. Grab them here: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2236322-goldensilver853s-mod-hub
You are now breathing manually.
I typo'd the name in the forums. The file is "heights.ogg" and "heights" everywhere in the code and the sounds.json file.
I have tried adding debug in to see if something is coming back null, but not seeing any errors or problems. The debug always shows "records.heights"
package mymod;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.util.ResourceLocation;
public class MusicDisc extends ItemRecord {
public MusicDisc(String recordName) {
super(recordName);
this.maxStackSize = 1;
this.setCreativeTab(CreativeTabs.tabMisc);
}
@Override
public void registerIcons(IIconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon("MyMod:record_" + recordName);
}
@Override
public ResourceLocation getRecordResource(String name)
{
return new ResourceLocation("MyMod:" + name);
}
}
Here is what I basically have in MyMod.java
public class MyMod {
public static Item recordHeights;
@EventHandler public void load(FMLInitializationEvent event) {
recordHeights = new MusicDisc("heights").setUnlocalizedName("record_heights");
GameRegistry.registerItem(recordHeights, "heights");
}
}
A: Make MyMod lowercase for ResourceLocations and Icons and related things (i.e. anything you are referencing in the assets package). It'll work in the development environment but I highly doubt it will work when you compile your mod.
B: Your record item class has nothing in it that would make the record play in the jukebox. You should head back to the original post and redo the record class.
Monoblocks and Vehicular Movement: The greatest additions to a modern Minecraft city. Grab them here: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2236322-goldensilver853s-mod-hub
You are now breathing manually.
Thanks! I had all the code in there from the first post, but I was removing functions here and there.
I changed the MusicDisc and updated all the resource locations to be "mymod:" instead.
I think this is how I had it originally.
Still no luck...
So I decided to try the AdditionalRecords mod and see if that even works... and it did not!
Turns out no custom music dics work for me.
I looked closer and I found I get this error with the AdditionalRecords mod...
Pulled from the latest.log file
[00:17:59] [Client thread/WARN]: Unable to play unknown soundEvent: minecraft:records.cd1
I decided to take out Optifine... and then it worked!
EDIT: I grabbed the latest Optifine "OptiFine_1.7.10_HD_B5" and it works now with OptiFine
Thanks again for the help
So for some reason one of those mods prevents custom music discs???
You've got to put your own music into Additional Records But this Optifine/Fastcraft error though, I find it kind of weird since those mostly work on rendering and chunks. I'm going to try it out with fastcraft and see if its the culprit. Glad your record works now though.
Monoblocks and Vehicular Movement: The greatest additions to a modern Minecraft city. Grab them here: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2236322-goldensilver853s-mod-hub
You are now breathing manually.
It turned out to be something with the old OptFine I was using. I think it was OptiFine_1.7.10_HD_A4 if you want to investigate it.
I know this thread is really, really old and I am probably doing something really, really dumb, but I have been working on this for days. My custom record seems to be called no problem but no matter WHAT i do I absolutely cannot get it to play...it does not play in either 1.6.4 or 1.7.10.
sounds.json file:
my main file before preInit:
my main file in the preInit method:
most of your code is completely different form this tutorial, I recommend re trying.
I just found this tutorial and FINALLY I have working records for my mod. So thanks for this.
However.....when I play a record the Vanilla music does not stop so you end up hearing both the default music and my music on top of each other.
Is there a fix for this or am I the only one this is happening to?
PubliCraft & Fandomcraft
I was able to get it working so I will have to go back and compare my code to this forum thanks
I did not have the problem of Vanilla music playing in the background if I figure that out I will post
PubliCraft & Fandomcraft
Code or no one can help
Monoblocks and Vehicular Movement: The greatest additions to a modern Minecraft city. Grab them here: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2236322-goldensilver853s-mod-hub
You are now breathing manually.
I still can't get it to work even though it looks fine... heres some of the code
Register thing
record_cd1=new Record(0, "cd1").setTextureName("niftyblocks:cd1").setUnlocalizedName("cd1");
Record class
package com.niftyblocks.nifty;
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 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.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class Record
extends ItemRecord
{
private static final Map records = new HashMap();
public final String recordName;
public Record(int par1, String par0Str)
{
super(par0Str);
this.recordName = par0Str;
this.maxStackSize = 1;
this.setCreativeTab(NiftyBlocks.tabnifty);
records.put(par0Str, this);
}
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1)
{
return this.itemIcon;
}
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.getBlock(par4, par5, par6) == Blocks.jukebox) && (par3World.getBlockMetadata(par4, par5, par6) == 0))
{
if (par3World.isRemote) {
return true;
}
((BlockJukebox)Blocks.jukebox).func_149926_b(par3World, par4, par5, par6, par1ItemStack);
par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, Item.getIdFromItem(this));
par1ItemStack.stackSize -= 1;
return true;
}
return false;
}
@SideOnly(Side.CLIENT)
public void func_77624_a(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add(getRecordTitle());
}
@SideOnly(Side.CLIENT)
public String getRecordTitle()
{
return this.recordName;
}
@SideOnly(Side.CLIENT)
public EnumRarity func_77613_e(ItemStack par1ItemStack)
{
return EnumRarity.rare;
}
@SideOnly(Side.CLIENT)
public static Record getRecord(String par0Str)
{
return (Record)records.get(par0Str);
}
public ResourceLocation getRecordResource(String name)
{
return new ResourceLocation("niftyblocks:" + name);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("niftyblocks:" + this.getUnlocalizedName().substring(5));
}
}
sounds.json
{
"records.cd1": {
"category": "record",
"sounds": [
{
"name": "records/cd1",
"stream": true
}
]
}
}
what is the error ...you mean just won't play?
Which folder is your record in? sounds.json? I have my record in assets/glistremod/sounds and my sounds.json in assets/glistremod
I do not have "name": "records/cd1", rather I have "name": "cd1",
You may want to play around with the locations and paths to make it work, it took me forever until it finally was perfect
Where am I supposed to keep my sounds.json file and the music file? I am still really confused on this
you can google for how to set up sounds for minecraft forge 1.7.10.
"src\main\resources\assets\piratecody_nethercraft" is where my sounds.json is
"src\main\resources\assets\piratecody_nethercraft\records"
I kept all the names the same from your code. (with the "kitten").
I replaced "Dragonborn" with my mod id.
sounds.json:
MusicDisc.java:
My sound wont play at all what do I do
Show code.