Jump to content

Item that plays song on right-click?


Alanvcd

Recommended Posts

Hi, I need to know how to make an item play a song with noteblock sounds, when you use it (Right click). I also need to know how to make it select a song from a GUI, opened by shift+right clicking with the item. Could anyone help me please?

The flying banana ate my dog.

Link to comment
Share on other sites

Hi, I need to know how to make an item play a song with noteblock sounds, when you use it (Right click).

playing one note: BlockNote.java, method "onBlockEventReceived".  so something like

par1World.playSoundEffect((double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D, "note.harp", 3.0F, var7);

where par2-par4 you would use coordinates of a player (posX..posZ). when item is right-clicked method "onItemRightClick" is triggered, there will be probably part of your code. test for shift - "player.isSneaking()". the music playing would be probably handled in tick handler (of a server?), where it would remember how much ticks passed from start of a song and when it's next note's turn it would call playSoundEffect on a position of a saved player (!more players can play a song at the same time!). [basic item creation: http://www.minecraftforge.net/wiki/Basic_Items]

 

I also need to know how to make it select a song from a GUI, opened by shift+right clicking with the item.

you'll need to learn how to create GUI and how to use custom packets to keep it in sync with server:

http://www.minecraftforge.net/wiki/Containers_and_GUIs

http://www.minecraftforge.net/wiki/Packet_Handling

selected song would be probably saved in ItemStack or just in item damage.

 

this text may not be complete/exact, but it should show you a possible way of doing it (I hope :D).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

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.



×
×
  • Create New...

Important Information

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