make deserialization function of slots return default slot when
All checks were successful
Build, test and push / server_clippy (push) Successful in 40s
Build, test and push / lib_clippy (push) Successful in 39s
Build, test and push / server_test (push) Successful in 1m3s
Build, test and push / lib_test (push) Successful in 1m5s
Build, test and push / build_server_docker_image (push) Successful in 3m43s
Build, test and push / push_server (push) Successful in 22s

encountering unknown or not implemented SlotComponents
This commit is contained in:
TheTxT 2025-08-29 19:57:39 +02:00
parent d40b19f499
commit e367da303e

View file

@ -204,9 +204,9 @@ pub fn slot(data: &mut Vec<u8>) -> Result<Slot, Box<dyn Error>> {
8 => SlotComponent::Lore((0..varint(data)?).map(|_| nbt_network(data).unwrap()).collect()),
9 => SlotComponent::Rarity(data.remove(0)),
10 => SlotComponent::Enchantments((0..varint(data)?).map(|_| (varint(data).unwrap(), varint(data).unwrap())).collect()),
11 => todo!(), //SlotComponent::CanPlaceOn,
12 => todo!(), //SlotComponent::CanBreak,
13 => todo!(), //SlotComponent::AttributeModifiers,
//11 => todo!(), //SlotComponent::CanPlaceOn,
//12 => todo!(), //SlotComponent::CanBreak,
//13 => todo!(), //SlotComponent::AttributeModifiers,
14 => SlotComponent::CustomModelData((0..varint(data)?).map(|_| float(data).unwrap()).collect(), (0..varint(data)?).map(|_| boolean(data).unwrap()).collect(), (0..varint(data)?).map(|_| string(data).unwrap()).collect(), (0..varint(data)?).map(|_| int(data).unwrap()).collect()),
15 => SlotComponent::TooltipDisplay(boolean(data)?, (0..varint(data)?).map(|_| varint(data).unwrap()).collect()),
16 => SlotComponent::RepairCost(varint(data)?),
@ -214,19 +214,19 @@ pub fn slot(data: &mut Vec<u8>) -> Result<Slot, Box<dyn Error>> {
18 => SlotComponent::EnchantmentGlintOverride(boolean(data)?),
19 => SlotComponent::IntangibleProjectile(nbt_network(data)?),
20 => SlotComponent::Food(varint(data)?, float(data)?, boolean(data)?),
21 => todo!(), //SlotComponent::Consumable,
//21 => todo!(), //SlotComponent::Consumable,
22 => SlotComponent::UseRemainder(slot(data)?),
23 => SlotComponent::UseCooldown(float(data)?, if boolean(data)? {Some(string(data)?)} else {None}),
24 => SlotComponent::DamageResistant(string(data)?),
25 => todo!(), //SlotComponent::Tool,
//25 => todo!(), //SlotComponent::Tool,
26 => SlotComponent::Weapon(varint(data)?, float(data)?),
27 => SlotComponent::Enchantable(varint(data)?),
28 => todo!(), //SlotComponent::Equippable,
29 => todo!(), //SlotComponent::Repairable,
//28 => todo!(), //SlotComponent::Equippable,
//29 => todo!(), //SlotComponent::Repairable,
30 => SlotComponent::Glider,
31 => SlotComponent::TooltipStyle(string(data)?),
32 => todo!(), //SlotComponent::DeathProtection,
33 => todo!(), //SlotComponent::BlockAttacks,
//32 => todo!(), //SlotComponent::DeathProtection,
//33 => todo!(), //SlotComponent::BlockAttacks,
34 => SlotComponent::StoredEnchantments((0..varint(data)?).map(|_| (varint(data).unwrap(), varint(data).unwrap())).collect()),
35 => SlotComponent::DyedColor(int(data)?),
36 => SlotComponent::MapColor(int(data)?),
@ -235,28 +235,28 @@ pub fn slot(data: &mut Vec<u8>) -> Result<Slot, Box<dyn Error>> {
39 => SlotComponent::MapPostProcessing(data.remove(0)),
40 => SlotComponent::ChargedProjectiles((0..varint(data)?).map(|_| slot(data).unwrap()).collect()),
41 => SlotComponent::BundleContents((0..varint(data)?).map(|_| slot(data).unwrap()).collect()),
42 => todo!(), //SlotComponent::PotionContents,
//42 => todo!(), //SlotComponent::PotionContents,
43 => SlotComponent::PotionDurationScale(float(data)?),
44 => SlotComponent::SuspiciousStewEffects((0..varint(data)?).map(|_| (varint(data).unwrap(), varint(data).unwrap())).collect()),
45 => SlotComponent::WritableBookContent((0..varint(data)?).map(|_| (string(data).unwrap(), if boolean(data).unwrap() {Some(string(data).unwrap())} else {None})).collect()),
46 => SlotComponent::WrittenBookContent((0..varint(data)?).map(|_| (string(data).unwrap(), if boolean(data).unwrap() {Some(string(data).unwrap())} else {None})).collect()),
47 => todo!(), //SlotComponent::Trim,
//47 => todo!(), //SlotComponent::Trim,
48 => SlotComponent::DebugStickState(nbt_network(data)?),
49 => SlotComponent::EntityData(nbt_network(data)?),
50 => SlotComponent::BucketEntityData(nbt_network(data)?),
51 => SlotComponent::BlockEntityData(nbt_network(data)?),
52 => todo!(), //SlotComponent::Instrument,
53 => todo!(), //SlotComponent::ProvidesTrimMaterial,
//52 => todo!(), //SlotComponent::Instrument,
//53 => todo!(), //SlotComponent::ProvidesTrimMaterial,
54 => SlotComponent::OminousBottleAmplifier(data.remove(0)),
55 => todo!(), //SlotComponent::JukeboxPlayable,
//55 => todo!(), //SlotComponent::JukeboxPlayable,
56 => SlotComponent::ProvidesBannerPatterns(string(data)?),
57 => SlotComponent::Recipes(nbt_network(data)?),
58 => SlotComponent::LodestoneTracker(boolean(data)?, string(data)?, position(data)?, boolean(data)?),
59 => todo!(), //SlotComponent::FireworkExplosion,
60 => todo!(), //SlotComponent::Fireworks,
//59 => todo!(), //SlotComponent::FireworkExplosion,
//60 => todo!(), //SlotComponent::Fireworks,
61 => SlotComponent::Profile(if boolean(data)? {Some(string(data)?)} else {None}, if boolean(data)? {Some(uuid(data)?)} else {None}, (0..varint(data)?).map(|_| (string(data).unwrap(), string(data).unwrap(), if boolean(data).unwrap() {Some(string(data).unwrap())} else {None})).collect()),
62 => SlotComponent::NoteblockSound(string(data)?),
63 => todo!(), //SlotComponent::BannerPatterns,
//63 => todo!(), //SlotComponent::BannerPatterns,
64 => SlotComponent::BaseColor(data.remove(0)),
65 => SlotComponent::PotDecorations((0..varint(data)?).map(|_| varint(data).unwrap()).collect()),
66 => SlotComponent::Container((0..varint(data)?).map(|_| varint(data).unwrap()).collect()),
@ -264,10 +264,10 @@ pub fn slot(data: &mut Vec<u8>) -> Result<Slot, Box<dyn Error>> {
68 => SlotComponent::Bees((0..varint(data)?).map(|_| (nbt_network(data).unwrap(), varint(data).unwrap(), varint(data).unwrap())).collect()),
69 => SlotComponent::Lock(nbt_network(data)?),
70 => SlotComponent::ContainerLoot(nbt_network(data)?),
71 => todo!(), //SlotComponent::BreakSound,
72 => todo!(), //SlotComponent::VillagerVariant,
73 => todo!(), //SlotComponent::WolfVariant,
74 => todo!(), //SlotComponent::WolfSoundVariant,
//71 => todo!(), //SlotComponent::BreakSound,
//72 => todo!(), //SlotComponent::VillagerVariant,
//73 => todo!(), //SlotComponent::WolfVariant,
//74 => todo!(), //SlotComponent::WolfSoundVariant,
75 => SlotComponent::WolfCollar(data.remove(0)),
76 => SlotComponent::FoxVariant(data.remove(0)),
77 => SlotComponent::SalmonSize(data.remove(0)),
@ -279,17 +279,20 @@ pub fn slot(data: &mut Vec<u8>) -> Result<Slot, Box<dyn Error>> {
83 => SlotComponent::RabbitVariant(data.remove(0)),
84 => SlotComponent::PigVariant(data.remove(0)),
85 => SlotComponent::CowVariant(data.remove(0)),
86 => todo!(), //SlotComponent::ChickenVariant,
//86 => todo!(), //SlotComponent::ChickenVariant,
87 => SlotComponent::FrogVariant(varint(data)?),
88 => SlotComponent::HorseVariant(data.remove(0)),
89 => todo!(), //SlotComponent::PaintingVariant,
//89 => todo!(), //SlotComponent::PaintingVariant,
90 => SlotComponent::LlamaVariant(data.remove(0)),
91 => SlotComponent::AxolotlVariant(data.remove(0)),
92 => SlotComponent::CatVariant(varint(data)?),
93 => SlotComponent::CatCollar(data.remove(0)),
94 => SlotComponent::SheepColor(data.remove(0)),
95 => SlotComponent::ShulkerColor(data.remove(0)),
x => panic!("I cant deserialize the SlotComponent with id {x}, because I dont know it"),
x => {
println!("I cant deserialize the SlotComponent with id {x}, because I dont know it");
return Ok(Slot::default()); //TODO: Cant safely parse the rest so lets fall back to just default
},
});
}
let mut components_to_remove: Vec<i32> = Vec::new();