minecraft-fs
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 tobuild/libs
- Build FUSE filesystem with
- Install Minecraft mod
- Client version: 1.18.2
- Dependencies: Fabric Loader, Fabric API and Fabric Language Kotlin
- Install MCFS via mod manager/putting mod jar in
mods/
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
-
tail
able 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