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 {
Class entityClass = ReflectionManager.getNmsClass("Entity");
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
Class entityClass = ReflectionManager.getNmsClass("Entity"); hasInvun = entityClass.getField("noDamageTicks").getInt(nmsEntity) == ReflectionManager
hasInvun = entityClass.getField("noDamageTicks").getInt(nmsEntity) == entityClass .getNmsClass("EntityLiving").getField("maxNoDamageTicks")
.getField("maxNoDamageTicks").getInt(nmsEntity); .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();