Jump to content

Using onEntityCollidedWithBlock to add a potion effect to a liquid isn't working


Recommended Posts

Posted

Hello everyone!

I'm trying to use onEntityCollidedWithBlock to add a potion effect to an entity while the entity is swimming in the liquid but it isn't working. I have no idea why it isn't working as I have followed multiple tutorials. My liquid is instantiated right so I don't think that that is the problem.

 

This is the code for the fluid of my liquid in the class FluidCorrosiveAcid:

package com.leonardude.zether.liquids;

import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;

public class FluidCorrosiveAcid extends Fluid {

public FluidCorrosiveAcid() {
	super("fluidCorrosiveAcid");
	this.setDensity(10);
	this.setViscosity(1000);
	FluidRegistry.registerFluid(this);
}

}

 

And this is the code for the block of my liquid in the class BlockCorrosiveAcid:

package com.leonardude.zether.liquids;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;

import com.leonardude.zether.main.Zether;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockCorrosiveAcid extends BlockFluidClassic {

public BlockCorrosiveAcid(int id) {
	super(id, Zether.fluidCorrosiveAcid, Material.water);
	this.setCreativeTab(CreativeTabs.tabBlock);
	Zether.fluidCorrosiveAcid.setBlockID(id);
}

@Override
public void onEntityCollidedWithBlock( World world, int x, int y, int z, Entity entity ) {
	if (entity instanceof EntityLiving) {
		((EntityLiving)entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 1));
	}
}

@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta) {
	return Block.waterMoving.getIcon(side, meta);
}

@Override
public int colorMultiplier(IBlockAccess iblockaccess, int x, int y, int z) {
	return 0x66FF00;
}

}

 

Please help as I have no idea what I am doing wrong! Thanks in advance!

 

;D ;D ;D ;D

Leonardude

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.

Announcements



×
×
  • Create New...

Important Information

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