more 1.8 chunk parsing

This commit is contained in:
Bixilon 2020-06-23 15:52:30 +02:00
parent daaa56bbad
commit 3edddf7f70
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
7 changed files with 33 additions and 18 deletions

View File

@ -32,7 +32,7 @@ public class EntityMetaData {
while (item != 0x7F) { while (item != 0x7F) {
byte index = (byte) (item & 0x1F); byte index = (byte) (item & 0x1F);
Object data; Object data;
Type_1_7_10 type = Type_1_7_10.byId((item & 0xFF) >> 5); Type_1_7_10 type = Type_1_7_10.byId((item & 0xFF) >>> 5);
switch (type) { switch (type) {
case BYTE: case BYTE:
data = buffer.readByte(); data = buffer.readByte();

View File

@ -24,12 +24,12 @@ public class FallingBlock extends EntityObject implements ObjectInterface {
public FallingBlock(int id, Location location, short yaw, short pitch, int additionalInt) { public FallingBlock(int id, Location location, short yaw, short pitch, int additionalInt) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
block = Blocks.byLegacy(additionalInt & 0xFFF, additionalInt >> 12); block = Blocks.byLegacy(additionalInt & 0xFFF, additionalInt >>> 12);
} }
public FallingBlock(int id, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) { public FallingBlock(int id, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
block = Blocks.byLegacy(additionalInt & 0xFFF, additionalInt >> 12); block = Blocks.byLegacy(additionalInt & 0xFFF, additionalInt >>> 12);
} }
@Override @Override

View File

@ -36,7 +36,7 @@ public class PacketBlockChange implements ClientboundPacket {
case VERSION_1_8: case VERSION_1_8:
position = buffer.readPosition(); position = buffer.readPosition();
int blockId = buffer.readVarInt(); int blockId = buffer.readVarInt();
block = Blocks.byLegacy(blockId >> 4, blockId & 0xF); block = Blocks.byLegacy(blockId >>> 4, blockId & 0xF);
break; break;
} }
} }

View File

@ -32,7 +32,7 @@ public class PacketChunkData implements ClientboundPacket {
@Override @Override
public void read(InPacketBuffer buffer, ProtocolVersion v) { public void read(InPacketBuffer buffer, ProtocolVersion v) {
switch (v) { switch (v) {
case VERSION_1_7_10: case VERSION_1_7_10: {
this.location = new ChunkLocation(buffer.readInteger(), buffer.readInteger()); this.location = new ChunkLocation(buffer.readInteger(), buffer.readInteger());
boolean groundUpContinuous = buffer.readBoolean(); boolean groundUpContinuous = buffer.readBoolean();
short sectionBitMask = buffer.readShort(); short sectionBitMask = buffer.readShort();
@ -43,9 +43,16 @@ public class PacketChunkData implements ClientboundPacket {
chunk = ChunkUtil.readChunkPacket(v, decompressed, sectionBitMask, addBitMask, groundUpContinuous, true); chunk = ChunkUtil.readChunkPacket(v, decompressed, sectionBitMask, addBitMask, groundUpContinuous, true);
break; break;
case VERSION_1_8: }
//ToDo case VERSION_1_8: {
this.location = new ChunkLocation(buffer.readInteger(), buffer.readInteger());
boolean groundUpContinuous = buffer.readBoolean();
short sectionBitMask = buffer.readShort();
int size = buffer.readVarInt();
chunk = ChunkUtil.readChunkPacket(v, buffer, sectionBitMask, (short) 0, groundUpContinuous, true);
break; break;
}
} }
} }

View File

@ -25,14 +25,13 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap; import java.util.HashMap;
public class PacketMultiBlockChange implements ClientboundPacket { public class PacketMultiBlockChange implements ClientboundPacket {
ChunkLocation location;
final HashMap<InChunkLocation, Blocks> blocks = new HashMap<>(); final HashMap<InChunkLocation, Blocks> blocks = new HashMap<>();
ChunkLocation location;
@Override @Override
public void read(InPacketBuffer buffer, ProtocolVersion v) { public void read(InPacketBuffer buffer, ProtocolVersion v) {
switch (v) { switch (v) {
case VERSION_1_7_10: case VERSION_1_7_10: {
location = new ChunkLocation(buffer.readInteger(), buffer.readInteger()); location = new ChunkLocation(buffer.readInteger(), buffer.readInteger());
short count = buffer.readShort(); short count = buffer.readShort();
int dataSize = buffer.readInteger(); // should be count * 4 int dataSize = buffer.readInteger(); // should be count * 4
@ -42,16 +41,25 @@ public class PacketMultiBlockChange implements ClientboundPacket {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int raw = buffer.readInteger(); int raw = buffer.readInteger();
byte meta = (byte) (raw & 0xF); byte meta = (byte) (raw & 0xF);
short blockId = (short) ((raw & 0xFF_F0) >> 4); short blockId = (short) ((raw & 0xFF_F0) >>> 4);
byte y = (byte) ((raw & 0xFF_00_00) >> 16); byte y = (byte) ((raw & 0xFF_00_00) >>> 16);
byte z = (byte) ((raw & 0x0F_00_00_00) >> 24); byte z = (byte) ((raw & 0x0F_00_00_00) >>> 24);
byte x = (byte) (Math.abs((raw & 0xF0_00_00_00) >> 28)); byte x = (byte) ((raw & 0xF0_00_00_00) >>> 28);
blocks.put(new InChunkLocation(x, y, z), Blocks.byLegacy(blockId, meta)); blocks.put(new InChunkLocation(x, y, z), Blocks.byLegacy(blockId, meta));
} }
break; break;
case VERSION_1_8: }
//ToDo case VERSION_1_8: {
location = new ChunkLocation(buffer.readInteger(), buffer.readInteger());
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), y, (pos & 0xF)), Blocks.byLegacy((blockId >>> 4), (blockId & 0xF)));
}
break; break;
}
} }
} }

View File

@ -177,7 +177,7 @@ public class InByteBuffer {
public BlockPosition readPosition() { public BlockPosition readPosition() {
Long raw = readLong(); Long raw = readLong();
return new BlockPosition(Long.valueOf(raw >> 38).intValue(), Long.valueOf(raw & 0xFFF).shortValue(), Long.valueOf(raw << 26 >> 38).intValue()); return new BlockPosition(Long.valueOf(raw >>> 38).intValue(), Long.valueOf(raw & 0xFFF).shortValue(), Long.valueOf(raw << 26 >>> 38).intValue());
} }
@Override @Override

View File

@ -33,7 +33,7 @@ public class BitByte {
} }
public static byte getHigh4Bits(byte input) { public static byte getHigh4Bits(byte input) {
return (byte) ((input) >> 4 & 0xF); return (byte) ((input) >>> 4 & 0xF);
} }
public static byte getBitCount(short input) { public static byte getBitCount(short input) {