From 4e302ca09feb6309abc312a277dc410b9ba859d5 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 19 Dec 2022 06:11:03 -0800 Subject: [PATCH] Remove remaining unnecessary casts in examples --- examples/chest.rs | 2 +- examples/conway.rs | 13 ++++--------- examples/inventory_piano.rs | 13 ++++--------- examples/parkour.rs | 2 +- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/examples/chest.rs b/examples/chest.rs index e80d88e..53ca907 100644 --- a/examples/chest.rs +++ b/examples/chest.rs @@ -86,7 +86,7 @@ impl Config for Game { for chunk_z in -2..Integer::div_ceil(&(SIZE_Z as i32), &16) + 2 { for chunk_x in -2..Integer::div_ceil(&(SIZE_X as i32), &16) + 2 { world.chunks.insert( - [chunk_x as i32, chunk_z as i32], + [chunk_x, chunk_z], UnloadedChunk::default(), (), ); diff --git a/examples/conway.rs b/examples/conway.rs index 64c03c7..47a8783 100644 --- a/examples/conway.rs +++ b/examples/conway.rs @@ -90,11 +90,9 @@ impl Config for Game { for chunk_z in -2..Integer::div_ceil(&(SIZE_Z as i32), &16) + 2 { for chunk_x in -2..Integer::div_ceil(&(SIZE_X as i32), &16) + 2 { - world.chunks.insert( - [chunk_x as i32, chunk_z as i32], - UnloadedChunk::default(), - (), - ); + world + .chunks + .insert([chunk_x, chunk_z], UnloadedChunk::default(), ()); } } } @@ -267,10 +265,7 @@ impl Config for Game { for chunk_x in 0..Integer::div_ceil(&SIZE_X, &16) { for chunk_z in 0..Integer::div_ceil(&SIZE_Z, &16) { - let chunk = world - .chunks - .get_mut((chunk_x as i32, chunk_z as i32)) - .unwrap(); + let chunk = world.chunks.get_mut([chunk_x, chunk_z]).unwrap(); for x in 0..16 { for z in 0..16 { let cell_x = chunk_x * 16 + x; diff --git a/examples/inventory_piano.rs b/examples/inventory_piano.rs index 3cc92f9..c77fe14 100644 --- a/examples/inventory_piano.rs +++ b/examples/inventory_piano.rs @@ -78,21 +78,16 @@ impl Config for Game { // initialize chunks for chunk_z in -2..Integer::div_ceil(&(SIZE_Z as i32), &16) + 2 { for chunk_x in -2..Integer::div_ceil(&(SIZE_X as i32), &16) + 2 { - world.chunks.insert( - [chunk_x as i32, chunk_z as i32], - UnloadedChunk::default(), - (), - ); + world + .chunks + .insert([chunk_x, chunk_z], UnloadedChunk::default(), ()); } } // initialize blocks in the chunks for chunk_x in 0..Integer::div_ceil(&SIZE_X, &16) { for chunk_z in 0..Integer::div_ceil(&SIZE_Z, &16) { - let chunk = world - .chunks - .get_mut((chunk_x as i32, chunk_z as i32)) - .unwrap(); + let chunk = world.chunks.get_mut([chunk_x, chunk_z]).unwrap(); for x in 0..16 { for z in 0..16 { let cell_x = chunk_x * 16 + x; diff --git a/examples/parkour.rs b/examples/parkour.rs index 7b3b244..6dfd5f6 100644 --- a/examples/parkour.rs +++ b/examples/parkour.rs @@ -257,7 +257,7 @@ fn reset(client: &mut Client, world: &mut World) { for chunk_z in -1..3 { for chunk_x in -2..2 { world.chunks.insert( - (chunk_x, chunk_z), + [chunk_x, chunk_z], UnloadedChunk::default(), ChunkState { keep_loaded: true }, );