Posted May 14, 201411 yr 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
May 14, 201411 yr (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.
May 14, 201411 yr 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.
May 14, 201411 yr 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.
May 15, 201411 yr 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.