Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.14.4] Is it possible to create potions?


jiggish
 Share

Recommended Posts

I've just started trying to code for minecraft, having very little experience with Java, I decided my first try and learn would be to create a mod with a bunch of custom potions for the game, with new effects and everything, so I started following tutorials from zero, and reading all the documentation I could find, guiding my way into learning, but being completely unable to find anything that could teach how to create potions for 1.14.4.

All the guides are outdated, even the topics on this forum all refer to 1.12.2/prior. There's no PotionType class, even the main Potion class is completely different, and the registry-thing deny any of my tries into inserting new potions or new effects into the game. Doing some more research, I found no mods online with new potions for 1.14.4.

Is it even possible to create new potions with new effects? And how to?

Link to comment
Share on other sites

1 minute ago, jiggish said:

Is it even possible to create new potions with new effects?

Yes.

Effects are handled by the Effect class. An effect is something like "slowness" or "jump boost" (you can see a list in the Effects class). You usually need to make your own subclass to achieve a custom effect. For actually performing the effect we need to distinguish between instant and non-instant effects.

For instant effects (Effect#isInstant returns true) Effect#affectEntity will be called to perform the instant effect.

For non-instant effects Effect#isReady(remainingDuration, amplifier) will be called every tick while the effect is active on an entity. If it returns true, Effect#peformEffect will also be called that tick.

 

Potions are handled by the Potion class. A potion is something like "slowness", "long slowness" or "strong slowness", or, more abstractly, a Potion is a combination of zero or more effect instances. An EffectInstance is a combination of an Effect with a duration and an amplifier.

 

Both Effect and Potion are forge registry entries and are registered as described in the documentation.

  • Thanks 2
Link to comment
Share on other sites

Every time I try to construct a new Effect I get "The constructor Effect(EffectType, int) is not visible".
I'm trying to register a new Effect as I would with anything else, following what I believe is the default procedure.

 

@SubscribeEvent
public static void registerEffects(final RegistryEvent.Register<Effect> event) {			
  event.getRegistry().registerAll(
    EffectList.EFFECT_TEST = new Effect(null, 0).setRegistryName(location("effect_test"))
  );
  logger.info("Potions registered.");
}

 

and about "EffectList..."

public class EffectList {
	public static Effect EFFECT_TEST;
}


Even trying many others way (which I believe are all wrong) I'm still not able to use the constructor.
What else should I be doing?

Link to comment
Share on other sites

12 hours ago, jiggish said:

Every time I try to construct a new Effect I get "The constructor Effect(EffectType, int) is not visible".

The constructor in the Effect class is protected. Please learn basic Java if you don't know what this means or how to work around it.

 

12 hours ago, jiggish said:

new Effect(null, 0)

Using null here is not allowed and makes no sense.

 

12 hours ago, jiggish said:

logger.info("Potions registered.");

Why is this at info level? Even debug would be too much. Nobody needs this in the log file.

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.

Guest
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.