Posted June 26, 20169 yr Problem: New sounds don't get registered. package registry; import core.ModBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraftforge.fml.common.registry.GameRegistry; public class SoundRegistry { public static SoundEvent record_flute1; public static SoundEvent record_flute2; public static void registerSounds () { record_flute1 = registerSound( "record.flute1" ); record_flute2 = registerSound( "record.flute2" ); } private static SoundEvent registerSound ( String soundName ) { ResourceLocation res = new ResourceLocation ( ModBase.ID , soundName ); return GameRegistry.register( new SoundEvent( res ).setRegistryName( res ) ); } } package item; import handler.SoundHandler; import net.minecraft.client.Minecraft; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; import registry.SoundRegistry; public class ItemPanFlute extends ItemBase { public ItemPanFlute () { super( "pan_flute" , false ); this.setCreativeTab( CreativeTabs.tabTools ); this.setMaxStackSize( 1 ); this.setMaxDamage( 500 ); } @Override public ActionResult < ItemStack > onItemRightClick ( ItemStack itemstack , World world , EntityPlayer player , EnumHand hand ) { try { if ( itemstack.getTagCompound().hasNoTags() || ( world.getTotalWorldTime() - itemstack.getTagCompound().getLong( "world_time" ) ) >= 5 ) { if ( !world.isRemote ) { float rotationPitch = ( ( - ( player.rotationPitch ) ) / 360 ); float soundPitch = ( float ) ( rotationPitch + 1.375 ); if ( !player.isSneaking() ) { SoundHandler.playSoundInRadius( player , 25 , SoundRegistry.record_flute1 , ( float ) 0.5 , soundPitch ); } else { SoundHandler.playSoundInRadius( player , 25 , SoundRegistry.record_flute2 , ( float ) 0.5 , soundPitch ); } itemstack.getTagCompound().setLong( "world_time" , world.getTotalWorldTime() ); itemstack.damageItem( 1 , player ); } } } catch ( Exception ex ) {} return super.onItemRightClick( itemstack , world , player , hand ); } @Override public void onUpdate ( ItemStack itemstack , World world , Entity entity , int metadata , boolean bool ) { if ( itemstack.getTagCompound() == null ) { itemstack.setTagCompound( new NBTTagCompound() ); } } } { "record.flute1": { "category": "record", "sounds": [ { "name": "betterlife:flute1", "stream": true } ] } , "record.flute2": { "category": "record", "sounds": [ { "name": "betterlife:flute2", "stream": true } ] } } As you can see in the 2nd code snippet: When the player sneaks and right clicks the item, the 2nd sound should be played. But this doesn't work. *Hug*
June 26, 20169 yr Are you sure that registerSounds() is being called in the proxies? Forgetting to actually call registration methods has tripped me up before in the past. Colore - The mod that adds monochrome blocks in every color of the rainbow! http://www.minecraftforge.net/forum/index.php?topic=35149 If you're looking to learn how to make mods for 1.9.4, I wrote a helpful article with links to a lot of useful resources for learning Minecraft 1.9.4 modding! http://supergeniuszeb.com/mods/a-helpful-list-of-minecraft-1-9-4-modding-resources/
June 27, 20169 yr Author The method gets called. Scenario: I've got my flute. When I'm not sneaking and press the item it will play record_flute1 but when I'm sneaking and press the item, it should play record_flute2. When I'm not sneaking it will play the sound and when I'm sneaking it will not. I already copied record_flute1 and named it record_flute2 so that I have both files BUT they are the same. Then I tested again and realized that I actually just plays record_flute1 but not record_flute2. The base problem is commensurately that just the record_flute1 can be played. *Hug*
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.