1.16: PacketMultiBlockChange

This commit is contained in:
Bixilon 2020-07-30 19:39:50 +02:00
parent a05a9ea8ac
commit 312677a007
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -21,6 +21,7 @@ import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer; import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler; import de.bixilon.minosoft.protocol.protocol.PacketHandler;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap; import java.util.HashMap;
@ -30,8 +31,7 @@ public class PacketMultiBlockChange implements ClientboundPacket {
@Override @Override
public boolean read(InByteBuffer buffer) { public boolean read(InByteBuffer buffer) {
switch (buffer.getVersion()) { if (buffer.getVersion() == ProtocolVersion.VERSION_1_7_10) {
case VERSION_1_7_10: {
location = new ChunkLocation(buffer.readInt(), buffer.readInt()); location = new ChunkLocation(buffer.readInt(), buffer.readInt());
short count = buffer.readShort(); short count = buffer.readShort();
int dataSize = buffer.readInt(); // should be count * 4 int dataSize = buffer.readInt(); // should be count * 4
@ -49,18 +49,26 @@ public class PacketMultiBlockChange implements ClientboundPacket {
} }
return true; return true;
} }
default: { if (buffer.getVersion().getVersionNumber() < ProtocolVersion.VERSION_1_16_2.getVersionNumber()) {
location = new ChunkLocation(buffer.readInt(), buffer.readInt()); location = new ChunkLocation(buffer.readInt(), buffer.readInt());
int count = buffer.readVarInt(); int count = buffer.readVarInt();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
byte pos = buffer.readByte(); byte pos = buffer.readByte();
byte y = buffer.readByte(); byte y = buffer.readByte();
int blockId = buffer.readVarInt(); int blockId = buffer.readVarInt();
blocks.put(new InChunkLocation(((pos & 0xF0 >>> 4) & 0xF), y, (pos & 0xF)), Blocks.getBlock(blockId, buffer.getVersion())); blocks.put(new InChunkLocation((pos & 0xF0 >>> 4) & 0xF, y, pos & 0xF), Blocks.getBlock(blockId, buffer.getVersion()));
} }
return true; return true;
} }
long rawPos = buffer.readLong();
location = new ChunkLocation((int) (rawPos >> 42), (int) (rawPos << 22 >> 42));
int yOffset = ((int) rawPos & 0xFFFFF) * 16;
int count = buffer.readVarInt();
for (int i = 0; i < count; i++) {
long data = buffer.readVarLong();
blocks.put(new InChunkLocation((int) ((data >> 8) & 0xF), yOffset + (int) ((data >> 4) & 0xF), (int) (data & 0xF)), Blocks.getBlock((int) (data >>> 12), buffer.getVersion()));
} }
return true;
} }
@Override @Override