Skip to content

🧰 FUSE filesystem for querying and controlling Minecraft

License

Notifications You must be signed in to change notification settings

DomWilliams0/minecraft-fs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

78 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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