Jump to content

how to get a sound to play from an array(using onItemRightClick ) - 1.12.2 modding


Recommended Posts

Posted (edited)

So, I am creating a Meme Mod for Minecraft Forge 1.12.2 and decided, to make a item, where if you right click with it, it will play a random meme that I will put in an array. I have the array, and the item class, but I am not sure how I can make it play the random sound from the array. If anyone knows how I can do this, I would be highly appreciated if you could tell me what I have to do. If you could tell me in simple terms, that would be much more helpful but if not, then I will try my best to understand it. Thank You.

Edited by UM3 F0R TH3 W1N
Posted
  On 8/5/2018 at 12:29 AM, UM3 F0R TH3 W1N said:

If you could tell me in simple terms, that would be much more helpful but if not, then I will try my best to understand it. Thank You.

Expand  

How much do you know/have.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 8/5/2018 at 12:31 AM, UM3 F0R TH3 W1N said:

how much what do I know/have

Expand  

How much code for this do you know, have you created the item, have you overrided the method that fires when the item is right clicked, do you know how to play a sound?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 8/5/2018 at 12:35 AM, UM3 F0R TH3 W1N said:

yh ik how to do all of that/have done that all, but I just don't know how to make it choose the random sound from array @Animefan8888

Expand  

List#get(Random#nextInt(List#size()))

Or in simpler terms I assume you know how to get an Item out of a ArrayList, so you need to generate a psuedo-random number with the Random class that has a maximum of the lists length.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 8/5/2018 at 12:41 AM, UM3 F0R TH3 W1N said:

im quite new to arrays, so I have no clue what this means

Expand  

Create a new Random call nextInt(listLength) and then pass the int returned from that into the get method of List/ArrayList

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 8/5/2018 at 12:49 AM, UM3 F0R TH3 W1N said:

how? is this right?

image.png.92f428071012051e20acdd60c691a136.png

I assume that's wrong, as I said, im very unexperienced with this

Expand  

That's partially right, now you just need to pass it into the get method on your list that has the Sounds in it.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.