You are browsing as a guest. Sign up (or log in) to start making projects!

MCServerKit

  • 4 Devlogs
  • 113 Total hours

A full kit for creating and managing Minecraft servers.

Open comments for this post

30h 24m 40s logged

Devlog 4

I have finished porting the library to Rust using Rust FFI, so it won’t need to be done manually. I’ve set it up so you can install it through Cargo:

cargo add mcserverkit

And you can use it like this:
main.rs

fn main() {
    let err = mcserverkit::install("1.21.1");
    if err != None {
        println!("Error installing 1.21.1:");
    }

	let err = mcserverkit::create("MyServer", true);
    if err != None {
        println!("Error creating MyServer:");
    }

	let err = mcserverkit::start("MyServer", "4G");
    if err != None {
        println!("Error starting MyServer:");
    }
}

Also, I’ve added ARM architecture support for Linux and I updated the library to Go 1.26.4 so instead of passing 1s and 0s to the eula parameter you can pass true or false for C and C++.

7
1
65
Open comments for this post

5h 36m 40s logged

devlog 3

When I began binding my Go library to Rust today, I had realized something I’ve been doing wrong not just in my Rust bindings but in my C bindings. They both work by calling go build which is fine but not everyone has Go installed on their computer, so it works on mine but not others.

use std::process::Command;

fn main() {
    println!("Hello World!");

    // https://stackoverflow.com/questions/43292357/how-can-one-detect-the-os-type-using-rust
    // https://doc.rust-lang.org/std/process/struct.Command.html
    let _output = if cfg!(target_os = "windows") {
        Command::new("go").args([
            "build",
            "-buildmode=c-shared",
            "-o",
            "mcserverkit.dll",
            "./bindings/c",
        ]);
    } else if cfg!(target_os = "linux") {
        Command::new("go").args([
            "build",
            "-buildmode=c-shared",
            "-o",
            "mcserverkit.so",
            "./bindings/c",
        ]);
    } else if cfg!(target_os = "macos") {
        Command::new("go").args([
            "build",
            "-buildmode=c-shared",
            "-o",
            "mcserverkit.dylib",
            "./bindings/c",
        ]);
    } else {
        println!("Operating system not supported");
        return;
    };
}

the plan

Instead of requiring every person to have Go installed, I created a GitHub action that compiles the library for every platform whenever a new release is published. It generates .dll, .so, .dylib and header files and uploads to release assets.

but it’s only half the process, I still have to rewrite my Rust and C bindings so they download the precompiled assets from the latest GitHub release instead of compiling them locally.

This should actually make the entire logic faster because it won’t need to download the source and run go build every time when it can skip straight to the prebuilt assets, which removes the compiling step entirely!!!

0
1
79
Open comments for this post

45h 6m 45s logged

devlog 2

In my last post, i said that i wanted to port my Minecraft server library to C. currently i’ve released v0.1.9 which adds C/C++ support with Go bindings. and i spent a LONG time debugging and creating a CMakeLists.txt allowing developers to easily just… (yes that easy)

cmake_minimum_required(VERSION 3.16)
project(example LANGUAGES C)

include(FetchContent)

FetchContent_Declare(
	mcserverkit
	GIT_REPOSITORY https://github.com/mcserverkit/core
	GIT_TAG v0.1.9
)
FetchContent_MakeAvailable(mcserverkit)

add_executable(example main.c)
target_link_libraries(example PRIVATE mcserverkit)

which allows you to do this!

#include "mcserverkit.h"

int main()
{
	Install("1.21.1");
	Create("MyServer", 1);
	Start("MyServer", "4G");
}

and to bundle as an executable run this in your terminal:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

sorry this update took so long…

app progress

Also, I know I’ve just added support for C and C++ but now I NEED to add an adapter for Rust because I switched to Tauri instead of Webview and Tauri uses Rust for the backend instead of C++ and that’s most likely going to be a part of the next log.

Here’s a picture of the app so far, i was inspired by Minecraft’s website ui and wanted it to feel more connected to the official game, it already works cross platform but none of the backend is connected yet because i have to make bindings for Rust.

0
1
56
Open comments for this post

32h 16m 32s logged

running local minecraft servers is annoying!

nobody likes paying for cloud hosting, so i spent the past 8 days programming a local cli for creating and managing minecraft servers because using .jar files directly is overcomplicated. i decided to make the core an open source and reusable Go library and i am planning to port it to C in the future.

i just finished the first stable version of mcserverkit’s core and cli and wrote a shell script for macos and linux users to easily install the cli. as for windows, i haven’t yet but i have included steps to easily add the executable to PATH.

what’s next?

i am working on a GUI app using C and webview, i plan on adding port forwarding so you can run it on your computer locally and share them with your friends!

2
1
122

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…