Posted November 3, 201311 yr 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 Leonardude
November 4, 201311 yr Hi It looks like it should work. Do you know if onEntityCollidedWithBlock is being called or not? (i.e. using breakpoint or System.out.println -?) -TGG
November 4, 201311 yr You are checking for an instance of EntityLiving. Note that the player is only an instance of EntityLivingBase.
November 4, 201311 yr Ha, well-spotted dude! http://greyminecraftcoder.blogspot.com.au/2013/10/the-most-important-minecraft-classes_9.html -TGG
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.