Jump to content

[1.6] Setting AoE potion damage to blocks


Recommended Posts

I am making a block of uranium as part of the mod I am making mainly as a testing project to see how well I can return to Minecraft modding. So far I have made it able to swirl with particles just fine, but getting it to grant potion effects is troubling me.


It does give me the poison effect at a correct chance, but only visually. My hearts turn green, particles appear, the status effect appears in my HUD, but it does not actually decrease my health like a potion or cave spider bite does, and when it reaches 0:00, does not disappear. I suspect that somehow it is only applying on the client side, even though updateTick is server side? What am I doing wrong?


public void updateTick(World par1World, int par2, int par3, int par4, Random random)
    	if(!par1World.isRemote) //added this and still no luck
    	AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)par2, (double)par3, (double)par4, (double)(par2 + 1), (double)(par3 + 1), (double)(par4 + 1)).expand(4, 4, 4);
        List list = par1World.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); //tried EntityPlayer.class too, same problem
        Iterator iterator = list.iterator();
        EntityLivingBase entityalive;

        while (iterator.hasNext())
            entityalive = (EntityLivingBase)iterator.next();
            if(random.nextInt(128) == 1)
            	entityalive.addPotionEffect(new PotionEffect(19, 200, 1));


EDIT: After commenting out the isRemote part, it seems to work _sometimes._ I suspect that the random value is not the same on client and server and thus the poison effect will not work unless both happen to strike at the same time. I've tried using world.rand, I've tried making a new random with world.getWorldTime() as the seed. Is there any way to fix this without having to remove the randomness entirely?

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.

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.