mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-26 03:55:28 +01:00
Merge pull request #26 from Mystalion/fix-paintings
Fix support for paintings, also add a read and write position method.
This commit is contained in:
commit
0209c51d10
@ -363,4 +363,17 @@ public class PacketUtil {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static long[] readBlockPosition(ByteBuf buf) {
|
||||
long val = buf.readLong();
|
||||
long x = (val >> 38); // signed
|
||||
long y = (val >> 26) & 0xfff; // unsigned
|
||||
// this shifting madness is used to preserve sign
|
||||
long z = (val << 38) >> 38; // signed
|
||||
return new long[]{x, y, z};
|
||||
}
|
||||
|
||||
public static void writeBlockPosition(ByteBuf buf, long x, long y, long z) {
|
||||
buf.writeLong(((x & 0x3ffffff) << 38) | ((y & 0xfff) << 26) | (z & 0x3ffffff));
|
||||
}
|
||||
}
|
||||
|
@ -267,6 +267,23 @@ public class OutgoingTransformer {
|
||||
|
||||
return;
|
||||
}
|
||||
if (packet == PacketType.PLAY_SPAWN_PAINTING) {
|
||||
int id = PacketUtil.readVarInt(input);
|
||||
PacketUtil.writeVarInt(id, output);
|
||||
|
||||
PacketUtil.writeUUID(getUUID(id), output);
|
||||
|
||||
String title = PacketUtil.readString(input);
|
||||
PacketUtil.writeString(title, output);
|
||||
|
||||
long[] position = PacketUtil.readBlockPosition(input);
|
||||
PacketUtil.writeBlockPosition(output, position[0], position[1], position[2]);
|
||||
|
||||
byte direction = input.readByte();
|
||||
output.writeByte(direction);
|
||||
|
||||
return;
|
||||
}
|
||||
if (packet == PacketType.PLAY_OPEN_WINDOW) {
|
||||
int windowId = input.readUnsignedByte();
|
||||
String type = readString(input);
|
||||
|
Loading…
Reference in New Issue
Block a user