diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ec376bb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea
+target
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..0eceef4
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,201 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "ansi_term"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "bitflags"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
+
+[[package]]
+name = "clap"
+version = "2.33.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
+dependencies = [
+ "ansi_term",
+ "atty",
+ "bitflags",
+ "strsim",
+ "textwrap",
+ "unicode-width",
+ "vec_map",
+]
+
+[[package]]
+name = "core-foundation"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
+
+[[package]]
+name = "core-graphics"
+version = "0.18.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f15b3cb55687886a6b66953123621e5a1529a91a01666d646fb64baa13f900f0"
+dependencies = [
+ "bitflags",
+ "core-foundation",
+ "foreign-types",
+ "libc",
+]
+
+[[package]]
+name = "enigo"
+version = "0.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95ce8d7672e87b3155fd5e8a9226276da5c833e15bc879c7b98a78f743b67814"
+dependencies = [
+ "core-graphics",
+ "libc",
+ "objc",
+ "pkg-config",
+ "unicode-segmentation",
+ "winapi",
+]
+
+[[package]]
+name = "foreign-types"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
+dependencies = [
+ "foreign-types-shared",
+]
+
+[[package]]
+name = "foreign-types-shared"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
+
+[[package]]
+name = "hermit-abi"
+version = "0.1.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "honeycomb"
+version = "0.1.0"
+dependencies = [
+ "clap",
+ "enigo",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.88"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a"
+
+[[package]]
+name = "malloc_buf"
+version = "0.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "objc"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
+dependencies = [
+ "malloc_buf",
+]
+
+[[package]]
+name = "pkg-config"
+version = "0.3.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
+
+[[package]]
+name = "strsim"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
+
+[[package]]
+name = "textwrap"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
+dependencies = [
+ "unicode-width",
+]
+
+[[package]]
+name = "unicode-segmentation"
+version = "1.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
+
+[[package]]
+name = "unicode-width"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
+
+[[package]]
+name = "vec_map"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/Cargo.toml b/Cargo.toml
index 8df0462..40a0b9a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
-name = "MinecraftWorldPregenerator"
+name = "honeycomb"
version = "0.1.0"
-authors = ["codedcosmos"]
+authors = ["codedcosmos", "IronFist95"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/README.md b/README.md
index 66f405a..fc2ff45 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,88 @@
-apt install libxdo-dev
-pacman -S xdotool
+
+# Honeycomb
+### By codedcosmos and Ironfist95
-INPUTBOT
\ No newline at end of file
+Honeycomb is a tool that automatically types teleport commands to pre-generate a minecraft world.
+
+### Why pregenerate?
+Generating chunks fresh from the world takes up additional cpu resources.
+The server has to first generate the chunk and then send it to the client.
+If chunks are pregenerated the server simply needs to load them from disk and send them to the client, which is a lot faster.
+
+This is why big servers like [Hermitcraft Season 7](https://www.youtube.com/watch?v=eA35S2GW-jI) pregenerate their chunks.
+
+### Usage
+
+Windows should work just fine, but if on linux you also need to install xdotool.
+
+Ubuntu/Debian: `apt install libxdo-dev`
+
+Arch: `pacman -S xdotool`
+
+### Running
+Along with some run arguments (listed below), you simply open up a terminal or command prompt and type:
+
+`./honeycomb`
+
+If on windows you should be able to just doubleclick on honeycomb.exe and it will launch command prompt for you.
+
+It will wait for 5 seconds by default, and then start sending commands.
+After executing you should quickly switch to minecraft to prevent typing commands all over the place.
+
+
+Run arguments
+
+ Honeycomb - Chunk Pregenerator 1.0
+ IronFist95 & codedcosmos (codedcosmos.mail@gmail.com)
+ Automatically types teleport commands to pre-generate a minecraft world.
+
+ USAGE:
+ honeycomb [FLAGS] [OPTIONS]
+
+ FLAGS:
+ -r, --auto_return Automatically returns to spawn
+ -c, --creative_mode Starts the script by setting the players gamemode to creative
+ -s, --spectator_mode Starts the script by setting the players gamemode to spectator
+ -h, --help Prints help information
+ -V, --version Prints version information
+
+ OPTIONS:
+ -t, --teleport_delay
+ Sets the delay between teleports (milliseconds) [default: 12000]
+
+ -d, --input_delay Sets the delay between keypresses (milliseconds) [default: 120]
+ -p, --pregenerate_distance
+ Used to set how far to pregenerate (blocks). If set to 0, continues until manually stopped. [default: 1024]
+
+ -e, --start_delay Sets the delay before starting (seconds) [default: 5]
+ -x, --start_x Sets the starting location on the x axis [default: 0]
+ -y, --start_y Sets the starting location on the y axis [default: 0]
+ -b, --view_buffer
+ Safety Buffer distance, to help make sure all chunks are loaded [default: 0.9]
+
+ -v, --view_distance Used to calculate how far to teleport the player [default: 12]
+
+
+
+### Why won't it work?
+Though this may not be the issue, it's likely you need to set your open chat key to t.
+You might have rebound it to a different key.
+
+If not feel free to post an github issue :)
+
+### Why hexagon?
+Well apart from [hexagons being the bestagons](https://www.youtube.com/watch?v=thOifuHs6eY).
+
+Hexagons are the shape with the highest, command to area ratio, when tiling.
+Additionally, they are much closer to a circle than a rectangle, this helps make every pregenerated chunk be equidistant from spawn.
+
+A pregenerated world can be seed below:
+
+
+
+### Building
+When building on Ubuntu/Debian make sure to install mingw: `apt install mingw-w64`
+
+Either build directly with `cargo build --release`
+or run `sh build.sh` if on linux.
\ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100644
index 0000000..4dc2eb2
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,8 @@
+#!bin/bash
+mkdir -p release
+
+cargo build --release
+cargo build --release --target x86_64-pc-windows-gnu
+
+cp target/release/honeycomb release/honeycomb
+cp target/x86_64-pc-windows-gnu/release/honeycomb.exe release/honeycomb.exe
\ No newline at end of file
diff --git a/release/honeycomb b/release/honeycomb
new file mode 100755
index 0000000..100052b
Binary files /dev/null and b/release/honeycomb differ
diff --git a/release/honeycomb.exe b/release/honeycomb.exe
new file mode 100755
index 0000000..55990a5
Binary files /dev/null and b/release/honeycomb.exe differ
diff --git a/res/hexagon_screenshot.png b/res/hexagon_screenshot.png
new file mode 100644
index 0000000..f26cc41
Binary files /dev/null and b/res/hexagon_screenshot.png differ
diff --git a/res/logo.png b/res/logo.png
new file mode 100644
index 0000000..78700dd
Binary files /dev/null and b/res/logo.png differ
diff --git a/res/small.png b/res/small.png
new file mode 100644
index 0000000..744ef52
Binary files /dev/null and b/res/small.png differ
diff --git a/src/main.rs b/src/main.rs
index 09766ed..79044aa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,6 @@
-use enigo::{Enigo, KeyboardControllable, Key};
use std::{thread, time};
-use clap::{Arg, App, SubCommand};
+use enigo::{Enigo, KeyboardControllable, Key};
+use clap::{Arg, App};
fn main() {
// Process launch arguments with clap
@@ -15,7 +15,7 @@ fn main() {
.long("input_delay")
.help("Sets the delay between keypresses (milliseconds)")
.takes_value(true)
- .default_value("40"))
+ .default_value("120"))
.arg(Arg::with_name("Delay Between Teleports")
.value_name("Delay Between Teleports")
@@ -99,6 +99,7 @@ fn main() {
// Load data from arguments
let input_delay = matches.value_of("Input Delay").unwrap_or_default();
let input_delay = input_delay.parse::().expect("input_delay must be a positive integer!");
+ #[cfg(target_os = "linux")]
let input_delay_micro = input_delay * 1000;
let teleport_delay = matches.value_of("Delay Between Teleports").unwrap_or_default();
@@ -141,6 +142,15 @@ fn main() {
let pregenerate_distance = pregenerate_distance.parse::().expect("pregenerate_distance must be a positive integer!");
let pregenerate_distance = pregenerate_distance as i64;
+ // Initial display
+ if pregenerate_distance == 0 {
+ println!("Will pre generate a hexagon until closed");
+ println!("Press Ctrl+C to close");
+ } else {
+ println!("Will pre generate a hexagon of radius {} blocks", pregenerate_distance);
+ println!("Press Ctrl+C to close prematurely");
+ }
+
// Wait Block
println!("Starting up honeycomb");
for i in 0..start_delay {
@@ -150,6 +160,7 @@ fn main() {
// Setup enigo
let mut enigo = Enigo::new();
+ #[cfg(target_os = "linux")]
enigo.set_delay(input_delay_micro);
// Set player gamemode
@@ -161,13 +172,11 @@ fn main() {
execute_command(&mut enigo, input_delay, "/gamemode creative @s".to_string());
}
- // Configurable
+ // Pre-calculate some stuff
let chunk_size = 16.0;
let look_dist = view_distance as f64 * 2.0;
let hexagon_size = chunk_size * look_dist * view_buffer;
- let mut x = start_x as f64;
- let mut y = start_y as f64;
let mut step_amount = 0;
let long = 60.0_f64.to_radians().sin() * hexagon_size;
@@ -184,11 +193,11 @@ fn main() {
let mut current_distance = 0.0;
while pregenerate_distance == 0 || current_distance < pregenerate_distance as f64 {
- x = start_x as f64;
- y = start_y as f64;
+ let mut x = start_x as f64;
+ let mut y = start_y as f64;
// Move to Bottom
- for s in 0..step_amount {
+ for _s in 0..step_amount {
x += down.0;
y += down.1;
}
@@ -222,7 +231,7 @@ fn main() {
println!("Completed");
}
-fn perform_dir(mut enigo: &mut Enigo, input_delay: u64, teleport_delay: u64, x: &mut f64, y: &mut f64, step_amount: i64, dir: (f64, f64), current_distance: f64, pregenerate_distance: i64, step_index: i64) {
+fn perform_dir(enigo: &mut Enigo, input_delay: u64, teleport_delay: u64, x: &mut f64, y: &mut f64, step_amount: i64, dir: (f64, f64), current_distance: f64, pregenerate_distance: i64, step_index: i64) {
let current_distance = current_distance as i64;
let pregenerate_distance = pregenerate_distance as i64;
@@ -243,7 +252,7 @@ fn perform_dir(mut enigo: &mut Enigo, input_delay: u64, teleport_delay: u64, x:
}
}
-fn teleport(mut enigo: &mut Enigo, input_delay: u64, teleport_delay: u64, x: i64, y: i64) {
+fn teleport(enigo: &mut Enigo, input_delay: u64, teleport_delay: u64, x: i64, y: i64) {
teleport_with_rot(enigo, input_delay, teleport_delay, x, y, 0.0);
teleport_with_rot(enigo, input_delay, teleport_delay, x, y, 90.0);
teleport_with_rot(enigo, input_delay, teleport_delay, x, y, 180.0);
@@ -261,7 +270,7 @@ fn teleport_with_rot(enigo: &mut Enigo, input_delay: u64, teleport_delay: u64, x
fn execute_command(enigo: &mut Enigo, input_delay: u64, command_text: String) {
thread::sleep(time::Duration::from_millis(input_delay));
- enigo.key_click(Key::Return);
+ enigo.key_sequence("t");
thread::sleep(time::Duration::from_millis(input_delay * 2));