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,17 +170,32 @@ 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) {
// If the pitch is not the expected
if (pitch > 97 || pitch < 111)
return;
pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.5F; pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.5F;
} else // Min = 1.5
// Cap = 97.5
// Max = 1.7
// Cap = 110.5
} else {
// If the pitch is not the expected
if (pitch >= 63 || pitch <= 76)
return;
pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.0F; 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) if (disguise.getType() == DisguiseType.BAT)
pitch *= 95F; pitch *= 0.95F;
pitch *= 63; pitch *= 63;
if (pitch < 0) if (pitch < 0)
pitch = 0; pitch = 0;
@ -193,6 +208,7 @@ public class DisguiseAPI {
} }
} }
} }
}
} else if (event.getPacketID() == Packets.Server.ENTITY_STATUS) { } else if (event.getPacketID() == Packets.Server.ENTITY_STATUS) {
if ((Byte) mods.read(1) == 2) { if ((Byte) mods.read(1) == 2) {
// It made a damage animation // It made a damage animation