UM3 F0R TH3 W1N Posted August 5, 2018 Share 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 Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2018 Share Posted August 5, 2018 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. 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. Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted August 5, 2018 Author Share Posted August 5, 2018 Just now, Animefan8888 said: How much do you know/have. how much what do I know/have Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2018 Share Posted August 5, 2018 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? 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. Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted August 5, 2018 Author Share 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 Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2018 Share Posted August 5, 2018 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. 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. Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted August 5, 2018 Author Share Posted August 5, 2018 (edited) 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 August 5, 2018 by UM3 F0R TH3 W1N Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2018 Share Posted August 5, 2018 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 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. Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted August 5, 2018 Author Share Posted August 5, 2018 4 minutes ago, Animefan8888 said: Create a new Random call nextInt(listLength) and then pass the int returned from that into the get method of List/ArrayList how? is this right? I assume that's wrong, as I said, im very unexperienced with this Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2018 Share Posted August 5, 2018 Just now, UM3 F0R TH3 W1N said: how? is this right? 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. 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. Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted August 5, 2018 Author Share Posted August 5, 2018 4 minutes ago, Animefan8888 said: pass it into the get method on your list that has the Sounds in it. so what do I put for soundIn Quote Link to comment Share on other sites More sharing options...
Big_Bad_E Posted August 5, 2018 Share Posted August 5, 2018 1 minute ago, UM3 F0R TH3 W1N said: so what do I put for soundIn The sound. Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2018 Share Posted August 5, 2018 1 minute ago, UM3 F0R TH3 W1N said: so what do I put for soundIn 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. Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted August 5, 2018 Author Share Posted August 5, 2018 9 hours ago, Animefan8888 said: A SoundEvent that you have to make. but I want it to be the random sound... Quote Link to comment Share on other sites More sharing options...
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.