From d149fb63f8bc4f081c804887d9c9d50f27e420a8 Mon Sep 17 00:00:00 2001 From: blackfur <64478051+theblackfurguy@users.noreply.github.com> Date: Thu, 11 Feb 2021 17:29:02 +0100 Subject: [PATCH] Added set_blocks() function --- src/lib.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c051f7f..3071e5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,15 +10,21 @@ mod tests { fn it_works() { assert_eq!(2 + 2, 4); let mut mc = create("localhost:4711"); - let position = Vec3 { + let position1 = Vec3 { x: 25, y: 0, z: 5 }; + let position2 = Vec3 { + x: 30, + y: 5, + z: 10 + }; mc.post_to_chat("Test"); - println!("{}",mc.get_block(position)); - println!("{:?}",mc.get_block_with_data(position)); - mc.set_block(position,18,1); + println!("{}",mc.get_block(position1)); + println!("{:?}",mc.get_block_with_data(position1)); + mc.set_block(position1,18,1); + mc.set_blocks(position1,position2,18,1); } } @@ -71,6 +77,10 @@ impl Minecraft { pub fn set_block(&mut self, pos:Vec3, blocktype:u8, blockdata:u8) { self.conn.send(&format!("world.setBlock({},{},{},{},{})", pos.x, pos.y, pos.z, blocktype, blockdata)); } + + pub fn set_blocks(&mut self, pos1:Vec3, pos2:Vec3, blocktype:u8, blockdata:u8) { + self.conn.send(&format!("world.setBlocks({},{},{},{},{},{},{},{})", pos1.x,pos1.y,pos1.z,pos2.x,pos2.y,pos2.z,blocktype,blockdata)); + } } pub fn create(adress:&str) -> Minecraft {