mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 16:36:58 -04:00
fix chunk reading for some servers (1.9)
This commit is contained in:
parent
9dcbcfcf29
commit
9872606d40
@ -189,6 +189,7 @@ public class Connection {
|
||||
handleThread.start();
|
||||
}
|
||||
|
||||
|
||||
public PluginChannelHandler getPluginChannelHandler() {
|
||||
return pluginChannelHandler;
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ public class PacketChunkData implements ClientboundPacket {
|
||||
boolean groundUpContinuous = buffer.readBoolean();
|
||||
short sectionBitMask = buffer.readShort();
|
||||
int size = buffer.readVarInt();
|
||||
int lastPos = buffer.getPosition();
|
||||
buffer.setPosition(size + lastPos);
|
||||
|
||||
chunk = ChunkUtil.readChunkPacket(buffer, sectionBitMask, (short) 0, groundUpContinuous, true);
|
||||
return true;
|
||||
@ -62,13 +64,19 @@ public class PacketChunkData implements ClientboundPacket {
|
||||
boolean groundUpContinuous = buffer.readBoolean();
|
||||
short sectionBitMask = (short) buffer.readVarInt();
|
||||
int size = buffer.readVarInt();
|
||||
int lastPos = buffer.getPosition();
|
||||
|
||||
chunk = ChunkUtil.readChunkPacket(buffer, sectionBitMask, (short) 0, groundUpContinuous, true);
|
||||
// set position of the byte buffer, because of some reasons HyPixel makes some weired stuff and sends way to much 0 bytes. (~ 190k)
|
||||
buffer.setPosition(size + lastPos);
|
||||
int blockEntitiesCount = buffer.readVarInt();
|
||||
for (int i = 0; i < blockEntitiesCount; i++) {
|
||||
CompoundTag tag = buffer.readNBT();
|
||||
blockEntities.put(new BlockPosition(tag.getIntTag("x").getValue(), (short) tag.getIntTag("y").getValue(), tag.getIntTag("z").getValue()), tag);
|
||||
}
|
||||
if (buffer.getBytesLeft() > 0) {
|
||||
Log.debug("ERROR");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class PacketPlayerAbilitiesSending implements ServerboundPacket {
|
||||
case VERSION_1_7_10:
|
||||
case VERSION_1_8:
|
||||
case VERSION_1_9_4:
|
||||
// only fly matches, everything else ignored
|
||||
// only fly matters, everything else ignored
|
||||
byte flags = 0;
|
||||
if (flying) {
|
||||
flags |= 0b10;
|
||||
|
@ -73,7 +73,7 @@ public class PacketPlayerDigging implements ServerboundPacket {
|
||||
|
||||
@Override
|
||||
public void log() {
|
||||
Log.protocol(String.format("Send player digging packet (status=%s, position=%s, face=%d)", status.name(), position.toString(), face));
|
||||
Log.protocol(String.format("Send player digging packet (status=%s, position=%s, face=%s)", status.name(), position.toString(), face.name()));
|
||||
}
|
||||
|
||||
public enum DiggingStatus {
|
||||
|
@ -378,4 +378,8 @@ public class InByteBuffer {
|
||||
public String toString() {
|
||||
return "dataLen: " + bytes.length + "; pos: " + pos;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
@ -55,14 +55,9 @@ public class Util {
|
||||
while (!inflater.finished()) {
|
||||
stream.write(buffer, 0, inflater.inflate(buffer));
|
||||
}
|
||||
} catch (DataFormatException e) {
|
||||
stream.close();
|
||||
} catch (IOException | DataFormatException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new InByteBuffer(stream.toByteArray(), version);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user