mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 18:05:51 -04:00
1.16: PacketMultiBlockChange
This commit is contained in:
parent
a05a9ea8ac
commit
312677a007
@ -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,37 +31,44 @@ 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
|
if (dataSize != count * 4) {
|
||||||
if (dataSize != count * 4) {
|
throw new IllegalArgumentException(String.format("Not enough data (%d) for %d blocks", dataSize, count));
|
||||||
throw new IllegalArgumentException(String.format("Not enough data (%d) for %d blocks", dataSize, count));
|
|
||||||
}
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
int raw = buffer.readInt();
|
|
||||||
byte meta = (byte) (raw & 0xF);
|
|
||||||
short blockId = (short) ((raw & 0xFF_F0) >>> 4);
|
|
||||||
byte y = (byte) ((raw & 0xFF_00_00) >>> 16);
|
|
||||||
byte z = (byte) ((raw & 0x0F_00_00_00) >>> 24);
|
|
||||||
byte x = (byte) ((raw & 0xF0_00_00_00) >>> 28);
|
|
||||||
blocks.put(new InChunkLocation(x, y, z), Blocks.getBlockByLegacy(blockId, meta));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
default: {
|
for (int i = 0; i < count; i++) {
|
||||||
location = new ChunkLocation(buffer.readInt(), buffer.readInt());
|
int raw = buffer.readInt();
|
||||||
int count = buffer.readVarInt();
|
byte meta = (byte) (raw & 0xF);
|
||||||
for (int i = 0; i < count; i++) {
|
short blockId = (short) ((raw & 0xFF_F0) >>> 4);
|
||||||
byte pos = buffer.readByte();
|
byte y = (byte) ((raw & 0xFF_00_00) >>> 16);
|
||||||
byte y = buffer.readByte();
|
byte z = (byte) ((raw & 0x0F_00_00_00) >>> 24);
|
||||||
int blockId = buffer.readVarInt();
|
byte x = (byte) ((raw & 0xF0_00_00_00) >>> 28);
|
||||||
blocks.put(new InChunkLocation(((pos & 0xF0 >>> 4) & 0xF), y, (pos & 0xF)), Blocks.getBlock(blockId, buffer.getVersion()));
|
blocks.put(new InChunkLocation(x, y, z), Blocks.getBlockByLegacy(blockId, meta));
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if (buffer.getVersion().getVersionNumber() < ProtocolVersion.VERSION_1_16_2.getVersionNumber()) {
|
||||||
|
location = new ChunkLocation(buffer.readInt(), buffer.readInt());
|
||||||
|
int count = buffer.readVarInt();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
byte pos = buffer.readByte();
|
||||||
|
byte y = buffer.readByte();
|
||||||
|
int blockId = buffer.readVarInt();
|
||||||
|
blocks.put(new InChunkLocation((pos & 0xF0 >>> 4) & 0xF, y, pos & 0xF), Blocks.getBlock(blockId, buffer.getVersion()));
|
||||||
|
}
|
||||||
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user