private void filesList_SelectedIndexChanged(object sender, EventArgs e) { FileDetail selectedFile = fileList[filesListBox.SelectedIndex]; BinVoxModel binVox = new BinVoxModel(selectedFile.FullName); fileInfo.Clear(); fileInfo.AppendText("file: " + selectedFile.Display + "\r\n\r\n"); fileInfo.AppendText("depth: " + binVox.dims.depth + " width: " + binVox.dims.width + " height: " + binVox.dims.height + "\r\n"); fileInfo.AppendText("voxels: " + binVox.size + "\r\n"); fileInfo.AppendText("present voxels: " + binVox.present_voxels); plotButton.Enabled = true; }
private static void plotInThread(object obj) { ThreadInfo info = (ThreadInfo)obj; BinVoxModel binVox = new BinVoxModel(info.file.FullName); int resumefrom = info.resumefrom; int addx = info.relative_x; int addy = info.relative_y; int addz = info.relative_z; Thread.Sleep(100); // and window name were obtained using the Spy++ tool. IntPtr minecraftHandle = FindWindow(null, info.minecraftTitle); // Verify that Calculator is a running process. if (minecraftHandle == IntPtr.Zero) { MessageBox.Show("Minecraft with title '" + info.minecraftTitle + "' not running"); return; } SetForegroundWindow(minecraftHandle); Thread.Sleep(100); SendKeys.SendWait("{ESC}"); int blocksplaced = 0; while (binVox.HasNext()) { Voxel voxel = binVox.Next(); if (voxel.is_present) { if (info.token.IsCancellationRequested) { break; } blocksplaced++; if (blocksplaced < resumefrom) { continue; } if (blocksplaced % 20 == 0) { Properties.Settings.Default.resumefrom = blocksplaced.ToString(); Thread.Sleep(5000); } string cmd = "/setblock " + (voxel.x + addx) + " " + (voxel.y + addy) + " " + (voxel.z + addz) + " minecraft:sandstone 0 destroy"; SendKeys.SendWait("t"); Thread.Sleep(120); string[] keys = cmd.Select(x => x.ToString()).ToArray(); for (int i = 0; i < keys.Length; i++) { Thread.Sleep(10); if (keys[i] == "~") { SendKeys.SendWait("{~}"); } else { SendKeys.SendWait(keys[i]); } } Thread.Sleep(10); SendKeys.SendWait("{ENTER}"); Thread.Sleep(1000); } } }