Jump to content

Music Disk Not Playing Music! Sounds Not loading i think !


Thecheatgamer1

Recommended Posts

Well this is my mod Items class

 

 

package com.Thecheatgamer1.Annom.Item;

 

import com.Thecheatgamer1.Annom.Lib.ItemIds;

 

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

public class ModItems {

 

    /* Mod item instances */

    public static Item ItemFusionIngot;

    public static Item ItemIredantCrystal;

    public static Item ItemKI87ElementIngot;

    public static Item ItemHappyDaysMusicDisk;

   

 

    public static void init() {

 

        /* Initialize each mod item individually */

        ItemFusionIngot = new ItemFusionIngot(ItemIds.ITEMFUSIONINGOT);

        ItemIredantCrystal = new ItemIredantCrystal(ItemIds.ITEMIREDANTCRYSTAL);

        ItemKI87ElementIngot = new ItemKi87ElementIngot(ItemIds.ITEMKI87ELEMENT);

        ItemHappyDaysMusicDisk = new ItemHappyDaysMusicDisk(ItemIds.ITEMHAPPYDAYSMUSICDISK);

       

        LanguageRegistry.addName(ItemFusionIngot, "Fusion Ingot");

        LanguageRegistry.addName(ItemIredantCrystal, "Iredant Crystal");

        LanguageRegistry.addName(ItemKI87ElementIngot, "Ki87Element Ingot");

        LanguageRegistry.addName(ItemHappyDaysMusicDisk, "HappyDays Music Disk");

       

       

        GameRegistry.addRecipe(new ItemStack(ItemIredantCrystal), new Object[] { "aaa", "aba", "aaa", Character.valueOf('a'), ItemFusionIngot, Character.valueOf('b'), ItemKI87ElementIngot });

       

    }

}

 

 

This is my HappydaysMusic Disk class

 

 

package com.Thecheatgamer1.Annom.Item;

 

import com.Thecheatgamer1.Annom.Annom.Annom;

import com.Thecheatgamer1.Annom.Lib.Sounds;

import com.Thecheatgamer1.Annom.Lib.Textures;

 

import net.minecraft.block.Block;

import net.minecraft.block.BlockJukeBox;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemRecord;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

public class ItemHappyDaysMusicDisk extends ItemRecord {

   

        public final String recordName;

       

        public ItemHappyDaysMusicDisk(int id) {

           

              super(id, "HappyDays");

              this.setCreativeTab(Annom.tabsAnnom);

              this.maxStackSize = 1;

              this.recordName = "HappyDays";

             

}

 

    public String getSoundFile()

    {

            return Sounds.HAPPYDAYS;

    }

   

    public String getTextureFile()

    {

        return Textures.ITEMHAPPYDAYSMUSICDISK;

    } 

   

    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.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)

        {

            if (par3World.isRemote)

            {

                return true;

            }

            else

            {

                ((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack);

                par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID);

                --par1ItemStack.stackSize;

                return true;

            }

        }

        else

        {

            return false;

        }

    }

   

}

 

 

 

This is my SoundHandler class

 

 

package com.Thecheatgamer1.Annom.Client.Audio;

 

 

import java.util.logging.Level;

 

import net.minecraftforge.client.event.sound.SoundLoadEvent;

import net.minecraftforge.event.ForgeSubscribe;

 

import com.Thecheatgamer1.Annom.Core.Util.LogHelper;

import com.Thecheatgamer1.Annom.Lib.Sounds;

 

public class SoundHandler {

 

    @ForgeSubscribe

    public void onSoundLoad(SoundLoadEvent event) {

 

        // For each custom sound file we have defined in Sounds

        for (String soundFile : Sounds.soundFiles) {

            // Try to add the custom sound file to the pool of sounds

            try {

                event.manager.soundPoolSounds.addSound(soundFile, this.getClass().getResource("/" + soundFile));

            }

            // If we cannot add the custom sound file to the pool, log the exception

            catch (Exception e) {

                LogHelper.log(Level.WARNING, "Failed loading sound file: " + soundFile);

            }

        }

    }

}

 

 

 

 

And this is my ClientProxy class

 

 

package com.Thecheatgamer1.Annom.Core.Proxy;

 

import com.Thecheatgamer1.Annom.Client.Audio.SoundHandler;

 

import net.minecraftforge.common.MinecraftForge;

 

public class ClientProxy extends CommonProxy {

 

 

 

    @Override

    public void registerSoundHandler() {

 

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

    }

}

 

 

 

And this is my CommonProxy Class

 

 

package com.Thecheatgamer1.Annom.Core.Proxy;

 

public class CommonProxy {

 

 

    public void registerRenderTickHandler() {

 

    }

 

    public void registerDrawBlockHighlightHandler() {

 

    }

 

    public void registerSoundHandler() {

 

    }

 

    public void initRenderingAndTextures() {

 

    }

}

 

 

 

The Disk Works fine, but the music its supposed to play isnt playing so can someone tell me how to fix it or what i have to add!

Link to comment
Share on other sites

Put this in ItemHappyDaysMusicDisk

public String getSoundFile()
    {
            return "/resources/mod/streaming/FILENAME.ogg";
    }

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Link to comment
Share on other sites

Put this in ItemHappyDaysMusicDisk

public String getSoundFile()
    {
            return "/resources/mod/streaming/FILENAME.ogg";
    }

 

Added and not working, sound is not playing at all!

Did you change the return to where your ogg file is located?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Link to comment
Share on other sites

Put this in ItemHappyDaysMusicDisk

public String getSoundFile()
    {
            return "/resources/mod/streaming/FILENAME.ogg";
    }

 

Added and not working, sound is not playing at all!

Did you change the return to where your ogg file is located?

 

Yes, i even tryed connecting it to my Sounds.java class what is supposed to direct all sounds

Link to comment
Share on other sites

can i see what you put?

 

 

public class ItemHappyDaysMusicDisk extends ItemRecord {

   

        public final String recordName;

       

        public ItemHappyDaysMusicDisk(int id) {

           

              super(id, "HappyDays");

              this.setCreativeTab(Annom.tabsAnnom);

              this.maxStackSize = 1;

              this.recordName = "HappyDays";

             

}

 

        public String getSoundFile()

        {

                return "/resources/mod/Annom/Sound/HappyDyas.ogg";

        }

 

Link to comment
Share on other sites

This is what I use.

 

Main Class:

public Item music1;
music1 = new ItemRecordMusic(11111, "musicone").setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("musicDiskOne");

//The first box is for item ID, and the second box is for file name.
//The file would be located in: \resources\mod\streaming\musicone.ogg

 

ItemRecordMusic

package com.musicraft.main;

import java.util.List;

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.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemRecordMusic extends ItemRecord
{
public final String recordName;

public ItemRecordMusic(int par1, String par2Str)
{
	super(par1, par2Str);
	this.recordName = par2Str;
	this.maxStackSize = 1;
	this.setCreativeTab(CreativeTabs.tabMisc);
}

    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
    {
    	
    }


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.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)
	{
		if (par3World.isRemote)
		{	
			return true;
		}
		else
		{
			((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack);
			par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID);
			--par1ItemStack.stackSize;
			return true;
		}
	}
	else
	{
		return false;
	}
}

@SideOnly(Side.CLIENT)

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
	if (this.recordName == "musicone")
	{
		par3List.add("HappyDays - " + this.recordName);
	}
}

    @SideOnly(Side.CLIENT)
    @Override
    public void updateIcons(IconRegister par1IconRegister)
    {
        this.iconIndex = par1IconRegister.registerIcon(this.recordName);
    }
    
    @Override
    public String getRecordTitle()
    {
        return "HappyDays";
    }
}

 

Some fields, you might have to change by yourself, but this is what I use, and it works fine.

Remember that the file needs to be in OGG format!

Link to comment
Share on other sites

This is what I use.

 

Main Class:

public Item music1;
music1 = new ItemRecordMusic(11111, "musicone").setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("musicDiskOne");

//The first box is for item ID, and the second box is for file name.
//The file would be located in: \resources\mod\streaming\musicone.ogg

 

ItemRecordMusic

package com.musicraft.main;

import java.util.List;

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.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemRecordMusic extends ItemRecord
{
public final String recordName;

public ItemRecordMusic(int par1, String par2Str)
{
	super(par1, par2Str);
	this.recordName = par2Str;
	this.maxStackSize = 1;
	this.setCreativeTab(CreativeTabs.tabMisc);
}

    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
    {
    	
    }


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.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)
	{
		if (par3World.isRemote)
		{	
			return true;
		}
		else
		{
			((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack);
			par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID);
			--par1ItemStack.stackSize;
			return true;
		}
	}
	else
	{
		return false;
	}
}

@SideOnly(Side.CLIENT)

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
	if (this.recordName == "musicone")
	{
		par3List.add("HappyDays - " + this.recordName);
	}
}

    @SideOnly(Side.CLIENT)
    @Override
    public void updateIcons(IconRegister par1IconRegister)
    {
        this.iconIndex = par1IconRegister.registerIcon(this.recordName);
    }
    
    @Override
    public String getRecordTitle()
    {
        return "HappyDays";
    }
}

 

Some fields, you might have to change by yourself, but this is what I use, and it works fine.

Remember that the file needs to be in OGG format!

 

Still not working

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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • 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;     }  
  • Topics

×
×
  • Create New...

Important Information

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