mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 08:58:02 -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();
|
handleThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PluginChannelHandler getPluginChannelHandler() {
|
public PluginChannelHandler getPluginChannelHandler() {
|
||||||
return pluginChannelHandler;
|
return pluginChannelHandler;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,8 @@ public class PacketChunkData implements ClientboundPacket {
|
|||||||
boolean groundUpContinuous = buffer.readBoolean();
|
boolean groundUpContinuous = buffer.readBoolean();
|
||||||
short sectionBitMask = buffer.readShort();
|
short sectionBitMask = buffer.readShort();
|
||||||
int size = buffer.readVarInt();
|
int size = buffer.readVarInt();
|
||||||
|
int lastPos = buffer.getPosition();
|
||||||
|
buffer.setPosition(size + lastPos);
|
||||||
|
|
||||||
chunk = ChunkUtil.readChunkPacket(buffer, sectionBitMask, (short) 0, groundUpContinuous, true);
|
chunk = ChunkUtil.readChunkPacket(buffer, sectionBitMask, (short) 0, groundUpContinuous, true);
|
||||||
return true;
|
return true;
|
||||||
@ -62,13 +64,19 @@ public class PacketChunkData implements ClientboundPacket {
|
|||||||
boolean groundUpContinuous = buffer.readBoolean();
|
boolean groundUpContinuous = buffer.readBoolean();
|
||||||
short sectionBitMask = (short) buffer.readVarInt();
|
short sectionBitMask = (short) buffer.readVarInt();
|
||||||
int size = buffer.readVarInt();
|
int size = buffer.readVarInt();
|
||||||
|
int lastPos = buffer.getPosition();
|
||||||
|
|
||||||
chunk = ChunkUtil.readChunkPacket(buffer, sectionBitMask, (short) 0, groundUpContinuous, true);
|
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();
|
int blockEntitiesCount = buffer.readVarInt();
|
||||||
for (int i = 0; i < blockEntitiesCount; i++) {
|
for (int i = 0; i < blockEntitiesCount; i++) {
|
||||||
CompoundTag tag = buffer.readNBT();
|
CompoundTag tag = buffer.readNBT();
|
||||||
blockEntities.put(new BlockPosition(tag.getIntTag("x").getValue(), (short) tag.getIntTag("y").getValue(), tag.getIntTag("z").getValue()), tag);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class PacketPlayerAbilitiesSending implements ServerboundPacket {
|
|||||||
case VERSION_1_7_10:
|
case VERSION_1_7_10:
|
||||||
case VERSION_1_8:
|
case VERSION_1_8:
|
||||||
case VERSION_1_9_4:
|
case VERSION_1_9_4:
|
||||||
// only fly matches, everything else ignored
|
// only fly matters, everything else ignored
|
||||||
byte flags = 0;
|
byte flags = 0;
|
||||||
if (flying) {
|
if (flying) {
|
||||||
flags |= 0b10;
|
flags |= 0b10;
|
||||||
|
@ -73,7 +73,7 @@ public class PacketPlayerDigging implements ServerboundPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log() {
|
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 {
|
public enum DiggingStatus {
|
||||||
|
@ -378,4 +378,8 @@ public class InByteBuffer {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "dataLen: " + bytes.length + "; pos: " + pos;
|
return "dataLen: " + bytes.length + "; pos: " + pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] getBytes() {
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,15 +55,10 @@ public class Util {
|
|||||||
while (!inflater.finished()) {
|
while (!inflater.finished()) {
|
||||||
stream.write(buffer, 0, inflater.inflate(buffer));
|
stream.write(buffer, 0, inflater.inflate(buffer));
|
||||||
}
|
}
|
||||||
} catch (DataFormatException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
stream.close();
|
stream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException | DataFormatException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return new InByteBuffer(stream.toByteArray(), version);
|
return new InByteBuffer(stream.toByteArray(), version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user