Skip to content
This repository was archived by the owner on Dec 24, 2024. It is now read-only.

Commit c5458de

Browse files
committedJun 19, 2021
update connection
1 parent fd26120 commit c5458de

22 files changed

+312
-91
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/target
22
.idea
33
storage.db
4+
cache.db
45
users.csv
56
proxies.csv

‎Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ flexbuffers = "2.0"
7070
packets = { path = "packets" } # from a path in the local filesystem
7171

7272
[profile.release]
73-
lto = "fat"
74-
codegen-units = 1
73+
#lto = "fat"
74+
#codegen-units = 1

‎src/bootstrap/dns.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::error::Res;
88
async fn dns_lookup(host: &str) -> Result<Address, ResolveError> {
99
let resolver = AsyncResolver::tokio(ResolverConfig::default(), ResolverOpts::default()).unwrap();
1010

11+
println!("performing srv lookup");
1112
resolver.srv_lookup(format!("_minecraft._tcp.{}", host)).await.map(|res| {
1213
let srv = res.iter().next().unwrap();
1314
Address {

‎src/bootstrap/mojang.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct Mojang {
1515

1616
impl Mojang {
1717
pub fn socks5(proxy: &Proxy) -> Res<Mojang> {
18-
18+
1919
let address = proxy.address();
2020
let user = &proxy.user;
2121
let pass = &proxy.pass;
@@ -152,7 +152,6 @@ impl Mojang {
152152
.await?;
153153

154154
let status = res.status();
155-
println!("validate got {}", status);
156155
Ok(status == 204)
157156
}
158157

‎src/bootstrap/opts.rs

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use clap::{AppSettings, Clap};
66
pub struct Opts {
77
pub host: String,
88

9+
#[clap(long)]
10+
pub load: bool,
11+
912
#[clap(short, long, default_value = "1")]
1013
pub count: usize,
1114

‎src/bootstrap/storage.rs

+33-17
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub struct ValidUser {
3737
pub email: String,
3838
pub username: String,
3939
pub password: String,
40-
pub last_checked: u128,
41-
pub uuid: u128,
40+
pub last_checked: u64,
41+
pub uuid: String,
4242
pub access_id: String,
4343
pub client_id: String,
4444
}
@@ -70,12 +70,12 @@ pub struct ProxyUser {
7070

7171
async fn validate_user(user: &ValidUser, proxy: &Proxy) {}
7272

73-
fn time() -> u128 {
73+
fn time() -> u64 {
7474
let start = SystemTime::now();
7575
let since_the_epoch = start
7676
.duration_since(UNIX_EPOCH)
7777
.expect("Time went backwards");
78-
since_the_epoch.as_millis()
78+
since_the_epoch.as_secs()
7979
}
8080

8181
impl Drop for UserCache {
@@ -135,7 +135,7 @@ impl UserCache {
135135
username: res.username,
136136
password: user.password.clone(),
137137
last_checked: time(),
138-
uuid: res.uuid.0,
138+
uuid: res.uuid.to_string(),
139139
access_id: res.access_token,
140140
client_id: res.client_token,
141141
};
@@ -160,13 +160,19 @@ impl UserCache {
160160
User::Valid(valid) => {
161161
let proxy = iter.next().unwrap();
162162
let mojang = Mojang::socks5(&proxy).unwrap();
163+
164+
// if verified in last day don't even check to verify
165+
if time() - valid.last_checked < 3600 * 24 {
166+
return Some((mojang, proxy, valid.clone()));
167+
}
168+
163169
let is_valid = mojang.validate(&valid.access_id, &valid.client_id).await.unwrap();
164170
if !is_valid {
165171
match mojang.refresh(&valid.access_id, &valid.client_id).await {
166172
Ok(auth) => {
167173
valid.access_id = auth.access_token;
168174
valid.username = auth.username;
169-
valid.uuid = auth.uuid.0;
175+
valid.uuid = auth.uuid.to_string();
170176
valid.client_id = auth.client_token;
171177
valid.last_checked = time();
172178
return Some((mojang, proxy, valid.clone()));
@@ -178,7 +184,7 @@ impl UserCache {
178184
Ok(auth) => {
179185
valid.access_id = auth.access_token;
180186
valid.username = auth.username;
181-
valid.uuid = auth.uuid.0;
187+
valid.uuid = auth.uuid.to_string();
182188
valid.client_id = auth.client_token;
183189
valid.last_checked = time();
184190
return Some((mojang, proxy, valid.clone()));
@@ -194,6 +200,8 @@ impl UserCache {
194200
}
195201
}
196202
}
203+
} else {
204+
return Some((mojang, proxy, valid.clone()));
197205
}
198206
}
199207
User::Invalid(invalid) => {}
@@ -204,21 +212,29 @@ impl UserCache {
204212
}
205213

206214
pub fn obtain_users(mut self, count: usize, users: Vec<CSVUser>, proxies: Vec<Proxy>) -> Receiver<ProxyUser> {
215+
println!("obtaining users");
207216
let mut proxies = proxies.into_iter().cycle();
208217

209218
let (tx, rx) = tokio::sync::mpsc::channel(1);
210219

211220
tokio::task::spawn_local(async move {
212-
for csv_user in users.into_iter().take(count) {
213-
match self.get_or_put(&csv_user, &mut proxies).await {
214-
Some((mojang, proxy, user)) => {
215-
tx.send(ProxyUser {
216-
user,
217-
proxy,
218-
mojang,
219-
}).await.unwrap();
220-
}
221-
_ => {}
221+
let mut local_count = 0;
222+
for csv_user in users.into_iter() {
223+
if let Some((mojang, proxy, user)) = self.get_or_put(&csv_user, &mut proxies).await {
224+
local_count += 1;
225+
println!("valid user {}", user.email);
226+
tx.send(ProxyUser {
227+
user,
228+
proxy,
229+
mojang,
230+
}).await.unwrap();
231+
} else {
232+
println!("invalid user {}", csv_user.email);
233+
}
234+
235+
if local_count >= count {
236+
println!("ret");
237+
return;
222238
}
223239
}
224240
});

‎src/client/follow/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::collections::VecDeque;
22
use crate::client::pathfind::context::MoveContext;
3-
use crate::client::instance::State;
43
use crate::protocol::McProtocol;
54
use crate::storage::block::BlockLocation;
65
use crate::types::Location;
6+
use crate::client::state::local::State;
77

88
pub struct Follower {
99
head: MoveContext,
@@ -39,4 +39,4 @@ impl Follower {
3939

4040
protocol.teleport(new_loc)
4141
}
42-
}
42+
}

‎src/client/instance.rs

+30-44
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
use std::rc::Rc;
2+
use std::time::Duration;
3+
14
use packets::types::UUID;
5+
use tokio::sync::Notify;
26

3-
use crate::client::runner::GlobalState;
4-
use crate::protocol::McProtocol;
5-
use crate::storage::world::WorldBlocks;
6-
use crate::types::Location;
7-
use crate::storage::block::BlockLocation;
8-
// use crate::client::pathfind::bidirectional::a_star_bi;
9-
use crate::client::pathfind::progress_checker::{NoVehicleProgressor, NoVehicleHeuristic, NoVehicleGoalCheck, GoalCheck};
7+
use crate::client::follow::Follower;
108
use crate::client::pathfind::context::{GlobalContext, MoveContext};
119
use crate::client::pathfind::incremental::{AStar, PathResult};
12-
use std::time::Duration;
10+
use crate::client::pathfind::progress_checker::{GoalCheck, NoVehicleGoalCheck, NoVehicleHeuristic, NoVehicleProgressor};
1311
use crate::client::timing::Increment;
14-
use crate::client::follow::Follower;
12+
use crate::protocol::McProtocol;
13+
use crate::storage::block::BlockLocation;
14+
use crate::storage::world::WorldBlocks;
15+
use crate::types::Location;
16+
use crate::client::state::local::State;
17+
use crate::client::state::global::GlobalState;
18+
1519

1620
#[derive(Debug)]
1721
pub struct ClientInfo {
@@ -20,25 +24,21 @@ pub struct ClientInfo {
2024
pub entity_id: u32,
2125
}
2226

23-
24-
pub struct State {
25-
pub ticks: usize,
26-
pub info: ClientInfo,
27-
pub destination: BlockLocation,
28-
pub alive: bool,
29-
pub follower: Option<Follower>,
30-
pub finder_problem: Option<TravelProblem>,
31-
pub location: Location
32-
}
33-
3427
pub struct TravelPath {
35-
blocks: Vec<BlockLocation>
28+
blocks: Vec<BlockLocation>,
3629
}
3730

3831
pub struct TravelProblem {
39-
a_star: AStar<MoveContext>,
40-
heuristic: NoVehicleHeuristic,
41-
goal_checker: NoVehicleGoalCheck
32+
pub a_star: AStar<MoveContext>,
33+
pub heuristic: NoVehicleHeuristic,
34+
pub goal_checker: NoVehicleGoalCheck,
35+
pub notifier: Rc<Notify>,
36+
}
37+
38+
impl Drop for TravelProblem {
39+
fn drop(&mut self) {
40+
self.notifier.notify_one();
41+
}
4242
}
4343

4444
pub struct Client<T: McProtocol> {
@@ -53,20 +53,10 @@ const fn ticks_from_secs(seconds: usize) -> usize {
5353
impl<T: McProtocol> Client<T> {
5454
pub fn run_sync(&mut self, global: &mut GlobalState) {
5555
self.move_around();
56-
self.anti_afk();
57-
5856
self.state.ticks += 1;
5957
}
6058

61-
fn anti_afk(&mut self) {
62-
const MESSAGE_TICKS: usize = ticks_from_secs(15); // every 15 seconds
63-
if self.state.ticks % MESSAGE_TICKS == 0 {
64-
// throwaway command to prevent anti afk
65-
self.protocol.send_chat("/wot");
66-
}
67-
}
68-
69-
fn move_around(&mut self){
59+
fn move_around(&mut self) {
7060
if self.state.ticks % 20 != 0 {
7161
return;
7262
}
@@ -78,27 +68,23 @@ impl<T: McProtocol> Client<T> {
7868
}
7969

8070

81-
82-
pub fn run_threaded(client: &mut State, global: &GlobalState){
83-
84-
if let Some(traverse) = client.finder_problem.as_mut() {
85-
71+
pub fn run_threaded(client: &mut State, global: &GlobalState) {
72+
if let Some(traverse) = client.travel_problem.as_mut() {
8673
let ctx = GlobalContext {
8774
path_config: &global.travel_config,
88-
world: &global.world_blocks
75+
world: &global.world_blocks,
8976
};
9077

9178
let progressor = NoVehicleProgressor::new(ctx);
9279

9380
let res = traverse.a_star.iterate_for(Duration::from_millis(30), &traverse.heuristic, &progressor, &traverse.goal_checker);
9481

9582
if let Increment::Finished(res) = res {
96-
9783
if let Some(res) = res {
9884
client.follower = Follower::new(res);
9985
}
10086
// we are done finding the path
101-
client.finder_problem = None;
87+
client.travel_problem = None;
10288
}
10389
}
104-
}
90+
}

‎src/client/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ pub mod runner;
33
mod pathfind;
44
mod timing;
55
mod follow;
6+
mod priorities;
7+
pub mod state;

‎src/client/pathfind/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ pub struct GlobalContext<'a> {
3737
#[derive(Clone, Eq, PartialEq, Hash)]
3838
pub struct MoveContext {
3939
pub location: BlockLocation,
40-
pub blocks_can_place: u32
40+
pub blocks_can_place: usize
4141
}

‎src/client/pathfind/moves.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::client::pathfind::moves::Movements::TraverseCardinal;
33
use crate::client::pathfind::progress_checker::{Neighbor, Progression};
44
use crate::storage::block::{AIR, BlockApprox, BlockLocation, SimpleType};
55
use crate::storage::world::WorldBlocks;
6-
use crate::client::runner::GlobalState;
76

87
enum MoveResult {
98
Edge,

‎src/client/priorities/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use crate::storage::world::ChunkLocation;
2+
use crate::storage::block::{BlockApprox, BlockState};

‎src/client/runner.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@ use rayon::Scope;
77
use tokio::task::JoinHandle;
88

99
use crate::bootstrap::Connection;
10-
use crate::client::instance::{Client, State, run_threaded};
10+
use crate::client::instance::{Client, run_threaded};
1111
use crate::error::Error;
1212
use crate::protocol::{Login, McProtocol};
1313
use crate::storage::world::WorldBlocks;
1414
use crate::types::Location;
15-
use crate::client::pathfind::context::{GlobalContext, PathConfig};
15+
use crate::client::pathfind::context::{GlobalContext, PathConfig, Costs};
1616
use crate::storage::block::BlockLocation;
17+
use crate::client::state::global::GlobalState;
18+
use crate::client::state::local::State;
19+
use crate::client::state::Dimension;
20+
use crate::client::state::inventory::Inventory;
1721

18-
#[derive(Default)]
19-
pub struct GlobalState{
20-
pub world_blocks: WorldBlocks,
21-
pub travel_config: PathConfig,
22-
}
2322

2423
pub struct Runner<T: McProtocol> {
2524
pending_logins: Rc<RefCell<Vec<Login<T>>>>,
@@ -100,12 +99,20 @@ impl<T: McProtocol + 'static> Runner<T> {
10099
let client = Client {
101100
state: State {
102101
ticks: 0,
102+
inventory: Inventory {},
103103
alive: true,
104+
dimension: Dimension::Overworld,
104105
follower: None,
105106
info,
106107
location: Location::default(),
107108
destination: BlockLocation(119, 72, 226),
108-
finder_problem: None
109+
travel_problem: None,
110+
costs: Costs {
111+
block_walk: 1.0,
112+
ascend: 1.0,
113+
fall: 1.0,
114+
block_place: 1.0
115+
}
109116
},
110117
protocol,
111118
};

‎src/client/state/global.rs

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
use crate::client::pathfind::context::PathConfig;
2+
use crate::storage::world::WorldBlocks;
3+
use std::collections::HashSet;
4+
5+
#[derive(Default)]
6+
pub struct GlobalState {
7+
pub world_blocks: WorldBlocks,
8+
pub travel_config: PathConfig,
9+
}
10+
11+
impl GlobalState {
12+
/// # Goal
13+
/// we want to assign regions to explore for each bot
14+
/// we want to explore in rings
15+
///
16+
/// ```
17+
/// 33333
18+
/// 32223
19+
/// 32123
20+
/// 32223
21+
/// 33333
22+
/// ```
23+
///
24+
/// Think of this as a priority queue where low numbers have a higher priority. It is easy to connect all regions
25+
/// because the chunks loaded are in a square in Minecraft and not a circle. Therefore, we can make sure sections
26+
/// will not collide.
27+
///
28+
/// # Assignment
29+
/// ## Initial
30+
/// Initially, this will just be a priority queue. All bots will get assigned a slot and walk to it
31+
///
32+
/// ## Next Step
33+
/// A naïve approach would be always taking the region with the least priority and breaking ties with distance.
34+
/// However, assume a bot is at an x and the last remaining region at the tie-breaking priority is an o
35+
/// ```
36+
/// ..x
37+
/// ...
38+
/// o..
39+
/// ```
40+
///
41+
/// This would be a long traversal. In addition, assume this was a thousand blocks away. This would take a lot of extra time. Ideally we would
42+
/// have a bot that will finish the task in a little period of time go to it. Instead we will have bots choose the smallest priority adjacent to
43+
/// it else if there are no adj the closest next smallest. Let's see how this would play out
44+
///
45+
///```
46+
/// 4321.
47+
/// 5..0.
48+
/// 6....
49+
/// 78...
50+
/// 9....
51+
///```
52+
/// or equally likely
53+
///
54+
///```
55+
/// ...12
56+
/// ...03
57+
/// 3...4
58+
/// 12..5
59+
/// 09876
60+
///```
61+
/// ## Data structure
62+
/// We want to make it easy for bots to follow the graph. Let us denote each grid as `(x,y)`, where the priority is `max(abs(x),abs(y))`
63+
///
64+
///```
65+
///(-1, 1)(0, 1)(1, 1)
66+
///(-1, 0)(0, 0)(1, 0)
67+
///(-1,-1)(0,-1)(1,-1)
68+
///```
69+
///
70+
/// We _could_ use a [`std::collections::hash::HashSet`] with an i32 tuple, but we could also use a wrapping structure
71+
///
72+
/// ```
73+
/// 123
74+
/// 804
75+
/// 765
76+
/// ```
77+
///
78+
/// We will use a HashMap for now though since it is simpler
79+
/// the lengths are 1, (3*3 - prev) = 8, (5*5) - prev = 17.
80+
/// There is a clock-wise wrapping where the top left is the first element.
81+
///
82+
async fn explore_circular(&mut self) {
83+
todo!()
84+
// // initial
85+
86+
// let mut left_over = HashSet::new();
87+
// left_over.insert((0, 0));
88+
// let mut r = 0;
89+
}
90+
}

‎src/client/state/inventory.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub struct Inventory {
2+
3+
}
4+
5+
impl Inventory {
6+
pub fn placeable_blocks(&self) -> usize{
7+
todo!()
8+
}
9+
}

‎src/client/state/local.rs

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
use crate::client::state::inventory::Inventory;
2+
use crate::client::pathfind::context::{Costs, MoveContext};
3+
use crate::client::instance::{ClientInfo, TravelProblem};
4+
use crate::storage::block::BlockLocation;
5+
use crate::client::state::Dimension;
6+
use crate::client::follow::Follower;
7+
use crate::types::Location;
8+
use crate::client::pathfind::incremental::AStar;
9+
use tokio::sync::Notify;
10+
use std::rc::Rc;
11+
use crate::client::pathfind::progress_checker::{NoVehicleHeuristic, NoVehicleGoalCheck};
12+
13+
pub struct State {
14+
pub ticks: usize,
15+
pub inventory: Inventory,
16+
pub costs: Costs,
17+
pub info: ClientInfo,
18+
pub destination: BlockLocation,
19+
pub alive: bool,
20+
pub dimension: Dimension,
21+
pub follower: Option<Follower>,
22+
pub travel_problem: Option<TravelProblem>,
23+
pub location: Location,
24+
}
25+
26+
impl State {
27+
pub fn block_location(&self) -> BlockLocation {
28+
let Location { x, y, z } = self.location;
29+
BlockLocation(x.floor() as i64, y.floor() as i64, z.floor() as i64)
30+
}
31+
32+
async fn travel_to_block(&mut self, goal: BlockLocation) {
33+
let from = self.block_location();
34+
35+
36+
// https://github.com/tokio-rs/tokio/releases/tag/tokio-0.2.12
37+
let notifier = Rc::new(Notify::new());
38+
39+
let start_node = MoveContext {
40+
location: from,
41+
blocks_can_place: self.inventory.placeable_blocks(),
42+
};
43+
44+
let heuristic = NoVehicleHeuristic {
45+
move_cost: self.costs.block_walk,
46+
goal,
47+
};
48+
49+
let goal_checker = NoVehicleGoalCheck::new(goal);
50+
51+
let a_star = AStar::new(start_node);
52+
53+
54+
let problem = TravelProblem {
55+
a_star,
56+
heuristic,
57+
goal_checker,
58+
notifier: notifier.clone(),
59+
};
60+
61+
62+
self.travel_problem = Some(problem);
63+
64+
notifier.notified().await;
65+
}
66+
}

‎src/client/state/mod.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use std::rc::Rc;
2+
3+
use tokio::sync::Notify;
4+
5+
use crate::client::follow::Follower;
6+
use crate::client::instance::{ClientInfo, TravelProblem};
7+
use crate::client::pathfind::context::{Costs, MoveContext};
8+
use crate::client::pathfind::incremental::AStar;
9+
use crate::client::pathfind::progress_checker::{NoVehicleGoalCheck, NoVehicleHeuristic};
10+
use crate::client::state::inventory::Inventory;
11+
use crate::storage::block::{BlockLocation, BlockState};
12+
use crate::types::Location;
13+
use std::collections::{HashMap, HashSet};
14+
15+
pub mod inventory;
16+
pub mod global;
17+
pub mod local;
18+
19+
pub enum Dimension {
20+
Overworld,
21+
Nether,
22+
End,
23+
}

‎src/main.rs

+22-8
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,45 @@ fn main() {
4343
}
4444

4545
async fn run() -> ResContext<()> {
46-
let Opts { users_file, proxy, proxies_file, host, count, version, port, db, delay, .. } = Opts::get();
46+
let Opts { users_file, proxy, proxies_file, host, count, version, port, db, delay, load, ..} = Opts::get();
4747

4848
let address = normalize_address(&host, port).await;
4949

5050
// A list of users we will login
51-
let proxy_users = {
51+
let mut proxy_users = {
52+
println!("reading {}", users_file);
5253
let csv_file = File::open(&users_file).context(||format!("could not open users file {}", users_file))?;
5354
let csv_users = bootstrap::csv::read_users(csv_file).context_str("could not open users file")?;
5455

56+
println!("reading {}", proxies_file);
5557
let proxies_file = File::open(&proxies_file).context(||format!("could not open proxies file {}", proxies_file))?;
5658
let proxies = bootstrap::csv::read_proxies(proxies_file).context_str("could not open proxies file")?;
5759

60+
println!("reading cache.db");
5861
let mut cache = UserCache::load("cache.db".into());
62+
63+
println!("obtaining users from cache");
5964
cache.obtain_users(count, csv_users, proxies)
6065
};
6166

62-
// taking the users and generating connections to the Minecraft server
63-
let connections = Connection::stream(address, proxy_users);
67+
if load {
68+
while proxy_users.recv().await.is_some() {
69+
// empty
70+
}
71+
return Ok(());
72+
}
73+
else {
74+
// taking the users and generating connections to the Minecraft server
75+
let connections = Connection::stream(address, proxy_users);
6476

65-
let opts = RunnerOptions { delay_millis: delay };
77+
let opts = RunnerOptions { delay_millis: delay };
6678

67-
match version {
68-
340 => Runner::<protocol::v340::Protocol>::run(connections, opts).await,
69-
_ => { panic!("version {} does not exist", version) }
79+
match version {
80+
340 => Runner::<protocol::v340::Protocol>::run(connections, opts).await,
81+
_ => { panic!("version {} does not exist", version) }
82+
}
7083
}
7184

85+
7286
Ok(())
7387
}

‎src/protocol/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use crate::bootstrap::Connection;
2-
use crate::client::instance::{Client, ClientInfo, State};
3-
use crate::client::runner::GlobalState;
2+
use crate::client::instance::{Client, ClientInfo};
43
use crate::error::Res;
54
use crate::types::Location;
5+
use crate::client::state::local::State;
6+
use crate::client::state::global::GlobalState;
67

78
pub mod v340;
89

‎src/protocol/v340/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use tokio::time::{Duration, sleep};
77

88
use crate::bootstrap::{Connection, CSVUser, Address};
99
use crate::bootstrap::mojang::{AuthResponse, calc_hash, Mojang};
10-
use crate::client::instance::{ClientInfo, State};
11-
use crate::client::runner::GlobalState;
10+
use crate::client::instance::{ClientInfo};
1211
use crate::error::Error::WrongPacket;
1312
use crate::error::Res;
1413
use crate::protocol::{Login, McProtocol};
@@ -21,6 +20,8 @@ use crate::protocol::v340::serverbound::{HandshakeNextState, TeleportConfirm};
2120
use rand::{thread_rng, Rng};
2221
use crate::storage::world::ChunkLocation;
2322
use crate::bootstrap::storage::ValidUser;
23+
use crate::client::state::local::State;
24+
use crate::client::state::global::GlobalState;
2425

2526
mod clientbound;
2627
mod serverbound;
@@ -39,7 +40,7 @@ impl McProtocol for Protocol {
3940
let ValidUser { email, username, password, last_checked, uuid, access_id, client_id } = user;
4041

4142
let Address { host, port } = address;
42-
let uuid = UUID(uuid);
43+
let uuid = UUID::from(&uuid);
4344

4445
let mut reader = PacketReader::from(read);
4546
let mut writer = PacketWriter::from(write);

‎src/storage/chunk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl LowMemoryChunkSection {
3030
let offset = block_number - (idx << 2);
3131

3232
let mut res = self.storage[idx];
33-
res = res >> offset;
33+
res >>= offset;
3434
res &= 0b11;
3535

3636
SimpleType::from(res)

‎src/storage/world.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ impl WorldBlocks {
1616
pub fn add_column(&mut self, location: ChunkLocation, column: ChunkColumn){
1717
self.storage.insert(location, column);
1818
}
19+
1920
pub fn get_block(&self, location: BlockLocation) -> Option<BlockApprox> {
2021
let BlockLocation(x, y, z) = location;
2122

0 commit comments

Comments
 (0)
This repository has been archived.