• 1

    posted a message on [Creating Mods] Potions (MCP) [13/10/10]
    First time posting anything, however I thought I could post some tutorials of mods I have been working on using the mod creator pack.

    *Note It's mostly just code I am no good at the whole artistic stuff so I just reuse textures*

    Let's Start with potions (they have endless possibilities and are extremely awesome)!

    first let's create a base class to use, we will call it "EntityPotion.java". This will be an abstract class, more of a way to design future potions.

    Inside this class we have:

    package net.minecraft.src;
    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3) braces deadcode 
    import java.util.Random;
    public abstract class EntityPotion extends Entity
    	public World world;
    	public EntityPlayer entityplayer;
    	public long timeOfEffect = 0L;
        public EntityPotion(World world, EntityPlayer entityplayer){
    		this.world = world;
    		this.entityplayer = entityplayer;
    	public EntityPotion(World world){
    		this.world = world;
    	public abstract boolean applyEffects();
    	public abstract boolean removeEffects();
    	public abstract void func_370_e_();
        public void readEntityFromNBT(NBTTagCompound nbttagcompound){
        public void writeEntityToNBT(NBTTagCompound nbttagcompound){

    We make this an entity (extends entity) because this will be the effect the potion has and not the actual item itself.

    Global Variables:
    World world: the world variable, this will allow us access to the world class and many functions
    EntityPlayer: This is the player, this will allow us to access variables and methods relating to the player
    timeOfEffect: This will be how long the effect should last

    We have to constructors, which should be fairly straightforward.
    public entity(World world)
    should be used when we don't care about the player itself.

    We have 3 abstract methods (These have to be implemented in any potion that extends this class)
    applyEffect(): This is where the effect of the potion will be applied

    removeEffect(): This is where any effects from the potions should be removed when the duration of the potion has been exceeded

    func_370_e_(): A little arbitrary in terms of what it does, however this is where any updates are taken place. Every tick of the game this method will be called (we are overloading from the entity class), if you were to look at other entities you would notice that stuff to deal with motion would belong in this method. Thus we will use this to time the effect of the potion as well update anything in special cases.

    The last two methods in this class are overloaded from the entity class as they are abstract, however I am not entirely sure as to how they work (all I know is it's for saving and I don't know how to deal with it if anyone knows let me know!)

    Next Thread Will be how to create the invincibility potion
    Posted in: Tutorials
  • To post a comment, please or register a new account.