Jump to content

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


UM3 F0R TH3 W1N

Recommended Posts

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
Link to comment
Share on other sites

Just now, 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.

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.

Link to comment
Share on other sites

Just now, UM3 F0R TH3 W1N said:

how much what do I know/have

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.

Link to comment
Share on other sites

Just now, 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

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.

Link to comment
Share on other sites

4 minutes ago, Animefan8888 said:
4 minutes ago, Animefan8888 said:

so you need to generate a psuedo-random number with the Random class that has a maximum of the lists length. 

im quite new to arrays, so I have no clue what this means, but I do kno how to get the item out of the array.yes

 

Edited by UM3 F0R TH3 W1N
Link to comment
Share on other sites

1 minute ago, UM3 F0R TH3 W1N said:

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

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.

Link to comment
Share on other sites

Just now, 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

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.

Link to comment
Share on other sites

1 minute ago, UM3 F0R TH3 W1N said:

image.png.6f6dd66d1aea14f08c5d7185b996cd31.pngso what do I put for soundIn

A SoundEvent that you have to make.

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.

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.

Announcements



×
×
  • Create New...

Important Information

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