Fixed the error with a field being fetched in entity class

This commit is contained in:
libraryaddict 2013-11-19 23:38:34 +13:00
parent 5c41c04dd8
commit 06b9734c3e

View File

@ -416,13 +416,13 @@ public class PacketsManager {
boolean hasInvun = false;
Object nmsEntity = ReflectionManager.getNmsEntity(entity);
try {
if (entity instanceof LivingEntity) {
Class entityClass = ReflectionManager.getNmsClass("Entity");
hasInvun = entityClass.getField("noDamageTicks").getInt(nmsEntity) == entityClass
.getField("maxNoDamageTicks").getInt(nmsEntity);
if (entity instanceof LivingEntity) {
hasInvun = entityClass.getField("noDamageTicks").getInt(nmsEntity) == ReflectionManager
.getNmsClass("EntityLiving").getField("maxNoDamageTicks")
.getInt(nmsEntity);
} else {
hasInvun = (Boolean) ReflectionManager.getNmsClass("Entity")
.getMethod("isInvulnerable").invoke(nmsEntity);
hasInvun = (Boolean) entityClass.getMethod("isInvulnerable").invoke(nmsEntity);
}
} catch (Exception ex) {
ex.printStackTrace();