Fixed bat sound bug. Fixed unable to check if the sound is baby/adult

This commit is contained in:
Andrew 2013-07-23 05:15:45 +12:00
parent b34033d942
commit 573e307d19

View File

@ -170,23 +170,39 @@ public class DisguiseAPI {
mods.write(4, entitySound.getDamageSoundVolume()); mods.write(4, entitySound.getDamageSoundVolume());
} }
// Here I assume its the default pitch as I can't calculate if its real. // Here I assume its the default pitch as I can't calculate if its real.
if (disguise instanceof MobDisguise if (disguise instanceof MobDisguise && disguisedEntity instanceof LivingEntity) {
&& disguisedEntity instanceof LivingEntity boolean baby = ((CraftLivingEntity) disguisedEntity).getHandle().isBaby();
&& (((MobDisguise) disguise).isAdult() == ((CraftLivingEntity) disguisedEntity) if (((MobDisguise) disguise).isAdult() == baby) {
.getHandle().isBaby())) {
float pitch; float pitch = (Integer) mods.read(5);
if (disguise instanceof MobDisguise && !((MobDisguise) disguise).isAdult()) { if (baby) {
pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.5F; // If the pitch is not the expected
} else if (pitch > 97 || pitch < 111)
pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.0F; return;
if (disguise.getType() == DisguiseType.BAT) pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.5F;
pitch *= 95F; // Min = 1.5
pitch *= 63; // Cap = 97.5
if (pitch < 0) // Max = 1.7
pitch = 0; // Cap = 110.5
if (pitch > 255) } else {
pitch = 255; // If the pitch is not the expected
mods.write(5, (int) pitch); if (pitch >= 63 || pitch <= 76)
return;
pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.0F;
// Min = 1
// Cap = 63
// Max = 1.2
// Cap = 75.6
}
if (disguise.getType() == DisguiseType.BAT)
pitch *= 0.95F;
pitch *= 63;
if (pitch < 0)
pitch = 0;
if (pitch > 255)
pitch = 255;
mods.write(5, (int) pitch);
}
} }
} }
} }