Jump to content

1.7.10 Music disk event problem.


BottleFact

Recommended Posts

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
    • Update your drivers: https://www.amd.com/en/support/graphics/amd-radeon-r9-series/amd-radeon-r9-200-series/amd-radeon-r9-280x
  • Topics

×
×
  • Create New...

Important Information

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