Jump to content

Recommended Posts

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

Posted

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!

 

Posted

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.

Posted

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

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