Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);
    }
}
 

 

  • Author

??????? I commented out the line that sets the player on fire and uncommented it and it started working.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.