Jump to content

Recommended Posts

Posted

I am simply wondering what method to override in my item in order to put use the playSoundAtEntity method so I can play a sound when the player holds an item.

Posted

It is called so long as it is in your inventory. But yes, checking if the currently held item is the passed stack will keep it from humming constantly unless it is otherwise in your hand.

Posted

It is NOT only called in the hotbar. I am testing this as we speak with a shield and it constantly updates as long as it is in your inventory, any slot.

 

 

Javadoc:

Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and update it's contents.

Posted

Hey, so in case anyone was looking at this thread and wanted to know the working code I used, here it is:

public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
     if (par5){
          par2World.playSoundAtEntity(par3Entity, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); //"random.bow" just used as a test
     }
}

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.