Assuming you've created and registered the Potion instances, you then need to create and register a PotionType for each brewable potion. For most vanilla Potions there are one to three PotionTypes: regular (e.g. Regeneration, 0:45) , long (e.g. Regeneration, 1:30) and strong (e.g. Regeneration II, 0:22).
Both Potion and PotionType are implementations of IForgeRegistryEntry, so they should be registered during the appropriate registry events.
Once you've created and registered the Potions and PotionTypes, use PotionHelper.addMix to add the brewing recipes (e.g. Awkward to Regular X, Regular X to Long X and Regular X to Strong X). For more advanced brewing recipes, you can use Forge's BrewingRecipeRegistry.
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.
Sorry, my English is not that advanced. I made little code but it needs some thing.
public class ModPotionTypes extends PotionType{
public static void registerPotionTypes(){
registerPotionType("liquidfire", new PotionType(new PotionEffect[] {new PotionEffect(BetterCraft.LiquidFire, 2)}));
}
}
Don't make your PotionType registration class (ModPotionTypes) extend PotionType or call PotionType.registerPotionType.
Subscribe to RegistryEvent.Register<PotionType>, get the registry from the event with RegistryEvent.Register#getRegistry and register your PotionTypes by calling IForgeRegistry#register or IForgeRegistry#registerAll.
You can see how I create and register my mod's PotionTypes here.
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.
I added some things from your source codes to the mine but it did crash. The crash report says line:56(78 for your code), 43(56) and 38(42) have problems. Can it be a Forge or Minecraft version problem?
I added some things from your source codes to the mine but it did crash. The crash report says line:56(78 for your code), 43(56) and 38(42) have problems. Can it be a Forge or Minecraft version problem?
When asking for help with a crash, always post the FML log (logs/fml-client-latest.log in the game directory) and your code using Gist or Pastebin. It's hard to fix something when you don't know what the problem actually is.
Make sure you apply syntax highlighting to your code when posting it with Gist or Pastebin. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.
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.
You didn't post the class that's causing the crash (ModPotionTypes). Please post this as well as the class where you create and register your Potions and the class that calls it.
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.
A NullPointerException is thrown when you try to call a method on or access a field of a null value. The only value on line 56 of your ModPotionTypes class that could be null is potionName, which means that your Potion's registry name was null.
My code requires that the Potion's registry name has been set before the PotionType is created, but your code doesn't do this.
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.
Set the registry names of your Potion instances when you create them instead of when you register them.
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.
PotionEffect doesn't implement IForgeRegistryEntry, so PotionEffects don't have registry names.
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.
PotionEffect doesn't implement IForgeRegistryEntry, so PotionEffects don't have registry names.
I already set the registry name of my potion. But I don't still get the problem with my mod. Can I PM to you my full source code? Maybe the problem is in an another place.
Where and when? You need to do it before you create the PotionTypes, which you aren't doing.
But I don't still get the problem with my mod. Can I PM to you my full source code? Maybe the problem is in an another place.
Create a Git repository of your code, push it to a site like GitHub and link it here.
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.
Potion implements IForgeRegistryEntry, so you need to register your Potion instances in RegistryEvent.Register<Potion>. You never set the registry names of your Potion instances or register them.
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.
Hi guys! I added 2 effects to the game and I want to make a potion that gives that effects. How can I create that potion?
Assuming you've created and registered the Potion instances, you then need to create and register a PotionType for each brewable potion. For most vanilla Potions there are one to three PotionTypes: regular (e.g. Regeneration, 0:45) , long (e.g. Regeneration, 1:30) and strong (e.g. Regeneration II, 0:22).
Both Potion and PotionType are implementations of IForgeRegistryEntry, so they should be registered during the appropriate registry events.
Once you've created and registered the Potions and PotionTypes, use PotionHelper.addMix to add the brewing recipes (e.g. Awkward to Regular X, Regular X to Long X and Regular X to Strong X). For more advanced brewing recipes, you can use Forge's BrewingRecipeRegistry.
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.
Sorry, my English is not that advanced. I made little code but it needs some thing.
Don't make your PotionType registration class (ModPotionTypes) extend PotionType or call PotionType.registerPotionType.
Subscribe to RegistryEvent.Register<PotionType>, get the registry from the event with RegistryEvent.Register#getRegistry and register your PotionTypes by calling IForgeRegistry#register or IForgeRegistry#registerAll.
You can see how I create and register my mod's PotionTypes here.
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 added some things from your source codes to the mine but it did crash. The crash report says line:56(78 for your code), 43(56) and 38(42) have problems. Can it be a Forge or Minecraft version problem?
When asking for help with a crash, always post the FML log (logs/fml-client-latest.log in the game directory) and your code using Gist or Pastebin. It's hard to fix something when you don't know what the problem actually is.
Make sure you apply syntax highlighting to your code when posting it with Gist or Pastebin. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.
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.
Code:https://pastebin.com/K14r7Vc7
FML log:https://pastebin.com/gVXrPxmL
You didn't post the class that's causing the crash (ModPotionTypes). Please post this as well as the class where you create and register your Potions and the class that calls it.
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.
Oh sorry, I accidentally copy the Reference class.
Real code: https://pastebin.com/uPKEzNvL
A NullPointerException is thrown when you try to call a method on or access a field of a null value. The only value on line 56 of your ModPotionTypes class that could be null is potionName, which means that your Potion's registry name was null.
My code requires that the Potion's registry name has been set before the PotionType is created, but your code doesn't do this.
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.
So, what I need to do?
Set the registry names of your Potion instances when you create them instead of when you register them.
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.
Of my potions or potion effects?
Of your Potion instances.
PotionEffect doesn't implement IForgeRegistryEntry, so PotionEffects don't have registry names.
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 already set the registry name of my potion. But I don't still get the problem with my mod. Can I PM to you my full source code? Maybe the problem is in an another place.
Where and when? You need to do it before you create the PotionTypes, which you aren't doing.
Create a Git repository of your code, push it to a site like GitHub and link it here.
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.
Source Code: https://github.com/Brogolem35/Bettercraft
Potion implements IForgeRegistryEntry, so you need to register your Potion instances in RegistryEvent.Register<Potion>. You never set the registry names of your Potion instances or register them.
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.
Hi, I solved the problems. I made the potion finally! Thanks for your help!