Jump to content

Recommended Posts

Posted

Hello I'm trying to add a music disc into Minecraft. I'm on forge 1.7.10-10.13.2.1291. I've been trying to add a music disc for quite some time and nothing, I've got it in the game with the proper name but theres no sound. I've added bunch of other stuff into Minecraft and had no problems. I only gave you everything that is connected with the music disc and if you know anything wrong with my setup, please tell me. :'(

 

This is my MusicDisc.java :: http://pastebin.com/TJ59fGjk

And this is my main class :: http://pastebin.com/jU6vJrMp

 

My sounds.json :

{

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

}

 

And my en_US.lang :

item.record_Kitten.name=Music Disc

item.record_Kitten.desc=Music Disc Description Testing

 

Thanks for your time.    :)

Posted

This is my adddisc function for custom records. But I am using 1.8.0 so I am not sure whether it is work on 1.7.10 or not.

 

package net.extend.mod.functions;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.common.collect.Maps;

import net.extend.mod.ref;
import net.minecraft.block.BlockJukebox;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class adddisc extends ItemRecord {

public String music;
private static final Map RECORDS = new HashMap();
public adddisc(String name, String music) {
	super(music);

	this.setMaxStackSize(1);
        this.setCreativeTab(CreativeTabs.tabMisc);
        this.setUnlocalizedName(name);
        this.music = music;
        RECORDS.put("records." + music, this);
        GameRegistry.registerItem(this, name);
}

@Override
    public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == Blocks.jukebox && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue()) {
            if (worldIn.isRemote) { return true; }
            else {
            	((BlockJukebox)Blocks.jukebox).insertRecord(worldIn, pos, iblockstate, stack);
                worldIn.playAuxSFXAtEntity((EntityPlayer)null, 1005, pos, Item.getIdFromItem(this));
                --stack.stackSize;
                return true;
            }
        } else { return false; }
    }

@Override
    @SideOnly(Side.CLIENT)
    public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) {
        tooltip.add(this.getRecordNameLocal());
    }

@Override
    @SideOnly(Side.CLIENT)
    public String getRecordNameLocal() {
        return StatCollector.translateToLocal(this.getUnlocalizedName() + ".desc");
    }

@Override
public ResourceLocation getRecordResource(String record) {
	ResourceLocation location = super.getRecordResource(ref.uid + ":" + this.music);
	return location;
}

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

 @SideOnly(Side.CLIENT)
 public static adddisc getRecord(String name) {
	 return (adddisc)RECORDS.get(name);
     }
}

 

public static Item discWish;
public static Item discJingle;
public static Item discCarol;
public static Item discBirGorusKabininde;
public static Item discAhSensiz;
public static Item discKoNewYear;
public static Item discNumb;
public static Item discBeautifulMind;
public static Item discSomebodyToldMe;
public static Item discKids;
public static Item discGhostsNStuff;
public static Item discVivaLaVida;
public static Item discApplause;
public static Item discDiamonds;
public static Item discMovesLikeJagger;
public static Item discRapGod;
public static Item discSetFireToRain;
public static Item discSurvival;
public static Item discMusadenizleCocuklar;
public static Item discWeAreTheChampions;
public static Item discTheFinalCountdown;
public static Item discStill;

 

	discWish = new adddisc("discwish", "wish");
	discJingle = new adddisc("discjingle", "jingle");
	discCarol = new adddisc("disccarol", "carol");
	discBirGorusKabininde = new adddisc("discbirgoruskabininde", "birgoruskabininde");
	discAhSensiz = new adddisc("discahsensiz", "ahsensiz");
	discKoNewYear = new adddisc("disckonewyear", "konewyear");
	discNumb = new adddisc("discnumb", "numb");
	discBeautifulMind = new adddisc("discbeautifulmind", "beautifulmind");
	discSomebodyToldMe = new adddisc("discsomebodytoldme", "somebodytoldme");
	discKids = new adddisc("disckids", "kids");
	discGhostsNStuff = new adddisc("discghostsnstuff", "ghostsnstuff");
	discVivaLaVida = new adddisc("discvivalavida", "vivalavida");
	discApplause = new adddisc("discapplause", "applause");
	discDiamonds = new adddisc("discdiamonds", "diamonds");
	discMovesLikeJagger = new adddisc("discmoveslikejagger", "moveslikejagger");
	discRapGod = new adddisc("discrapgod", "rapgod");
	discSetFireToRain = new adddisc("discsetfiretorain", "setfiretorain");
	discSurvival = new adddisc("discsurvival", "survival");
	discMusadenizleCocuklar = new adddisc("discmusadenizlecocuklar", "musadenizlecocuklar");
	discWeAreTheChampions = new adddisc("discwearethechampions", "wearethechampions");
	discTheFinalCountdown = new adddisc("discthefinalcountdown", "thefinalcountdown");
	discStill = new adddisc("discstill", "still");

 

Json:

{
    "wish": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/wish",
            "stream": true
            }
        ]
    },
    
    "jingle": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/jingle",
            "stream": true
            }
        ]
    },

    "carol": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/carol",
            "stream": true
            }
        ]
    },

    "birgoruskabininde": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/birgoruskabininde",
            "stream": true
            }
        ]
    },
    
    "ahsensiz": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/ahsensiz",
            "stream": true
            }
        ]
    },
    
    "konewyear": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/konewyear",
            "stream": true
            }
        ]
    },
    
    "numb": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/numb",
            "stream": true
            }
        ]
    },

    "beautifulmind": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/beautifulmind",
            "stream": true
            }
        ]
    },

    "somebodytoldme": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/somebodytoldme",
            "stream": true
            }
        ]
    },

    "kids": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/kids",
            "stream": true
            }
        ]
    },

    "ghostsnstuff": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/ghostsnstuff",
            "stream": true
            }
        ]
    },

    "vivalavida": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/vivalavida",
            "stream": true
            }
        ]
    },

    "applause": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/applause",
            "stream": true
            }
        ]
    },   

    "diamonds": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/diamonds",
            "stream": true
            }
        ]
    },

    "moveslikejagger": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/moveslikejagger",
            "stream": true
            }
        ]
    },

    "rapgod": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/rapgod",
            "stream": true
            }
        ]
    },

    "setfiretorain": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/setfiretorain",
            "stream": true
            }
        ]
    },

    "survival": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/survival",
            "stream": true
            }
        ]
    },
    
    "musadenizlecocuklar": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/musadenizlecocuklar",
            "stream": true
            }
        ]
    },
    
    "wearethechampions": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/wearethechampions",
            "stream": true
            }
        ]
    },
    
    "thefinalcountdown": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/thefinalcountdown",
            "stream": true
            }
        ]
    },
    
    "still": {
        "category": "record",
        "sounds": [
            {
            "name": "extend:records/still",
            "stream": true
            }
        ]
    }
}

 

And my ogg files in

C:\Users\Hamit\Desktop\Minecraft\1.8.0\src\main\resources\assets\extend\sounds\records

 

I am not sure, but maybe help you.

Posted

Glistre, your modid can be anything, with numbers and can have as many as you want characters.

I'll be trying the code xwerswoodx gave and see if that works. Will post my result.

Posted

Doesn't work...

When I copied the code there was a lot of errors, I fixed all of them and still nothing.

I got the item in game, I can put it in the jukebox but there still isn't any sound. :/  :'(

I wish there was a straightforward tutorial for 1.7.10.

If anyone knows something more, please let me know.

  • 2 weeks later...
Posted

I'm still working on this I solved it for 1.6.4 but not 1.7.10 ...cannot seem to get the sound to play which I believe must be done using @SubscribeEvent instead of @ForgeSubscribe but the same methods no longer work

 

This works in 1.6.4

public class SoundLoadHandler {
@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onSoundsLoaded(SoundLoadEvent event) {
	SoundManager src = event.manager;
	src.soundPoolStreaming.addSound("glistremod:wolf_howl.ogg");
/*		src.soundPoolStreaming.addSound(ref.uid + ":jingle.ogg");
	*/
}
/*	@ForgeSubscribe 
public void onSound(SoundLoadEvent event)
        {
            event.manager.soundPoolStreaming.addSound("glistremod:wolf_howl");         
    }*/

@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onPlayStreaming(PlayStreamingEvent event) {
	boolean isCont;
	isCont = event.name.contains("glistremod");
	if (!isCont) {
		FMLClientHandler.instance().getClient().sndManager.playStreaming("glistremod:" +  event.name, event.x + 0.5F, event.y + 0.5F, event.z + 0.5F);
	}
}

}

 

and put on the Event bus with :

        MinecraftForge.EVENT_BUS.register(new SoundLoadHandler());

 

maybe you can work with that

 

Posted

This is all I have and it works fine:

 

public class CustomRecord extends ItemRecord
{

 private static final Map records = new HashMap();

 public final String recordName;

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

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

	 records.put(recordName, this);
 }


 @Override
 public void registerIcons(IIconRegister iconRegister)
 {
	 itemIcon = iconRegister.registerIcon(Main.modid + ":" + "record");
 }


 @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.getBlock(x, y, z) == Blocks.jukebox && world.getBlockMetadata(x, y, z) == 0)
    	 {
		 if (world.isRemote)
		 {
			 return true;
		 }
		 else
		 {
			 ((BlockJukebox)Blocks.jukebox).func_149926_b(world, x, y, z, itemStack);
			 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 RecordHorror getRecord(String par0Str)
 {
	 return (RecordHorror)records.get(par0Str);
 }


 @Override
 public ResourceLocation getRecordResource(String name)
 {
	 return new ResourceLocation(Main.modid + ":" + name);
 }
}

 

None of that needs to be edited except for the icon texture name near the top.

As for the making the item itself:

 

record_name = new CustomRecord("Record Title").setUnlocalizedName("record_name ").setCreativeTab(CreativeTabs.tabMisc).setTextureName(Main.modid + ":" + "record");
GameRegistry.registerItem(record_name , "record_name ");

 

And lastly in the sounds.json file:

{
  "RecordTitle": {
    "category": "record",
    "sounds": [{"name": "RecordTitle",
    "stream": true}]
  }
}

Posted

I got an error Unable to play Unknown soundEvent unless I had this:

 @Override
@SubscribeEvent
public ResourceLocation getRecordResource(String name)
{
 return new ResourceLocation(GlistreMod.MODID +":"+ name);
}

 

and my sounds json did not have "records. ' in front of wolf_howl

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

 

mine now works

  • 1 month later...
Posted

This is all I have and it works fine:

 

public class CustomRecord extends ItemRecord
{

 private static final Map records = new HashMap();

 public final String recordName;

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

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

	 records.put(recordName, this);
 }


 @Override
 public void registerIcons(IIconRegister iconRegister)
 {
	 itemIcon = iconRegister.registerIcon(Main.modid + ":" + "record");
 }


 @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.getBlock(x, y, z) == Blocks.jukebox && world.getBlockMetadata(x, y, z) == 0)
    	 {
		 if (world.isRemote)
		 {
			 return true;
		 }
		 else
		 {
			 ((BlockJukebox)Blocks.jukebox).func_149926_b(world, x, y, z, itemStack);
			 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 RecordHorror getRecord(String par0Str)
 {
	 return (RecordHorror)records.get(par0Str);
 }


 @Override
 public ResourceLocation getRecordResource(String name)
 {
	 return new ResourceLocation(Main.modid + ":" + name);
 }
}

 

None of that needs to be edited except for the icon texture name near the top.

As for the making the item itself:

 

record_name = new CustomRecord("Record Title").setUnlocalizedName("record_name ").setCreativeTab(CreativeTabs.tabMisc).setTextureName(Main.modid + ":" + "record");
GameRegistry.registerItem(record_name , "record_name ");

 

And lastly in the sounds.json file:

{
  "RecordTitle": {
    "category": "record",
    "sounds": [{"name": "RecordTitle",
    "stream": true}]
  }
}

 

Erm, is it possible for you to give me all the imports. There are multiply one I can select when I about to import and I'm not too sure which one is the right one.

  • 7 months later...
Posted

Yeah i am looking to add new music disks to my minecraft without using the more disks mod for Minecraft 1.7.10 i suck at Java coding and would like someone to help me out adding my music to my minecraft as the orginal disks are boring now, however i do not want to overwrite the disks already in minecraft so how can i add my music in music disks without overwriting the original Minecraft music disks?

Posted

You're gonna need to compromise somewhere, and it's gonna take some work.

 

1) Find a mod that will add disc items to the game and allow you to insert your own music files for those discs to play. I just happen to have such a project on my to-do list. I might even get to it before the end of 2016, but don't hold your breath. However, you'd still need to get your music into ogg format (prolly require conversion, which will require an app like VLC and learning how to use it). Then the ogg files would prolly need special names, and they'd need to be moved to a special place so that the mod would use them.

 

2) Go learn Java. This forum assumes you already know Java and just need a little help to understand a Forge feature, so you'll need to look beyond. Fortunately, there are many online tutorials and manuals and forum discussions. Java's essential-level features are also amazingly easy to acquire if you have experience in another O-O language, esp once you come up to speed in Eclipse for Java (an IDE).

 

3) Hire a professional. When "between contracts" (i.e. unemployed), we can be had for about $50/hr (or you could hire an amateur for $30/hr, maybe even less, but he would take forever and still get it wrong). I estimate this project will take about 1 week coding and another of debugging. So basically, you're asking for about $4000 worth of help here. Scrape together $4000, and you'll find help coming out of the woodwork.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

So if i want help on adding my own music to mincraft i am expected to pay £2775.98 just for a small bit of coding?

I guess i need to learn Java then oh well; thanks for the help but I think that £2775.98 is way too much to pay just for some lines of code

Posted

... a small bit of coding... just for some lines of code

You really underestimate the amount of code needed. It is just not 'some lines of code'.

 

BTW, next time, please don't reply to a thread which is 6 months old, thank you.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

So if i want help on adding my own music to mincraft i am expected to pay £2775.98...?

No, you just need to get a hell of a lot closer to the finished product before you ask for the tip that sets you free.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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

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

Announcements



×
×
  • Create New...

Important Information

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