the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 96 lines 2.0 kB view raw
1#include "stdafx.h" 2#include "BasicTypeContainers.h" 3#include "InputOutputStream.h" 4#include "net.minecraft.network.packet.h" 5#include "LevelSoundPacket.h" 6 7const float LevelSoundPacket::PITCH_ACCURACY = Byte::MAX_VALUE / 2.0f; 8const float LevelSoundPacket::LOCATION_ACCURACY = 8.0f; 9 10LevelSoundPacket::LevelSoundPacket() 11{ 12 sound = 0; 13 x = 0; 14 y = Integer::MAX_VALUE; 15 z = 0; 16 volume = 0.0f; 17 pitch = 0; 18} 19 20LevelSoundPacket::LevelSoundPacket(int sound, double x, double y, double z, float volume, float pitch) 21{ 22 this->sound = sound; 23 this->x = (int) (x * LOCATION_ACCURACY); 24 this->y = (int) (y * LOCATION_ACCURACY); 25 this->z = (int) (z * LOCATION_ACCURACY); 26 this->volume = volume; 27 // 4J-PB - Let's make the pitch a float so it doesn't get mangled and make the noteblock people unhappy 28 //this->pitch = (int) (pitch * PITCH_ACCURACY); 29 this->pitch = pitch; 30 31// if (this->pitch < 0) this->pitch = 0; 32// if (this->pitch > 255) this->pitch = 255; 33} 34 35void LevelSoundPacket::read(DataInputStream *dis) 36{ 37 sound = dis->readInt(); 38 x = dis->readInt(); 39 y = dis->readInt(); 40 z = dis->readInt(); 41 volume = dis->readFloat(); 42 //pitch = dis->readUnsignedByte(); 43 pitch = dis->readFloat(); 44} 45 46void LevelSoundPacket::write(DataOutputStream *dos) 47{ 48 dos->writeInt(sound); 49 dos->writeInt(x); 50 dos->writeInt(y); 51 dos->writeInt(z); 52 dos->writeFloat(volume); 53 //dos->writeByte(pitch); 54 dos->writeFloat(pitch); 55} 56 57int LevelSoundPacket::getSound() 58{ 59 return sound; 60} 61 62double LevelSoundPacket::getX() 63{ 64 return x / LOCATION_ACCURACY; 65} 66 67double LevelSoundPacket::getY() 68{ 69 return y / LOCATION_ACCURACY; 70} 71 72double LevelSoundPacket::getZ() 73{ 74 return z / LOCATION_ACCURACY; 75} 76 77float LevelSoundPacket::getVolume() 78{ 79 return volume; 80} 81 82float LevelSoundPacket::getPitch() 83{ 84 //return pitch / PITCH_ACCURACY; 85 return pitch; 86} 87 88void LevelSoundPacket::handle(PacketListener *listener) 89{ 90 listener->handleSoundEvent(shared_from_this()); 91} 92 93int LevelSoundPacket::getEstimatedSize() 94{ 95 return 4 * 6; 96}