UM3 F0R TH3 W1N Posted August 5, 2018 Posted August 5, 2018 (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 August 5, 2018 by UM3 F0R TH3 W1N Quote
Animefan8888 Posted August 5, 2018 Posted August 5, 2018 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. Quote 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.
UM3 F0R TH3 W1N Posted August 5, 2018 Author Posted August 5, 2018 On 8/5/2018 at 12:30 AM, Animefan8888 said: How much do you know/have. Expand how much what do I know/have Quote
Animefan8888 Posted August 5, 2018 Posted August 5, 2018 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? Quote 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.
UM3 F0R TH3 W1N Posted August 5, 2018 Author Posted August 5, 2018 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 Quote
Animefan8888 Posted August 5, 2018 Posted August 5, 2018 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. Quote 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.
UM3 F0R TH3 W1N Posted August 5, 2018 Author Posted August 5, 2018 (edited) On 8/5/2018 at 12:37 AM, Animefan8888 said: On 8/5/2018 at 12:37 AM, Animefan8888 said: so you need to generate a psuedo-random number with the Random class that has a maximum of the lists length. Expand 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 Expand Edited August 5, 2018 by UM3 F0R TH3 W1N Quote
Animefan8888 Posted August 5, 2018 Posted August 5, 2018 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 Quote 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.
UM3 F0R TH3 W1N Posted August 5, 2018 Author Posted August 5, 2018 On 8/5/2018 at 12:43 AM, Animefan8888 said: Create a new Random call nextInt(listLength) and then pass the int returned from that into the get method of List/ArrayList Expand how? is this right? I assume that's wrong, as I said, im very unexperienced with this Quote
Animefan8888 Posted August 5, 2018 Posted August 5, 2018 On 8/5/2018 at 12:49 AM, UM3 F0R TH3 W1N said: how? is this right? 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. Quote 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.
UM3 F0R TH3 W1N Posted August 5, 2018 Author Posted August 5, 2018 On 8/5/2018 at 12:50 AM, Animefan8888 said: pass it into the get method on your list that has the Sounds in it. Expand so what do I put for soundIn Quote
Big_Bad_E Posted August 5, 2018 Posted August 5, 2018 On 8/5/2018 at 12:55 AM, UM3 F0R TH3 W1N said: so what do I put for soundIn Expand The sound. Quote
Animefan8888 Posted August 5, 2018 Posted August 5, 2018 On 8/5/2018 at 12:55 AM, UM3 F0R TH3 W1N said: so what do I put for soundIn Expand A SoundEvent that you have to make. Quote 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.
UM3 F0R TH3 W1N Posted August 5, 2018 Author Posted August 5, 2018 On 8/5/2018 at 12:57 AM, Animefan8888 said: A SoundEvent that you have to make. Expand but I want it to be the random sound... Quote
Recommended Posts
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.