1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

fix chunk parsing on hypixel

This commit is contained in:
mat 2025-01-27 19:24:12 +00:00
parent ed00a5b8f1
commit 67c053638c
4 changed files with 102 additions and 67 deletions

View file

@ -108,7 +108,7 @@ pub struct WriteConnection<W: ProtocolPacket> {
/// conn.set_compression_threshold(p.compression_threshold);
/// }
/// ClientboundLoginPacket::LoginFinished(p) => {
/// break (conn.configuration(), p.game_profile);
/// break (conn.config(), p.game_profile);
/// }
/// ClientboundLoginPacket::LoginDisconnect(p) => {
/// eprintln!("login disconnect: {}", p.reason);

File diff suppressed because one or more lines are too long

View file

@ -1,72 +1,72 @@
use std::{error::Error, fmt};
// this is from minecraft's code
// yeah idk either
#[rustfmt::skip]
const MAGIC: [(i32, i32, i32); 64] = [
// divide_mul, divide_add, divide_shift
(-1, -1, 0),
(-2147483648, 0, 0),
(1431655765, 1431655765, 0),
(-2147483648, 0, 1),
(858993459, 858993459, 0),
(715827882, 715827882, 0),
(613566756, 613566756, 0),
(-2147483648, 0, 2),
(477218588, 477218588, 0),
(429496729, 429496729, 0),
(390451572, 390451572, 0),
(357913941, 357913941, 0),
(330382099, 330382099, 0),
(306783378, 306783378, 0),
(286331153, 286331153, 0),
(-2147483648, 0, 3),
(252645135, 252645135, 0),
(238609294, 238609294, 0),
(226050910, 226050910, 0),
(214748364, 214748364, 0),
(204522252, 204522252, 0),
(195225786, 195225786, 0),
(186737708, 186737708, 0),
(178956970, 178956970, 0),
(171798691, 171798691, 0),
(165191049, 165191049, 0),
(159072862, 159072862, 0),
(153391689, 153391689, 0),
(148102320, 148102320, 0),
(143165576, 143165576, 0),
(138547332, 138547332, 0),
(-2147483648, 0, 4),
(130150524, 130150524, 0),
(126322567, 126322567, 0),
(122713351, 122713351, 0),
(119304647, 119304647, 0),
(116080197, 116080197, 0),
(113025455, 113025455, 0),
(110127366, 110127366, 0),
(107374182, 107374182, 0),
(104755299, 104755299, 0),
(102261126, 102261126, 0),
(99882960, 99882960, 0),
(97612893, 97612893, 0),
(95443717, 95443717, 0),
(93368854, 93368854, 0),
(91382282, 91382282, 0),
(89478485, 89478485, 0),
(87652393, 87652393, 0),
(85899345, 85899345, 0),
(84215045, 84215045, 0),
(82595524, 82595524, 0),
(81037118, 81037118, 0),
(79536431, 79536431, 0),
(78090314, 78090314, 0),
(76695844, 76695844, 0),
(75350303, 75350303, 0),
(74051160, 74051160, 0),
(72796055, 72796055, 0),
(71582788, 71582788, 0),
(70409299, 70409299, 0),
(69273666, 69273666, 0),
(68174084, 68174084, 0),
(-2147483648, 0, 5),
(-0b10000000000000000000000000000000, 0, 0),
(0b1010101010101010101010101010101, 0b1010101010101010101010101010101, 0),
(-0b10000000000000000000000000000000, 0, 1),
(0b110011001100110011001100110011, 0b110011001100110011001100110011, 0),
(0b101010101010101010101010101010, 0b101010101010101010101010101010, 0),
(0b100100100100100100100100100100, 0b100100100100100100100100100100, 0),
(-0b10000000000000000000000000000000, 0, 2),
(0b11100011100011100011100011100, 0b11100011100011100011100011100, 0),
(0b11001100110011001100110011001, 0b11001100110011001100110011001, 0),
(0b10111010001011101000101110100, 0b10111010001011101000101110100, 0),
(0b10101010101010101010101010101, 0b10101010101010101010101010101, 0),
(0b10011101100010011101100010011, 0b10011101100010011101100010011, 0),
(0b10010010010010010010010010010, 0b10010010010010010010010010010, 0),
(0b10001000100010001000100010001, 0b10001000100010001000100010001, 0),
(-0b10000000000000000000000000000000, 0, 3),
(0b1111000011110000111100001111, 0b1111000011110000111100001111, 0),
(0b1110001110001110001110001110, 0b1110001110001110001110001110, 0),
(0b1101011110010100001101011110, 0b1101011110010100001101011110, 0),
(0b1111111111111111111111111111000, 0b1111111111111111111111111111000, 0),
(0b1100001100001100001100001100, 0b1100001100001100001100001100, 0),
(0b1011101000101110100010111010, 0b1011101000101110100010111010, 0),
(0b1011001000010110010000101100, 0b1011001000010110010000101100, 0),
(0b1010101010101010101010101010, 0b1010101010101010101010101010, 0),
(0b1010001111010111000010100011, 0b1010001111010111000010100011, 0),
(0b1001110110001001110110001001, 0b1001110110001001110110001001, 0),
(0b1001011110110100001001011110, 0b1001011110110100001001011110, 0),
(0b1001001001001001001001001001, 0b1001001001001001001001001001, 0),
(0b1000110100111101110010110000, 0b1000110100111101110010110000, 0),
(0b1000100010001000100010001000, 0b1000100010001000100010001000, 0),
(0b1000010000100001000010000100, 0b1000010000100001000010000100, 0),
(-0b10000000000000000000000000000000, 0, 4),
(0b111110000011111000001111100, 0b111110000011111000001111100, 0),
(0b111100001111000011110000111, 0b111100001111000011110000111, 0),
(0b111010100000111010100000111, 0b111010100000111010100000111, 0),
(0b111000111000111000111000111, 0b111000111000111000111000111, 0),
(0b110111010110011111001000101, 0b110111010110011111001000101, 0),
(0b110101111001010000110101111, 0b110101111001010000110101111, 0),
(0b110100100000110100100000110, 0b110100100000110100100000110, 0),
(0b110011001100110011001100110, 0b110011001100110011001100110, 0),
(0b110001111100111000001100011, 0b110001111100111000001100011, 0),
(0b110000110000110000110000110, 0b110000110000110000110000110, 0),
(0b101111101000001011111010000, 0b101111101000001011111010000, 0),
(0b101110100010111010001011101, 0b101110100010111010001011101, 0),
(0b101101100000101101100000101, 0b101101100000101101100000101, 0),
(0b101100100001011001000010110, 0b101100100001011001000010110, 0),
(0b101011100100110001000001010, 0b101011100100110001000001010, 0),
(0b101010101010101010101010101, 0b101010101010101010101010101, 0),
(0b101001110010111100000101001, 0b101001110010111100000101001, 0),
(0b101000111101011100001010001, 0b101000111101011100001010001, 0),
(0b101000001010000010100000101, 0b101000001010000010100000101, 0),
(0b100111011000100111011000100, 0b100111011000100111011000100, 0),
(0b100110101001000011100111110, 0b100110101001000011100111110, 0),
(0b100101111011010000100101111, 0b100101111011010000100101111, 0),
(0b100101001111001000001001010, 0b100101001111001000001001010, 0),
(0b100100100100100100100100100, 0b100100100100100100100100100, 0),
(0b100011111011100000100011111, 0b100011111011100000100011111, 0),
(0b100011010011110111001011000, 0b100011010011110111001011000, 0),
(0b100010101101100011110010111, 0b100010101101100011110010111, 0),
(0b100010001000100010001000100, 0b100010001000100010001000100, 0),
(0b100001100100101110001010011, 0b100001100100101110001010011, 0),
(0b100001000010000100001000010, 0b100001000010000100001000010, 0),
(0b100000100000100000100000100, 0b100000100000100000100000100, 0),
(-0b10000000000000000000000000000000, 0, 5),
];
/// A compact list of integers with the given number of bits per entry.

View file

@ -69,7 +69,16 @@ impl PalettedContainer {
"Bits per entry is 0 but data is not empty."
);
let storage = match BitStorage::new(bits_per_entry.into(), size, Some(data)) {
let mut storage = match BitStorage::new(
bits_per_entry.into(),
size,
if data.is_empty() {
Some(vec![])
} else {
// we're going to update the data after creating the bitstorage
None
},
) {
Ok(storage) => storage,
Err(e) => {
warn!("Failed to create bit storage: {:?}", e);
@ -78,6 +87,9 @@ impl PalettedContainer {
));
}
};
// minecraft does this to allow the data to have extra padding bits. most
// servers don't use this, but it's notably used by hypixel.
storage.data = data;
Ok(PalettedContainer {
bits_per_entry,