public double readDouble(int reversed) { double value = 0; value = NumericalUtils.byteArrayToDouble(new byte[] { packetData[offset], packetData[offset + 1], packetData[offset + 2], packetData[offset + 3], packetData[offset + 4], packetData[offset + 5], packetData[offset + 6], packetData[offset + 7] }, reversed); offset = offset + 8; return(value); }
static public void LtVector3dToDoubles(byte[] LtVector3d, ref double x, ref double y, ref double z) { byte[] tempX = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] tempY = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] tempZ = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; for (int i = 0; i < 8; i++) { tempX[i] = LtVector3d[i]; tempY[i] = LtVector3d[i + 8]; tempZ[i] = LtVector3d[i + 16]; } x = NumericalUtils.byteArrayToDouble(tempX, 1); y = NumericalUtils.byteArrayToDouble(tempY, 1); z = NumericalUtils.byteArrayToDouble(tempZ, 1); }
public void processHyperJump(ref byte[] packet) { byte[] destXBytes = new byte[8]; byte[] destYBytes = new byte[8]; byte[] destZBytes = new byte[8]; byte[] maxHeight = new byte[4]; byte[] theLast4 = new byte[4]; // we dont know what this is lol DynamicArray restBytes = new DynamicArray(); ArrayUtils.copy(packet, 0, destXBytes, 0, 8); ArrayUtils.copy(packet, 8, destYBytes, 0, 8); ArrayUtils.copy(packet, 16, destZBytes, 0, 8); ArrayUtils.copy(packet, 30, maxHeight, 0, 4); ArrayUtils.copy(packet, packet.Length - 4, theLast4, 0, 4); // Players current X Z Y double x = 0; double y = 0; double z = 0; byte[] Ltvector3d = Store.currentClient.playerInstance.Position.getValue(); NumericalUtils.LtVector3dToDoubles(Ltvector3d, ref x, ref y, ref z); int rotation = (int)Store.currentClient.playerInstance.YawInterval.getValue()[0]; float xPos = (float)x; float yPos = (float)y; float zPos = (float)z; float xDestFloat = (float)NumericalUtils.byteArrayToDouble(destXBytes, 1); float yDestFloat = (float)NumericalUtils.byteArrayToDouble(destYBytes, 1); float zDestFloat = (float)NumericalUtils.byteArrayToDouble(destZBytes, 1); float distance = getDistance(xPos, yPos, zPos, xDestFloat, yDestFloat, zDestFloat); UInt16 duration = (UInt16)(distance * 1.5); //UInt32 startTime = TimeUtils.getUnixTimeUint32() - 100000; //UInt32 endTime = startTime + duration; UInt32 startTime = TimeUtils.getUnixTimeUint32(); UInt32 endTime = startTime + duration; PacketContent pak = new PacketContent(); pak.addByte(0x02); pak.addByte(0x00); pak.addByte(0x03); pak.addByte(0x09); pak.addByte(0x08); pak.addByte(0x00); pak.addFloatLtVector3f(xPos, yPos, zPos); pak.addUint32(startTime, 1); pak.addByte(0x80); pak.addByte(0x80); pak.addByte(0xb8); pak.addByte(0x14); // if 0xb8 pak.addByte(0x00); // if 0xb8 pak.addUint32(endTime, 1); pak.addByteArray(destXBytes); pak.addByteArray(destYBytes); pak.addByteArray(destZBytes); pak.addByteArray(new byte[] { 0x10, 0xff, 0xff }); pak.addByte(0x00); pak.addByte(0x00); pak.addByte(0x00); Store.currentClient.messageQueue.addObjectMessage(pak.returnFinalPacket(), true); }