The bug
Applying the same effect you already have but with an amplifier higher than 127 causes the timer to reach 0:00 and remain like this but you still have the potion effect.
How to reproduce
Type the command
/effect give @s minecraft:strength 10
Before the timer of the effect reaches 0:00, type the command
/effect give @s minecraft:strength 30 128
→ The effect's timer should remain at 0:00, but you would still have the effect
Code analysis
The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta.
This is a valid report because the method net.minecraft.client.network.NetHandlerPlayClient.handleEntityEffect(SPacketEntityEffect)
is not reading the amplifier correctly. The packet stores the amplifier as unsigned byte (0 to 255), however the client reads it as signed byte (-128 to 127). Because of this the client thinks the amplifier is lower and does not extend the duration of the effect. The effect remains however as the client does not receive a SPacketRemoveEntityEffect
packet, because for the server, the potion duration was extended.
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
if (entity instanceof EntityLivingBase)
{
Potion potion = Potion.getPotionById(packetIn.getEffectId());
if (potion != null)
{
// Replaced this
//PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.func_186984_g(), packetIn.func_179707_f());
PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), Byte.toUnsignedInt(packetIn.getAmplifier()), packetIn.func_186984_g(), packetIn.func_179707_f());
potioneffect.setPotionDurationMax(packetIn.func_149429_c());
((EntityLivingBase)entity).addPotionEffect(potioneffect);
}
}
}
Related issues
Attachments
Comments


Is this still an issue in 15w45a? If so, please explain the issue in detail and provide steps to reproduce it. Please also update the list of affected versions.

Confirmed for
15w47c
Just have a repeating command block running a /testfor
command and then a conditional chain command block that gives you the effect.
testfor command
/testfor @p {ActiveEffects:[{Duration:1}]}
It looks like this is caused only by the high amplifier but not by the duration

Please change the summary (title) of the report to something like "Potion effects with high amplifiers remain displayed in inventory after timer reaches 0:00"

So regular amplifiers are not an issue?

redstonehelper, yes it is.

Yes as in "not an issue", or yes as in "is an issue too"?

yes, as in not an issue for regular amplifiers.

Amplifiers above 4 are not supported, any bugs caused by them won't be fixed.

The title I suggested is wrong, sorry for that. Can you change it to "Applying effect with high amplifier when potion effect ends causes timer to stay at 0:00"

Please link to this comment in the description
The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta.
This is a valid report because the method net.minecraft.client.network.NetHandlerPlayClient.handleEntityEffect(SPacketEntityEffect)
is not reading the amplifier correctly. The packet stores the amplifier as unsigned byte (0 to 255), however the client reads it as signed byte (-128 to 127). Because of this the client thinks the amplifier is lower and does not extend the duration of the effect. The effect remains however as the client does not receive a SPacketRemoveEntityEffect
packet, because for the server, the potion duration was extended.
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
if (entity instanceof EntityLivingBase)
{
Potion potion = Potion.getPotionById(packetIn.getEffectId());
if (potion != null)
{
// Replaced this
//PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.func_186984_g(), packetIn.func_179707_f());
PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), Byte.toUnsignedInt(packetIn.getAmplifier()), packetIn.func_186984_g(), packetIn.func_179707_f());
potioneffect.setPotionDurationMax(packetIn.func_149429_c());
((EntityLivingBase)entity).addPotionEffect(potioneffect);
}
}
}

Is this still an issue in the latest snapshot 16w44a? If so please update the affected versions.
This is an automated comment on any open or reopened issue with out-of-date affected versions.
Confirmed for 1.13.1-pre1
Fixed in 1.15.2. The effect doesn't remain at 0:00 when the 10 seconds potion ends.

Probably fixed due to the fix for MC-1541.