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

hi, I'm making a mod that creates liquid version of the standard potions. When a player wades in a block of potion liquid, they should gain the potion effect. This is not taking place. I don't know why the potion effects don't work. here's my code:

 

package wrink.liquidPotions.fluids;


import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;

public abstract class IBlockPotion extends BlockFluidClassic {

private PotionEffect effect=null;

public IBlockPotion(Fluid fluid, Material material) {
	super(fluid, material);
	setTickRandomly(true);
}

@Override
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
	PotionEffect effect = this.getPotionEffect();
	if(!(effect==null) && entity instanceof EntityLivingBase)
	{
		((EntityLivingBase) entity).addPotionEffect(effect);	
	}
}

private PotionEffect getPotionEffect() {
	return effect;
}

public IBlockPotion setPotionEffect(PotionEffect effect)
{
	Block copy = this;
	this.effect=effect;
	return this;
}

}

 

blockPotionFluidAwkward = new BlockPotionBase(fluidPotionAwkward, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion");
        	blockPotionFluidThick = new BlockPotionBase(fluidPotionThick, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion");
        	blockPotionFluidMundane = new BlockPotionBase(fluidPotionMundane, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion");
        	blockPotionFluidMundane_plus = new BlockPotionBase(fluidPotionMundane_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion");
        	blockPotionFluidBreath = ((IBlockPotion) new BlockPotionBase(fluidPotionBreath, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(13, 0, 1));
        	blockPotionFluidBreath_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionBreath_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(13, 3600, 1));
        	blockPotionFluidFire = ((IBlockPotion) new BlockPotionBase(fluidPotionFire, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(12, 0, 1));
        	blockPotionFluidFire_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionFire_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(12, 3600, 1));
        	blockPotionFluidSlow = ((IBlockPotion) new BlockPotionBase(fluidPotionSlow, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(2, 0, 1));
        	blockPotionFluidSlow_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionSlow_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(2, 1800, 1));
        	blockPotionFluidSwift = ((IBlockPotion) new BlockPotionBase(fluidPotionSwift, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(1, 0, 1));
        	blockPotionFluidSwift_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionSwift_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(1, 3600, 1));
        	blockPotionFluidSwift_II = ((IBlockPotion) new BlockPotionBase(fluidPotionSwift_II, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(1, 0, 2));
        	blockPotionFluidHeal = ((IBlockPotion) new BlockPotionBase(fluidPotionHeal, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(6, 0, 1));
        	blockPotionFluidHeal_II = ((IBlockPotion) new BlockPotionBase(fluidPotionHeal_II, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(6, 0, 2));
        	blockPotionFluidHarm = ((IBlockPotion) new BlockPotionBase(fluidPotionHarm, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(7, 0, 1));
        	blockPotionFluidHarm_II = ((IBlockPotion) new BlockPotionBase(fluidPotionHarm_II, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(7, 0, 2));
        	blockPotionFluidPoison = ((IBlockPotion) new BlockPotionBase(fluidPotionPoison, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(19, 0, 1));
        	blockPotionFluidPoison_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionPoison_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(19, 900, 1));
        	blockPotionFluidPoison_II = ((IBlockPotion) new BlockPotionBase(fluidPotionPoison_II, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(19, 0, 2));
        	blockPotionFluidSee = ((IBlockPotion) new BlockPotionBase(fluidPotionSee, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(16, 0, 1));
        	blockPotionFluidSee_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionSee_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(16, 3600, 1));
        	blockPotionFluidInvis = ((IBlockPotion) new BlockPotionBase(fluidPotionInvis, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(14, 0, 1));
        	blockPotionFluidInvis_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionInvis_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(14, 3600, 1));
        	blockPotionFluidRegen = ((IBlockPotion) new BlockPotionBase(fluidPotionRegen, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(10, 0, 1));
        	blockPotionFluidRegen_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionRegen_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(10, 900, 1));
        	blockPotionFluidRegen_II = ((IBlockPotion) new BlockPotionBase(fluidPotionRegen_II, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(10, 0, 2));
        	blockPotionFluidWeak = ((IBlockPotion) new BlockPotionBase(fluidPotionWeak, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(18, 0, 1));
        	blockPotionFluidWeak_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionWeak_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(18, 1800, 1));
        	blockPotionFluidStrong = ((IBlockPotion) new BlockPotionBase(fluidPotionStrong, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(5, 0, 1));
        	blockPotionFluidStrong_plus = ((IBlockPotion) new BlockPotionBase(fluidPotionStrong_plus, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(5, 3600, 1));
        	blockPotionFluidStrong_II = ((IBlockPotion) new BlockPotionBase(fluidPotionStrong_II, Material.water).setBlockTextureName("liquidPotions" + ":" + "fluidPotion")).setPotionEffect(new PotionEffect(5, 0, 2));
        	
        	bucketPotionAwkward = new ItemBucket(blockPotionFluidAwkward).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionAwkward");
        	bucketPotionThick = new ItemBucket(blockPotionFluidThick).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionThick");
        	bucketPotionMundane = new ItemBucket(blockPotionFluidMundane).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionMundane");
        	bucketPotionMundane_plus = new ItemBucket(blockPotionFluidMundane_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionMundane_plus");
        	bucketPotionBreath = new ItemBucket(blockPotionFluidBreath).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionBreath");
        	bucketPotionBreath_plus = new ItemBucket(blockPotionFluidBreath_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionBreath_plus");
        	bucketPotionFire = new ItemBucket(blockPotionFluidFire).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionFire");
        	bucketPotionFire_plus = new ItemBucket(blockPotionFluidFire_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionFire_plus");
        	bucketPotionSlow = new ItemBucket(blockPotionFluidSlow).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionSlow");
        	bucketPotionSlow_plus = new ItemBucket(blockPotionFluidSlow_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionSlow_plus");
        	bucketPotionSwift = new ItemBucket(blockPotionFluidSwift).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionSwift");
        	bucketPotionSwift_plus = new ItemBucket(blockPotionFluidSwift_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionSwift_plus");
        	bucketPotionSwift_II = new ItemBucket(blockPotionFluidSwift_II).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionSwift_II");
        	bucketPotionHeal = new ItemBucket(blockPotionFluidHeal).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionHeal");
        	bucketPotionHeal_II = new ItemBucket(blockPotionFluidHeal_II).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionHeal_II");
        	bucketPotionHarm = new ItemBucket(blockPotionFluidHarm).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionHarm");
        	bucketPotionHarm_II = new ItemBucket(blockPotionFluidHarm_II).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionHarm_II");
        	bucketPotionPoison = new ItemBucket(blockPotionFluidPoison).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionPoison");
        	bucketPotionPoison_plus = new ItemBucket(blockPotionFluidPoison_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionPoison_plus");
        	bucketPotionPoison_II = new ItemBucket(blockPotionFluidPoison_II).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionPoison_II");
        	bucketPotionSee = new ItemBucket(blockPotionFluidSee).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionSee");
        	bucketPotionSee_plus = new ItemBucket(blockPotionFluidSee_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionSee_plus");
        	bucketPotionInvis = new ItemBucket(blockPotionFluidInvis).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionInvis");
        	bucketPotionInvis_plus = new ItemBucket(blockPotionFluidInvis_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionInvis_plus");
        	bucketPotionRegen = new ItemBucket(blockPotionFluidRegen).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionRegen");
        	bucketPotionRegen_plus = new ItemBucket(blockPotionFluidRegen_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionRegen_plus");
        	bucketPotionRegen_II = new ItemBucket(blockPotionFluidRegen_II).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionRegen_II");
        	bucketPotionWeak = new ItemBucket(blockPotionFluidWeak).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionWeak");
        	bucketPotionWeak_plus = new ItemBucket(blockPotionFluidWeak_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionWeak_plus");
        	bucketPotionStrong = new ItemBucket(blockPotionFluidStrong).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionStrong");
        	bucketPotionStrong_plus = new ItemBucket(blockPotionFluidStrong_plus).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionStrong_plus");
        	bucketPotionStrong_II = new ItemBucket(blockPotionFluidStrong_II).setMaxStackSize(1).setContainerItem(new ItemBucket(Blocks.air)).setCreativeTab(CreativeTabs.tabBrewing).setUnlocalizedName("BucketPotionStrong_II");
        	

  • Author

I'm noticing that when the upon spawning in the world, a player may only be affected by a continuous potion once. thereafter it does nothing

I think you want onEntityCollided, not onEntityWalking. The former is called when an entity passes inside a block, while I assume that the latter is only called when an entity is above it (?). In any case, you can walk inside fluids.

I like to make mods, just like you. Here's one worth checking out

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.