Jump to content

Recommended Posts

Posted

This is my code, and should work fine, it adds the potion effect to the player, but on countdown get 0:00 it keeps the effect, and the countdown also keeps on 0:00

 

@Override
@SuppressWarnings("rawtypes")
public void updateEntity()
{
	super.updateEntity();

	double minX = (float)(this.xCoord - range);
	double minY = (float)(this.yCoord - range);
	double minZ = (float)(this.zCoord - range);
	double maxX = (float)((this.xCoord + 1) + range);
	double maxY = (float)((this.yCoord + 1) + range);
	double maxZ = (float)((this.zCoord + 1) + range);

	List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().getAABB(minX, minY, minZ, maxX, maxY, maxZ));

	if(list.size() != 0)
	{
		for(int i = 0; i < list.size(); ++i)
		{
			EntityPlayer player = (EntityPlayer) list.get(i);

			if(!player.isPotionActive(10))
			{
				player.addPotionEffect(new PotionEffect(10, 400));

			}
		}
	}
}

 

Thanks in advance for helping  :)

Posted

(this MIGHT be the problem): You are checking if the potion is active every time the entity updates, which means that it will apply the potion effect forever.

 

But it is checking if the player is in an area of 5 blocks from a block, so if the player is more away than 5 blocks then it should stop adding the effect, I think.

 

EDIT: I understood you bad. No it is checking if the potion is NOT active, so it is not re-adding it on every entity update.

Posted

Can't help, nothing like this has ever happened to me.

 

If the problem still occurs, try clearing the potions on the player, either by forcing the player to drink milk, or some sort of method that makes the list null.

Posted

Can't help, nothing like this has ever happened to me.

 

If the problem still occurs, try clearing the potions on the player, either by forcing the player to drink milk, or some sort of method that makes the list null.

 

OK, i will try to find some method to remove the potion effects from the player, because even if he drinks milk the effect still remains  :'(

 

If i find something i will tell you, thanks for helping

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.