Skip to content

Commit

Permalink
1.21.50
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaileke committed Dec 12, 2024
1 parent 020b9a9 commit 548009b
Show file tree
Hide file tree
Showing 6 changed files with 317 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rand = "0.9.0-alpha.2"
tokio = "1.41.0"
base64 = "0.22.1"
openssl = "0.10.68"
serde = { version = "1.0.213", features = ["derive"] }
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
flate2 = "1.0.34"
chrono = "0.4.38"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use raknet_client::client;

#[tokio::main]
async fn main() {
let client = client::create("127.0.0.1".to_string(), 19132, "1.21.40".to_string(), true); // target address, target port, client version, debug mode
let client = client::create("127.0.0.1".to_string(), 19132, "1.21.50".to_string(), true); // target address, target port, client version, debug mode
client.await.unwrap().connect().expect("Target IP Connection Error");
}
```
Expand Down
19 changes: 16 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use openssl::ec::EcKey;
use openssl::pkey::{PKey, Private};
use rand::Rng;
use serde_json::Value;
use std::collections::HashMap;
use std::collections::{BTreeMap, HashMap};
use std::io::Result;
use std::net::UdpSocket;
use mojang_nbt::tag::tag::Tag;
Expand All @@ -33,7 +33,7 @@ use crate::protocol::open_conn_reply1::OpenConnReply1;
use crate::protocol::open_conn_reply2::OpenConnReply2;
use crate::protocol::open_conn_req1::OpenConnReq1;
use crate::protocol::open_conn_req2::OpenConnReq2;
use crate::utils::chunk::block::{BlockType, PropertyValues};
use crate::utils::chunk::block::{BlockMapBuilder, BlockType, PropertyValues};
//use crate::handle_incoming_data;


Expand Down Expand Up @@ -63,6 +63,7 @@ pub struct Client {
}

pub async fn create(target_address: String, target_port: u16, client_version: String, debug: bool) -> Option<Client> {
//block::vanilla_block_map(false, &vec![]);
let mut bedrock = bedrock::new(client_version, false);
if !bedrock.auth().await { return None; }
let mut rng = rand::thread_rng();
Expand Down Expand Up @@ -401,11 +402,16 @@ impl Client {
println!("current_tick: {}", start_game.current_tick);
println!("enchantment_seed: {}", start_game.enchantment_seed);

//block::vanilla_block_map();

let mut builder = BlockMapBuilder::new();

let block_palette = start_game.block_palette;
for block in &block_palette {

println!("Block Name: {}", block.get_name().clone());
let mut block_type: BlockType = BlockType::new(block.get_name());
let mut block_properties: HashMap<String, PropertyValues> = HashMap::new();
let mut block_properties: BTreeMap<String, PropertyValues> = BTreeMap::new();

let root = block.get_states().get_root();
let bct = root.as_any().downcast_ref::<CompoundTag>().unwrap();
Expand All @@ -420,6 +426,7 @@ impl Client {
let c_tag = value.as_any().downcast_ref::<CompoundTag>().unwrap();

let property_name = c_tag.get_string("name").unwrap();
println!(" - Property name: {}", property_name);
let list_enum = c_tag.get_list_tag("enum".to_string()).unwrap();

let mut strings = Vec::new();
Expand All @@ -428,10 +435,13 @@ impl Client {
for value in list_enum.get_value().downcast_ref::<Vec<Box<dyn Tag>>>().unwrap() {
let inner_value = value.get_value();
if let Some(v) = inner_value.downcast_ref::<String>() {
println!(" - Enum (String): {}", v);
strings.push(v.to_string());
} else if let Some(v) = inner_value.downcast_ref::<u32>() {
println!(" - Enum (u32): {}", v);
ints.push(v.clone());
} else if let Some(v) = inner_value.downcast_ref::<bool>() {
println!(" - Enum (bool): {}", v);
bools.push(v.clone());
} else {
println!("enum: value - Unknown type");
Expand All @@ -442,11 +452,14 @@ impl Client {
block_properties.insert(property_name, enums);
block_type.properties = block_properties.clone();

builder.insert_block(block_type.clone());
}
}

}

let _block_map = builder.build();

println!("multiplayer_correlation_id: {}", start_game.multiplayer_correlation_id);
println!("enable_new_inventory_system: {}", start_game.enable_new_inventory_system);
println!("server_software_version: {}", start_game.server_software_version);
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod protocol;
pub mod utils;

const RAKNET_PROTOCOL_VERSION: u8 = 11;
const BEDROCK_PROTOCOL_VERSION: u32 = 748;
const BEDROCK_PROTOCOL_VERSION: u32 = 766;

/*
use std::ffi::CStr;
Expand Down
6 changes: 5 additions & 1 deletion src/protocol/game/bedrock_packet_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ pub enum BedrockPacketType {
ContainerRegistryCleanup,
MovementEffect,
SetMovementAuthority,
CameraAimAssistPresets,
Unknown
}

Expand Down Expand Up @@ -414,6 +415,7 @@ impl BedrockPacketType {
0x13d => BedrockPacketType::ContainerRegistryCleanup,
0x13e => BedrockPacketType::MovementEffect,
0x13f => BedrockPacketType::SetMovementAuthority,
0x140 => BedrockPacketType::CameraAimAssistPresets,
_ => BedrockPacketType::Unknown,
}
}
Expand Down Expand Up @@ -623,6 +625,7 @@ impl BedrockPacketType {
BedrockPacketType::ContainerRegistryCleanup => 0x13d,
BedrockPacketType::MovementEffect => 0x13e,
BedrockPacketType::SetMovementAuthority => 0x13f,
BedrockPacketType::CameraAimAssistPresets => 0x140,
_ => 0
}
}
Expand Down Expand Up @@ -832,7 +835,8 @@ impl BedrockPacketType {
0x13d => "Container Registry Cleanup",
0x13e => "Movement Effect",
0x13f => "Set Movement Authority",
0x140 => "Camera Aim Assist Presets",
_ => "Unknown Packet"
}
}
}
}
Loading

0 comments on commit 548009b

Please sign in to comment.