Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Ok so last time I posted, Mazetar helped me out with adding sword sound but.... that was in 1.5 now its 1.6.

I've been trying really hard to add these sounds but this is the only thing I have seen on the inter webs.

sound file

package brenden.viking;

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

public class vikingsound 

{

	@ForgeSubscribe
    public void onSound(SoundLoadEvent event)
    {
        try 
        {
        	event.manager.addSound("attacking.wav");
        	event.manager.addSound("medieval:fireshot2.wav");
        	event.manager.addSound("medieval:fireshot3.wav");
        }
        
        catch (Exception e)
        {
            System.err.println("Fire sounds error");
        }

    }
}

In sword class

    public ItemStack onItemLeftClick(ItemStack ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        if (!par3EntityPlayer.capabilities.isCreativeMode)
        {
            --ItemStack.stackSize;
        }

        par2World.playSoundAtEntity(par3EntityPlayer, "brenden:attacking", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new VikingSword_Entity(par2World, par3EntityPlayer));
        }
     
        return ItemStack;
    } 

I dont know what to do now with this. If anyone could help a noob that would be lovely! thanks a million  ;)

Well this is quite simple.

 

addSound("attacking.wav");
playSoundAtEntity(par3EntityPlayer, "brenden:attacking"

Doesn't match.

  • Author

Well this is quite simple.

 

addSound("attacking.wav");
playSoundAtEntity(par3EntityPlayer, "brenden:attacking"

Doesn't match.

addSound("attacking.wav");
playSoundAtEntity(par3EntityPlayer, "attacking.wav"

doesn't work.

  • Author

Let us see your new code then.

Idk know if im not implementing this right or what, but... :)

 

sword class!

public boolean hitEntity (ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
    {
    	par3EntityLiving.worldObj.playSoundAtEntity(par3EntityLiving, "brenden:attacking", 1.0F, 1.0F);
    {
        par1ItemStack.damageItem(1, par3EntityLiving);
        return true;
    }
}


    
    public ItemStack onItemLeftClick(ItemStack ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        if (!par3EntityPlayer.capabilities.isCreativeMode)
        {
            --ItemStack.stackSize;
        }

        par2World.playSoundAtEntity(par3EntityPlayer, "brenden:attacking", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new VikingSword_Entity(par2World, par3EntityPlayer));
        }
     
        return ItemStack;
    }

 

sound class

 

package brenden.viking;

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

public class vikingsound 

{

	@ForgeSubscribe
    public void onSound(SoundLoadEvent event)
    {
        try 
        {
        	
        	event.manager.addSound("brenden:attacking.wav");
        
        }
        
        catch (Exception e)
        {
            System.err.println("Fire sounds error");
        }

    }
}

 

Thanks for your time!

 

  • Author

Your sound should be placed like this:

mcp/src/minecraft/assets/brenden/sound/attacking.wav

do you think this may be the problem?

par2World.spawnEntityInWorld(new VikingSword_Entity(par2World, par3EntityPlayer));?

No, actually the main problem is that those methods are not used by Minecraft any more:

public boolean hitEntity (ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)

public ItemStack onItemLeftClick(ItemStack ItemStack, World par2World, EntityPlayer par3EntityPlayer)

You have to update them.

If you add @Override above methods, you will get warnings and errors when they are removed/replaced/renamed!

Use @Override above any method which overrides a parents method. then you will at least not encounter this again :)

If you guys dont get it.. then well ya.. try harder...

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.