DomWilliams0 / minecraft-fs

🧰 FUSE filesystem for querying and controlling Minecraft

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

🧰 FUSE filesystem for querying and controlling Minecraft

License:GNU General Public License v3.0


Languages

Language:Rust 75.8%Language:Kotlin 20.3%Language:Python 3.7%Language:Shell 0.2%