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

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  :)

(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.

  • Author

(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.

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.

  • Author

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...

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.