Jump to content

[1.8] Custom Potion Effects


Tudedude

Recommended Posts

To be 100% honest, all of it lol. I've looked at the source, and it looks like the methods are protected, and all of the other methods I've found in tutorials haven't worked. Upon loading the client, it gives an NPE, pointing to my Potion object.

Link to comment
Share on other sites

You make a class that extends Potion.

Which part of the Potion class do you not understand?

Following this method: http://www.minecraftforum.net/forums/archive/tutorials/931752-forge-creating-custom-potion-effects

I get an error, saying that the constructor is not found for the super constructor "super(par1, par2, par3); under the main potion constructor ( "public PotionYourmod(int par1, boolean par2, int par3){" ), and to add a ResourceLocation in between par1 and par2. In the Potion class itself, the constructor is only the 3 pars, but it is also protected so it can't be that method, right? Any insight into what might be going on?

Edit - Looking back at that method, wth is the packet *.*; declaration? I've never seen that before, it brings up an error in Eclipse (unrecognized), and I can't find anything about it on Google...

Link to comment
Share on other sites

Seems like your super that you called (the constructor of the class you're extended if you didn't know :P) is not be called correctly perhaps? That's the only time I get an error such as the one you got.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

Seems like your super that you called (the constructor of the class you're extended if you didn't know :P) is not be called correctly perhaps? That's the only time I get an error such as the one you got.

import net.minecraft.potion.Potion;

public class BleedPot extends Potion{

public BleedPot(int par1, boolean par2, int par3) {
	super(par1, null, par2, par3);
}

public Potion setIconIndex(int par1, int par2) {
	super.setIconIndex(par1, par2);
	return this;
}
}

 

It seems to be imported and constructed correctly, at least according to the tutorial. TBH, I don't even know where the constructor it's using is from, because the only constructor in the Potion class is protected, and has 3 arguments, and I haven't imported anything else 0_0

Link to comment
Share on other sites

The tutorial is from 1.7, the code changed a tiny bit.

But honestly, if you have so much trouble with it (you don't even seem to know what protected means...): You need to learn java.

Forgive me, I misunderstood what protected means. I do know a fair bit of Java, but am new to mod development after a long hiatus in which everything changed. I've never really had to use protected in my previous work, but I'll definitely revisit my access stuff. I also understand that the code changed, but the Potion class structure is really hard for me to understand :/ I'm not really sure where it's pulling the constructor from, as the only one I see there is the constructor with three, so am I missing something?

Link to comment
Share on other sites

In 1.7 the constructor takes 3 args. In 1.8 it takes 4.

 

The important methods in Potion are:

- isReady(<ticksLeft>, <amplifier>) - called every tick, if you return true here it will then also call performEffect

- performEffect(<affectedEntity>, <amplifier>) - called every tick if isReady returns true that tick

- affectEntity(<potionEntity>, <potionThrower>, <affectedEntity>, <amplifier>, <distanceMultiplier>) - called for instant potions when they hit

- isInstant - Whether this is a splash potion (affectEntity will be used) or a drinkable potion (isReady + performEffect)

 

This took me longer to write down than to actually find out in my IDE. Learn to search for where methods are called from.

Just realized I was using an old source file. I'm very sorry for wasting your time :(

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.