From 06b9734c3edfb021460ba5ebec7cdb24802760ad Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 19 Nov 2013 23:38:34 +1300 Subject: [PATCH] Fixed the error with a field being fetched in entity class --- src/me/libraryaddict/disguise/PacketsManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/me/libraryaddict/disguise/PacketsManager.java b/src/me/libraryaddict/disguise/PacketsManager.java index d8583d32..1fbce37a 100644 --- a/src/me/libraryaddict/disguise/PacketsManager.java +++ b/src/me/libraryaddict/disguise/PacketsManager.java @@ -416,13 +416,13 @@ public class PacketsManager { boolean hasInvun = false; Object nmsEntity = ReflectionManager.getNmsEntity(entity); try { + Class entityClass = ReflectionManager.getNmsClass("Entity"); if (entity instanceof LivingEntity) { - Class entityClass = ReflectionManager.getNmsClass("Entity"); - hasInvun = entityClass.getField("noDamageTicks").getInt(nmsEntity) == entityClass - .getField("maxNoDamageTicks").getInt(nmsEntity); + 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();