Giter Site home page Giter Site logo

siathalysedi / langcraft Goto Github PK

View Code? Open in Web Editor NEW

This project forked from supertails/langcraft

0.0 2.0 0.0 819 KB

Compiler from LLVM IR to Minecraft datapacks.

License: Apache License 2.0

Shell 0.06% Rust 83.51% C 0.34% mcfunction 10.82% LLVM 5.27%

langcraft's Introduction

Langcraft

The LLVM target for Minecraft you've never wanted

Langcraft is a code generator targeting Minecraft Data Packs. It can currently run a fairly substantial set of bitcode files without issue. The project has a built-in command interpreter for debugging that supports breakpoints (ish) and inspecting register/memory values. All generated datapacks can be run in a real Minecraft Java Edition 1.16+ world in under 5 minutes.

Usage

cargo run -- --arg1 --arg2 ./path/to/llvm/bitcode.bc

Valid arguments are:

  • --help: Display usage and available options
  • --out=path/to/dir/: Specify the directory the datapack files should be placed in (default is ./out)
  • --run: Run the command interpreter on the generated code
  • --trace-bbs: Insert a print command at the beginning of each LLVM basic block

To use the generated datapack in Minecraft:

  1. Copy the entire output folder (./out by default) to the datapacks/ directory of a Minecraft world (using a superflat void world is recommended)
  2. Run /function setup:setup. This only has to be done the first time a Langcraft datapack is used in a world.
  3. Run /function rust:run
  4. If the datapack is modified while the world is open, run /reload and then go back to step 3.

Rust code must be built as follows:

  • Release mode
  • panic=abort
  • #![no_std]
  • #![no_main]
  • Have a main function with #[no_mangle]
  • Use i686-unknown-linux

rust_interp is a Rust project already configured to generate the proper bitcode. The interpreter binary target as shown in the demo can be built with:

sh compile_rust.sh

And the file to use will be:

rust_interp/target/i686-unknown-linux-gnu/release/deps/interpreter-SOMEHEXSTRING.bc

Any other language capable of generating LLVM bitcode can be used, as long as it can be built for a bare-metal 32-bit target. For a clang example see compile_c.sh.

Note that the latest nightly versions of rustc now use LLVM 11, which Langcraft cannot parse (yet). You can set an earlier version to use for a directory with:

rustup override set nightly-2020-08-23

Demo

A video of a Langcraft-compiled interpreter can be seen here.

License

Licensed under either of

  • MIT License
  • Apache License, Version 2.0

langcraft's People

Contributors

supertails avatar 5265644d61736f6e avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.