Jump to content

[1.10.2] Custom potion effect does not end at zero


DrMeepster

Recommended Posts

I am making a library mod to make making my mods easier and I added a test module including a test potion. When I tested it, the effect continued working even after it ran out of time.

BasicPotion:

Spoiler

package drmeepster.drcorester.potion;

import drmeepster.drcorester.property.PropertyHandler;
import drmeepster.drcorester.util.IBasicObject;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public abstract class BasicPotion extends Potion implements IBasicObject<Potion>{
    
    //copy these
    //public static final String NAME = "";
    //public static final int COLOR = 0x000000;
    
    private ResourceLocation icon;
    private String id;

    protected BasicPotion(boolean isBad, int color, String name, String modid) {
        super(true, color);
        this.setPotionName("effect." + PropertyHandler.getName(modid, name));
        this.setRegistryName(modid, name);
        this.setIconIndex(0, 0);
        icon = new ResourceLocation(modid, "textures/potion/" + name + ".png");
        System.out.println(icon);
        id = name;
    }
    
    @Override
    public boolean isReady(int duration, int amplifier){
        return true;
    }
    
    @Override
    public boolean hasStatusIcon(){
        return false;
    }
    
    @SideOnly(Side.CLIENT)
    @Override
    public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) {
        if (mc.currentScreen != null) {
            mc.getTextureManager().bindTexture(icon);
            Gui.drawModalRectWithCustomSizedTexture(x + 6, y + 7, 0, 0, 18, 18, 18, 18);
        }
    }
    
    @SideOnly(Side.CLIENT)
    @Override
    public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){
        mc.getTextureManager().bindTexture(icon);
        Gui.drawModalRectWithCustomSizedTexture(x + 3, y + 3, 0, 0, 18, 18, 18, 18);
    }
    
    @Override
    public String getId(){
        return id;
    }
    
    /* Copy this:
     * public void performEffect(EntityLivingBase entity, int amplifier){
     */
}

PotionTest:

Spoiler

package drmeepster.drcorester.testing;

import drmeepster.drcorester.ModDrCorester;
import drmeepster.drcorester.potion.BasicPotion;
import net.minecraft.entity.EntityLivingBase;

public class PotionTest extends BasicPotion {

    public static final String NAME = "potion_test";
    public static final int COLOR = 0x000000;
    
    protected PotionTest() {
        super(false, COLOR, NAME, ModDrCorester.MODID);
    }
    
    @Override
    public void performEffect(EntityLivingBase entity, int amplifier){
        entity.setFire(1);
    }
}
 

 

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.