Git Product home page Git Product logo

minecraft-fs's Introduction

minecraft-fs

Build Version MC Version Lines

A FUSE filesystem for querying and controlling Minecraft, as a universal mod platform (but mainly for fun). A blog post covering the technical details can be found here.

Warning: don't get your hopes too high, this is still WIP!


What?

This plugin makes it possible to control your game through the filesystem, and therefore with common Unix tools like cat, find, grep etc. This means you can easily write Minecraft mods with languages like bash and Python without needing to touch Java, gradle or Fabric.

Why?

For fun, to learn about FUSE, but most importantly - why not?

Examples

Controlling the player

Teleporting

Teleporting others to the player

Setting health

Setting blocks

Scripting

In ./scripts you can find some python that encapsulates the filesystem structure and makes for a nicer scripting experience. See the demo script for some examples.

import common
mc = Minecraft.from_args()

player = mc.player()
print(f"{player.name} is at {player.position}")

player.kill()

Installation

  • Download latest release, or build it yourself
    • Build FUSE filesystem with cargo build --bin minecraft-fs --release
    • Build Minecraft mod with cd plugin; ./gradlew build, which will build the jar file to build/libs
  • Install Minecraft mod

Usage

  • Install as above
  • Start Minecraft
  • Mount the FUSE filesystem over an empty directory
    • mkdir mnt; ./minecraft-fs ./mnt
  • Join a single player world - there's currently no support for multiplayer

Your mountpoint should contain something like the following:

$ cd mnt
$ ls
player  version  worlds

$ ls -l player
drwxr-xr-x   - dom 21 Feb 20:27 control
lrwxr-xr-x   0 dom 21 Feb 20:27 entity -> world/entities/by-id/135
.rwxr-xr-x 256 dom 21 Feb 20:27 health
.rwxr-xr-x 256 dom 21 Feb 20:27 name
.rwxr-xr-x 256 dom 21 Feb 20:27 position
lrwxr-xr-x   0 dom 21 Feb 20:27 world -> ../worlds/overworld

Congratulations, you can now manipulate the game through reading and writing to these special files.

Directory structure

; wo=write only, ro=read only, rw=read and write
โ”œโ”€โ”€ command       ; wo, executes a command as the player
โ”œโ”€โ”€ player
โ”‚ย ย  โ”œโ”€โ”€ control    ; all the files here are write-only
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ jump   ; causes the player to jump on any input
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ move   ; applies the given x,y,z force to the player
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ say    ; makes the player chat
โ”‚ย ย  โ”œโ”€โ”€ health     ; rw, the player's health
โ”‚ย ย  โ”œโ”€โ”€ name       ; ro, the player's name
โ”‚ย ย  โ”œโ”€โ”€ position   ; rw, the player's position
โ”‚ย ย  โ”œโ”€โ”€ gamemode   ; rw, the player's gamemode
โ”‚ย ย  โ”œโ”€โ”€ hunger     ; rw, the player's hunger
โ”‚ย ย  โ”œโ”€โ”€ exhaustion ; rw, the player's exhaustion
โ”‚ย ย  โ”œโ”€โ”€ saturation ; rw, the player's food saturation
โ”‚ย ย  โ”œโ”€โ”€ target     ; wo, a position to look at
โ”‚ย ย  โ”œโ”€โ”€ entity -> world/entities/by-id/135  ; symlink to player entity
โ”‚ย ย  โ””โ”€โ”€ world -> ../worlds/overworld  ; symlink to player world
โ””โ”€โ”€ worlds
    โ”œโ”€โ”€ overworld
    โ”‚ย ย  โ”œโ”€โ”€ blocks
    โ”‚ย ย  โ”‚   โ”œโ”€โ”€ 100,64,250
    โ”‚ย ย  โ”‚   โ”‚   โ”œโ”€โ”€ adjacent  ; dir of symlinks to adjacent blocks
    โ”‚ย ย  โ”‚   โ”‚   โ”‚ย ย  โ”œโ”€โ”€ above -> ../../100,65,250
    โ”‚ย ย  โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ below -> ../../100,63,250
    โ”‚ย ย  โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ east -> ../../101,64,250
    โ”‚ย ย  โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ north -> ../../100,64,249
    โ”‚ย ย  โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ south -> ../../100,64,251
    โ”‚ย ย  โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ west -> ../../99,64,250
    โ”‚ย ย  โ”‚   โ”‚   โ”œโ”€โ”€ pos    ; ro, this block's position
    โ”‚ย ย  โ”‚   โ”‚   โ””โ”€โ”€ type   ; rw, the block's type
    โ”‚ย ย  โ”‚   โ”œโ”€โ”€ 100.2 64.555 250.1223  ; this works too
    โ”‚ย ย  โ”‚   โ”‚   โ””โ”€โ”€ ...
    โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ README  ; ro, explains the dir structure
    โ”‚ย ย  โ”œโ”€โ”€ entities
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ by-id
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”œโ”€โ”€ 107  ; entity id
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ”œโ”€โ”€ health     ; rw, the entity's health (if living)
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ”œโ”€โ”€ living     ; inaccessible, exists to indicate living
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ”œโ”€โ”€ position   ; rw, the entity's position
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ”œโ”€โ”€ target     ; wo, a position to look at
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ””โ”€โ”€ type       ; ro, the entity's type
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”œโ”€โ”€ 108
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ”œโ”€โ”€ health
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ”œโ”€โ”€ living
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ”œโ”€โ”€ position
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ”œโ”€โ”€ target
    โ”‚ย ย  โ”‚ย ย  โ”‚   โ”‚ย ย  โ””โ”€โ”€ type
    โ”‚ย ย  โ”‚ย ย  โ”‚   ...
    โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ spawn ; rw, spawns an entity, read file for help
    โ”‚ย ย  โ””โ”€โ”€ time      ; rw, the world's time
    โ”œโ”€โ”€ nether
    โ”‚ย ย  โ”œโ”€โ”€ blocks
    โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ...
    โ”‚ย ย  โ”œโ”€โ”€ entities
    โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ...
    โ”‚ย ย  โ””โ”€โ”€ time
    โ””โ”€โ”€ end
        โ”œโ”€โ”€ blocks
        โ”‚ย ย  โ””โ”€โ”€ ...
        โ”œโ”€โ”€ entities
        โ”‚ย ย  โ””โ”€โ”€ ...
        โ””โ”€โ”€ time

TODOs

  • More endpoints
    • player gamemode
    • entity hunger
    • better player movement
    • entity looking direction (yaw,pitch,roll)
    • entity target pos
    • symlink to entity vehicle
  • Inventory management
    • individual slots
    • symlink to current slot, armour, other hand
    • give/spawn items
  • More block control
    • orientation
    • nbt tags
  • Entity spawning
  • More entity filters than by-id
    • by-type
    • by-proximity-to a position and radius
  • Server settings
    • game rules
    • pvp
    • difficulty
    • weather
  • Event file for reacting to events
    • tailable file of events such as player chat
  • Client specific things
    • pause/unpause game
    • load into world, stop server
  • Multiplayer support
    • install as a server mod, control the server world
    • install as a client mod and join an unmodded server, at least control the player

minecraft-fs's People

Contributors

domwilliams0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.