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; boolean hasInvun = false;
Object nmsEntity = ReflectionManager.getNmsEntity(entity); Object nmsEntity = ReflectionManager.getNmsEntity(entity);
try { try {
if (entity instanceof LivingEntity) {
Class entityClass = ReflectionManager.getNmsClass("Entity"); Class entityClass = ReflectionManager.getNmsClass("Entity");
hasInvun = entityClass.getField("noDamageTicks").getInt(nmsEntity) == entityClass if (entity instanceof LivingEntity) {
.getField("maxNoDamageTicks").getInt(nmsEntity); hasInvun = entityClass.getField("noDamageTicks").getInt(nmsEntity) == ReflectionManager
.getNmsClass("EntityLiving").getField("maxNoDamageTicks")
.getInt(nmsEntity);
} else { } else {
hasInvun = (Boolean) ReflectionManager.getNmsClass("Entity") hasInvun = (Boolean) entityClass.getMethod("isInvulnerable").invoke(nmsEntity);
.getMethod("isInvulnerable").invoke(nmsEntity);
} }
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();