EntityLiving setHealth(int i) method throws Illegal Argument Exception
EntityLiving:630
public void setHealth(int i)
Fix:
public void setHealth(int i)
Environment
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\deathmarine>java -version
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)
C:\Users\deathmarine>
Created Issue:
EntityLiving setHealth(int i) method throws Illegal Argument Exception
EntityLiving:630
{ this.health = i; if (i > getMaxHealth()) i = getMaxHealth(); }
public void setHealth(int i)Fix:
{ if (i > getMaxHealth()) i = getMaxHealth(); this.health = i; }
public void setHealth(int i)Environment
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.C:\Users\deathmarine>java -version
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)C:\Users\deathmarine>
How about:
{this.health = i > getMaxHealth() ? getMaxHealth() : i; }public void setHealth(int i)
Well, if everybody throws in his favourite bit of code:
Corrected your code
Thanks
Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
1.4.7 Seems to still have the same old code. Would be nice to get instructions on how to reproduce that exception, though. Edit: Not that the wonder of exception matters, the bug is obvious even by reading the code, but just me being curious.
Doesnt exist in 13w25b.