I created a custom mob Bee using Techne. I've got the custom model in the game, with the correct texture. First, I want the wings to be animated CONSTANTLY. Currently, they only move when the Bee moves.
Second, I want to have custom sounds for this mob. I have the sounds, in the correct folder, but I've been unable to find code that shows how to load the random sounds.
Also, so far, he's not dropping anything but XP when I kill him - I have a .json file that should create the loot, but it doesn't seem to work.
I don't know much about loot tables (yet) and animation, but I will be able to help you out with sound.
You're trying to play random sounds? That is not done from the code, but rather from the sounds.json. For each sound you can specify multiple files and they will be chosen randomly when played afaik.
Yes, I'd like random sounds for the hurt sound and "say" (or "meow" or "moo") sounds, and one for the ambient and one for the death. The code I currently have is:
public class Custom_Sounds
{
public static final SoundEvent ENTITY_BEE_AMBIENT;
public static final SoundEvent ENTITY_BEE_DEATH;
public static final SoundEvent ENTITY_BEE_HURT;
public static final SoundEvent ENTITY_BEE_STEP;
private static SoundEvent getRegisteredSoundEvent(String id)
{
SoundEvent soundevent = SoundEvent.REGISTRY.getObject(new ResourceLocation(id));
if (soundevent == null)
{
throw new IllegalStateException("Invalid Sound requested: " + id);
}
else
{
return soundevent;
}
}
static
{
if (!Bootstrap.isRegistered())
{
throw new RuntimeException("Accessed Sounds before Bootstrap!");
}
else
{
ENTITY_BEE_AMBIENT = getRegisteredSoundEvent("entity.bee.say1");
ENTITY_BEE_DEATH = getRegisteredSoundEvent("entity.bee.death");
ENTITY_BEE_HURT = getRegisteredSoundEvent("entity.bee.hurt1");
ENTITY_BEE_STEP = getRegisteredSoundEvent("entity.bee.step1");
}
}
}
This was based in part on what's going on with the code in the Zombie class, plus an older tutorial online. The main problem at the moment is that the game crashes (Invalid Sound requested: entity.bee.say1). I'm sure I need a .json file, but don't know the structure for it, nor where to put it, so that the game will choose the right sound for the singletons, and the random sounds for the hurt/ambient sounds. Any help is appreciated.
Not sure how you event started doing sounds without creating any jsons. Sounds json format has been around since 1.6/1.7.
All your sounds have to be listed in a sounds.json. First google search result returns this page about the structure (implying how easy it is to find). You could've looked at how vanilla handles sound jsons or at least a tutorial first...
All the tutorials I could find were really, really old. The newest one used commands that had been replace. I was looking for .json files in the vanilla, but couldn't find where they were. I have FINALLY found the vanilla file for sounds (it wasn't called sounds.json, but rather 1.12.json. Here's what I have:
The question is: Where do I put this file? Does the program automatically choose between the various hurt or say files? How do I create the hash for it? Size is self-explanatory; I'll have to change that once I have my actual sound files. I'm currently just using the sounds from the cow.
Do you know where the minecraft assets are stored? They are stored in .minecraft/versions/{yourversion}/{yourversion}.jar. If you look inside (with winrar) you should find everything you need.
Also, I don't think anything has changed about sound jsons since 1.7 so it doesn't matter if the tutorials are old.
This is taken from the .minecraft/assets/indexes/1.12.json file. I've looked EVERYWHERE in the 1.12.jar, and there is NO file called sound or sounds.json. The only .json files seem to be for textures & loot.
However: The file .minecraft/assets/indexes/1.12.json contains the hashed version of the original sounds, which are located in .minecraft/assets/objects. If you rename the file to a .ogg, you get the sound file. I HAVE the sound files - and I have the above .json. I just don't know where to put MY .json, or if it's even the right format.
The primary problem is that I can't find a sounds.json file to look at, and I don't know where to put it once I've found it.
Right, I'm very sorry, I forgot the sounds weren't stored in the that jar. It's actually done differently to what is in the file you found (at least for mods). You could take a look at how resource packs do their sounds (because mod assets are basically resource packs, you could probably have your mod use a resource pack only). Or I could just show you some examples from my mod (if you actually find them useful this time).
Also, just realized that the page I linked actually describes everything from where to place the file to the structure and even examples. So please take a closer look to what I link next time.
Also, the way you're registering sounds is a bit weird to me, but I'm not sure if it's different with mobs and I have no time to check rn.
I looked at that page again. It doesn't really give you "examples," per se (i.e., a complete file), nor does it really tell you where to put the file (unless you're doing a resource pack). I want to do it without the resource pack, if possible. I looked at your sounds.json, and came up with this:
However, I'm getting a crash: nvalid Sound requested: entity.bee.ambient. Maybe it's how I'm registering the sounds; maybe its the format of the .json. I just don't know. I'm still searching for other code examples, to see if I can get a better idea of what I'm doing wrong. I have this file located at main/resources/newmod/sounds.json ... which is where you had your sounds.json located. I have no idea what I'm doing wrong... yet.
Do you know how to navigate github? You can easily see where the file is located and where the sound files themselves are located. As I said, I don't have much time on my hands so I'll be able to help better you later. Have you read the wiki page as well? It provides in-depth information about this.
At a first glance I already see some issues:
1. you're trying to play entity.bee.ambient, however in the json the sound's name is just ambient.
2. Make sure the names inside "sounds" match with their files exactly.
3. You did a horrible job at copying my json or analyzing the wiki page. It's quite clear that in you need to specify the name of the sound by setting the "name" variable to your sound's name. I'm not sure what you wanted to accomplish by inventing your own variables (which obviously won't be used by the game) like "say": "ambient", "death": "death", etc.
Why is it that you fail to analyze something on your own. I keep giving you perfectly working repositories of code and useful links, but you just seem to ignore them. This isn't the first time this happens as well. I'm quite tired of breaking down every single detail for your just because you ignored the links I've given you. Sorry for my small rant.
I took another look at both the github and the wiki. The wiki didn't add much to my knowledge. I've read it four times now, but still am not sure what I'm doing wrong.
the file 'say1.ogg' is located in sounds/mob/bee ... I believe this should be correct. The code still says 'Invalid Sound requested: entity.bee.ambient.' The file is located correctly, afaik. It's formatted correctly. I'm just not getting from A to B. I'm missing something simple here, but I can't see the forest for the trees.
Well the json looks correct. I think the problem might be caused by the way your register your sounds. I'll show you how I usually register sounds. Try something similar to my code and see if it works.
I also used your code, virtually unchanged, to register the sounds. The main question is: Where are you calling your registerSounds from? It can't be from any of the proxies, as they use FMLInitializationEvents, not Events. The game doesn't crash, but neither does it play any sounds for the mob. I'm SOOOO close!!
I also used your code, virtually unchanged, to register the sounds. The main question is: Where are you calling your registerSounds from? It can't be from any of the proxies, as they use FMLInitializationEvents, not Events. The game doesn't crash, but neither does it play any sounds for the mob. I'm SOOOO close!!
The code Melonslise linked uses registry events. It looks like they have a separate class subscribing to the event and calling the SoundList.register(RegistryEvent.Register<SoundEvent>) method, but that's not necessary; the SoundList class could subscribe to the event itself.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
The code Melonslise linked uses registry events. It looks like they have a separate class subscribing to the event and calling the SoundList.register(RegistryEvent.Register<SoundEvent>) method, but that's not necessary; the SoundList class could subscribe to the event itself.
I know that, however I like to keep all my registry events in one class and the registry entries in separate classes (not even sure why. OCD? Convenience?).
I also used your code, virtually unchanged, to register the sounds. The main question is: Where are you calling your registerSounds from? It can't be from any of the proxies, as they use FMLInitializationEvents, not Events. The game doesn't crash, but neither does it play any sounds for the mob. I'm SOOOO close!!
Make sure the registry names of the sound events match the sounds' names in your json.
Show how you play your sounds and how you register them. Also show your console log.
Not sure how the tutorial you found is any better.
EDIT: Your json appears to have an error. I usually use this site to check my jsons.
EDIT: You don't appear to understand what registry events are. Any method that is subscribed to a registry event will be called automatically by forge for a specified entry (items, blocks, sounds, etc). It's recommended to use registry events rather than GameRegistry because it removes a lot of hassle, possible errors and makes the code cleaner, prettier and overall better.
Tutorial: Better, in that a). It showed the format of the sounds.json (with multiple choices for sounds, rather than singletons), and b). I understand more of what I'm doing now. I *DID* forget the {}'s in the code, which is my own fault.
I do understand registry events; I have a RegistryHandler class where I take care of most of (if not all) of that; that's where I put the registerSounds event. What I'm NOT sure of, however, is if the @SubscribeEvent makes the function call automatically, rather than having to specify it, say, in one of the proxies. The problem is this: I've been shown two different (and conflicting) ways to get things going - and haven't quite figured out which one is "right." Both methods work.
Your post to choonster about RegistryEvents was very enlightening; I'm looking at that some more. I'm sure I'll learn something more from his code. In the mean time, between adding @Mod.EventBusSubscriber to my RegistryHandler class and fixing the errors in the sounds.json, my mob now has sounds. Hurray!
So all that's left is to figure out the animation part. The creature animates while moving; it's just that I want it CONSTANTLY animating (at least one part, that is).
I'll explain events a little more. @Mod.EventBusSubscriber registers your class as an event handler within forge, it's the same as MinecraftForge.EVENT_BUS.register. @SubscribeEvent marks your method as an event and the method will be ran when the event is fired. I like using this way more since it's self-contained and much cleaner.
Also, get used to registry events because 1.12 no longer has GameRegistry.
As I said, I won't be able to help you with anything else. I've always had problems with animations and the sort.
EDIT: You could always look at how other mods achieve what you want. I do that often. Most mods are hosted on github.
I created a custom mob Bee using Techne. I've got the custom model in the game, with the correct texture. First, I want the wings to be animated CONSTANTLY. Currently, they only move when the Bee moves.
Second, I want to have custom sounds for this mob. I have the sounds, in the correct folder, but I've been unable to find code that shows how to load the random sounds.
Also, so far, he's not dropping anything but XP when I kill him - I have a .json file that should create the loot, but it doesn't seem to work.
Any help is appreciated.
I don't know much about loot tables (yet) and animation, but I will be able to help you out with sound.
You're trying to play random sounds? That is not done from the code, but rather from the sounds.json. For each sound you can specify multiple files and they will be chosen randomly when played afaik.
Yes, I'd like random sounds for the hurt sound and "say" (or "meow" or "moo") sounds, and one for the ambient and one for the death. The code I currently have is:
... and my Custom_Sounds:
This was based in part on what's going on with the code in the Zombie class, plus an older tutorial online. The main problem at the moment is that the game crashes (Invalid Sound requested: entity.bee.say1). I'm sure I need a .json file, but don't know the structure for it, nor where to put it, so that the game will choose the right sound for the singletons, and the random sounds for the hurt/ambient sounds. Any help is appreciated.
Not sure how you event started doing sounds without creating any jsons. Sounds json format has been around since 1.6/1.7.
All your sounds have to be listed in a sounds.json. First google search result returns this page about the structure (implying how easy it is to find). You could've looked at how vanilla handles sound jsons or at least a tutorial first...
All the tutorials I could find were really, really old. The newest one used commands that had been replace. I was looking for .json files in the vanilla, but couldn't find where they were. I have FINALLY found the vanilla file for sounds (it wasn't called sounds.json, but rather 1.12.json. Here's what I have:
The question is: Where do I put this file? Does the program automatically choose between the various hurt or say files? How do I create the hash for it? Size is self-explanatory; I'll have to change that once I have my actual sound files. I'm currently just using the sounds from the cow.
I have no idea where you found this file.
Do you know where the minecraft assets are stored? They are stored in .minecraft/versions/{yourversion}/{yourversion}.jar. If you look inside (with winrar) you should find everything you need.
Also, I don't think anything has changed about sound jsons since 1.7 so it doesn't matter if the tutorials are old.
This is taken from the .minecraft/assets/indexes/1.12.json file. I've looked EVERYWHERE in the 1.12.jar, and there is NO file called sound or sounds.json. The only .json files seem to be for textures & loot.
However: The file .minecraft/assets/indexes/1.12.json contains the hashed version of the original sounds, which are located in .minecraft/assets/objects. If you rename the file to a .ogg, you get the sound file. I HAVE the sound files - and I have the above .json. I just don't know where to put MY .json, or if it's even the right format.
The primary problem is that I can't find a sounds.json file to look at, and I don't know where to put it once I've found it.
Right, I'm very sorry, I forgot the sounds weren't stored in the that jar. It's actually done differently to what is in the file you found (at least for mods). You could take a look at how resource packs do their sounds (because mod assets are basically resource packs, you could probably have your mod use a resource pack only). Or I could just show you some examples from my mod (if you actually find them useful this time).
Here's an example of a sounds json from my mod. If you want more features/customization for your sounds then take a look at this page I linked earlier.
Also, just realized that the page I linked actually describes everything from where to place the file to the structure and even examples. So please take a closer look to what I link next time.
Also, the way you're registering sounds is a bit weird to me, but I'm not sure if it's different with mobs and I have no time to check rn.
I looked at that page again. It doesn't really give you "examples," per se (i.e., a complete file), nor does it really tell you where to put the file (unless you're doing a resource pack). I want to do it without the resource pack, if possible. I looked at your sounds.json, and came up with this:
However, I'm getting a crash: nvalid Sound requested: entity.bee.ambient. Maybe it's how I'm registering the sounds; maybe its the format of the .json. I just don't know. I'm still searching for other code examples, to see if I can get a better idea of what I'm doing wrong. I have this file located at main/resources/newmod/sounds.json ... which is where you had your sounds.json located. I have no idea what I'm doing wrong... yet.
Do you know how to navigate github? You can easily see where the file is located and where the sound files themselves are located. As I said, I don't have much time on my hands so I'll be able to help better you later. Have you read the wiki page as well? It provides in-depth information about this.
At a first glance I already see some issues:
1. you're trying to play entity.bee.ambient, however in the json the sound's name is just ambient.
2. Make sure the names inside "sounds" match with their files exactly.
3. You did a horrible job at copying my json or analyzing the wiki page. It's quite clear that in you need to specify the name of the sound by setting the "name" variable to your sound's name. I'm not sure what you wanted to accomplish by inventing your own variables (which obviously won't be used by the game) like "say": "ambient", "death": "death", etc.
Why is it that you fail to analyze something on your own. I keep giving you perfectly working repositories of code and useful links, but you just seem to ignore them. This isn't the first time this happens as well. I'm quite tired of breaking down every single detail for your just because you ignored the links I've given you. Sorry for my small rant.
I took another look at both the github and the wiki. The wiki didn't add much to my knowledge. I've read it four times now, but still am not sure what I'm doing wrong.
I did rewrite the sounds.json:
the file 'say1.ogg' is located in sounds/mob/bee ... I believe this should be correct. The code still says 'Invalid Sound requested: entity.bee.ambient.' The file is located correctly, afaik. It's formatted correctly. I'm just not getting from A to B. I'm missing something simple here, but I can't see the forest for the trees.
Well the json looks correct. I think the problem might be caused by the way your register your sounds. I'll show you how I usually register sounds. Try something similar to my code and see if it works.
Here's the registry event handler.
Here's where all the sounds are kept and registered.
EDIT: It's usually better not to use/rely on vanilla code since it's usually either hard-coded or straight up bad. It's better to use forge's systems.
Ok, I found a tutorial which gave an even BETTER example of the sounds.json. I've rewritten mine like this:
I also used your code, virtually unchanged, to register the sounds. The main question is: Where are you calling your registerSounds from? It can't be from any of the proxies, as they use FMLInitializationEvents, not Events. The game doesn't crash, but neither does it play any sounds for the mob. I'm SOOOO close!!
The code Melonslise linked uses registry events. It looks like they have a separate class subscribing to the event and calling the SoundList.register(RegistryEvent.Register<SoundEvent>) method, but that's not necessary; the SoundList class could subscribe to the event itself.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I know that, however I like to keep all my registry events in one class and the registry entries in separate classes (not even sure why. OCD? Convenience?).
Make sure the registry names of the sound events match the sounds' names in your json.
Show how you play your sounds and how you register them. Also show your console log.
Not sure how the tutorial you found is any better.
EDIT: Your json appears to have an error. I usually use this site to check my jsons.
EDIT: You don't appear to understand what registry events are. Any method that is subscribed to a registry event will be called automatically by forge for a specified entry (items, blocks, sounds, etc). It's recommended to use registry events rather than GameRegistry because it removes a lot of hassle, possible errors and makes the code cleaner, prettier and overall better.
Tutorial: Better, in that a). It showed the format of the sounds.json (with multiple choices for sounds, rather than singletons), and b). I understand more of what I'm doing now. I *DID* forget the {}'s in the code, which is my own fault.
I do understand registry events; I have a RegistryHandler class where I take care of most of (if not all) of that; that's where I put the registerSounds event. What I'm NOT sure of, however, is if the @SubscribeEvent makes the function call automatically, rather than having to specify it, say, in one of the proxies. The problem is this: I've been shown two different (and conflicting) ways to get things going - and haven't quite figured out which one is "right." Both methods work.
Your post to choonster about RegistryEvents was very enlightening; I'm looking at that some more. I'm sure I'll learn something more from his code. In the mean time, between adding @Mod.EventBusSubscriber to my RegistryHandler class and fixing the errors in the sounds.json, my mob now has sounds. Hurray!
So all that's left is to figure out the animation part. The creature animates while moving; it's just that I want it CONSTANTLY animating (at least one part, that is).
I'll explain events a little more. @Mod.EventBusSubscriber registers your class as an event handler within forge, it's the same as MinecraftForge.EVENT_BUS.register. @SubscribeEvent marks your method as an event and the method will be ran when the event is fired. I like using this way more since it's self-contained and much cleaner.
Also, get used to registry events because 1.12 no longer has GameRegistry.
As I said, I won't be able to help you with anything else. I've always had problems with animations and the sort.
EDIT: You could always look at how other mods achieve what you want. I do that often. Most mods are hosted on github.
Thank you. I'm already searching for custom mobs on github, to see if any do constant animation.
Still needing help on this...