mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
more 1.8 chunk parsing
This commit is contained in:
parent
daaa56bbad
commit
3edddf7f70
@ -32,7 +32,7 @@ public class EntityMetaData {
|
||||
while (item != 0x7F) {
|
||||
byte index = (byte) (item & 0x1F);
|
||||
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) {
|
||||
case BYTE:
|
||||
data = buffer.readByte();
|
||||
|
@ -24,12 +24,12 @@ public class FallingBlock extends EntityObject implements ObjectInterface {
|
||||
public FallingBlock(int id, Location location, short yaw, short pitch, int additionalInt) {
|
||||
super(id, location, yaw, pitch, null);
|
||||
// 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) {
|
||||
super(id, location, yaw, pitch, velocity);
|
||||
block = Blocks.byLegacy(additionalInt & 0xFFF, additionalInt >> 12);
|
||||
block = Blocks.byLegacy(additionalInt & 0xFFF, additionalInt >>> 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,7 +36,7 @@ public class PacketBlockChange implements ClientboundPacket {
|
||||
case VERSION_1_8:
|
||||
position = buffer.readPosition();
|
||||
int blockId = buffer.readVarInt();
|
||||
block = Blocks.byLegacy(blockId >> 4, blockId & 0xF);
|
||||
block = Blocks.byLegacy(blockId >>> 4, blockId & 0xF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class PacketChunkData implements ClientboundPacket {
|
||||
@Override
|
||||
public void read(InPacketBuffer buffer, ProtocolVersion v) {
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_7_10: {
|
||||
this.location = new ChunkLocation(buffer.readInteger(), buffer.readInteger());
|
||||
boolean groundUpContinuous = buffer.readBoolean();
|
||||
short sectionBitMask = buffer.readShort();
|
||||
@ -43,9 +43,16 @@ public class PacketChunkData implements ClientboundPacket {
|
||||
|
||||
chunk = ChunkUtil.readChunkPacket(v, decompressed, sectionBitMask, addBitMask, groundUpContinuous, true);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,14 +25,13 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PacketMultiBlockChange implements ClientboundPacket {
|
||||
ChunkLocation location;
|
||||
final HashMap<InChunkLocation, Blocks> blocks = new HashMap<>();
|
||||
|
||||
ChunkLocation location;
|
||||
|
||||
@Override
|
||||
public void read(InPacketBuffer buffer, ProtocolVersion v) {
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_7_10: {
|
||||
location = new ChunkLocation(buffer.readInteger(), buffer.readInteger());
|
||||
short count = buffer.readShort();
|
||||
int dataSize = buffer.readInteger(); // should be count * 4
|
||||
@ -42,16 +41,25 @@ public class PacketMultiBlockChange implements ClientboundPacket {
|
||||
for (int i = 0; i < count; i++) {
|
||||
int raw = buffer.readInteger();
|
||||
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) (Math.abs((raw & 0xF0_00_00_00) >> 28));
|
||||
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.byLegacy(blockId, meta));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class InByteBuffer {
|
||||
|
||||
public BlockPosition readPosition() {
|
||||
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
|
||||
|
@ -33,7 +33,7 @@ public class BitByte {
|
||||
}
|
||||
|
||||
public static byte getHigh4Bits(byte input) {
|
||||
return (byte) ((input) >> 4 & 0xF);
|
||||
return (byte) ((input) >>> 4 & 0xF);
|
||||
}
|
||||
|
||||
public static byte getBitCount(short input) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user