Fix the errors due to health being changed to a float

This commit is contained in:
libraryaddict 2013-11-23 04:20:03 +13:00
parent 49b81b0deb
commit 86d728f90d

View File

@ -410,9 +410,20 @@ public class PacketsManager {
if (loc.equals(soundLoc)) {
entitySound = DisguiseSound.getType(entity.getType().name());
if (entitySound != null) {
if (entity instanceof LivingEntity && ((LivingEntity) entity).getHealth() == 0) {
soundType = SoundType.DEATH;
} else {
Object obj = null;
if (entity instanceof LivingEntity) {
try {
obj = LivingEntity.class.getMethod("getHealth").invoke(entity);
} catch (Exception e) {
e.printStackTrace();
}
if (obj instanceof Float && ((Float) obj) == 0 || ((Integer) obj) == 0) {
soundType = SoundType.DEATH;
} else {
obj = null;
}
}
if (obj == null) {
boolean hasInvun = false;
Object nmsEntity = ReflectionManager.getNmsEntity(entity);
try {
@ -529,9 +540,20 @@ public class PacketsManager {
if (disSound == null)
return;
SoundType soundType = null;
if (entity instanceof LivingEntity && ((LivingEntity) entity).getHealth() == 0) {
soundType = SoundType.DEATH;
} else {
Object obj = null;
if (entity instanceof LivingEntity) {
try {
obj = LivingEntity.class.getMethod("getHealth").invoke(entity);
} catch (Exception e) {
e.printStackTrace();
}
if (obj instanceof Float && ((Float) obj) == 0 || ((Integer) obj) == 0) {
soundType = SoundType.DEATH;
} else {
obj = null;
}
}
if (obj == null) {
soundType = SoundType.HURT;
}
if (disSound.getSound(soundType) == null