Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP + Minecraft

Thomas Berends
December 03, 2020
410

PHP + Minecraft

PHP + Minecraft as given at SymfonyWorld 2020 on Dec 3, 2020

Thomas Berends

December 03, 2020
Tweet

Transcript

  1. Two versions Bedrock • Windows • iOS • Android •

    Playstation • Xbox • Nintendo Switch Java • Windows • MacOS • Linux
  2. First step: First look at the game files • Saves

    folder Each save folder has: • 9 subfolders, including the well named ‘data’ folder • icon.png, session lockfile
  3. Data directory • Worst name ever • But contains… maps?

    idcounts.dat map_0.dat map_1.dat map_2.dat etc.
  4. map_0.dat • Notepad shows gibberish • Google to the rescue!

    It’s.. NBT? Custom format, the map has: • colors • xCenter • zCenter • scale
  5. What can we do with this? • Generate created maps

    outside of the game • Know where these are positioned • Put all of them next to each other to create a bigger map!
  6. SlimMap • Open source project • Made with Symfony &

    Leaflet.js • Shows Maps made by players
  7. Structure Blocks • Can Save parts of the world to

    the file system • Can Load them in from the file system
  8. structure file • Ends with .nbt • Contains a set

    of blocks • Also used by game itself to create structures like villages
  9. structure file • Ends with .nbt • Contains a set

    of blocks • Also used by game itself to create structures like villages • Can be saved manually
  10. structure file • Ends with .nbt • Contains a set

    of blocks • Also used by game itself to create structures like villages • Can be saved manually • Can be placed automatically
  11. structure file blocks 0: pos: 0, 0, 0 Position of

    block state: 0 Index of block in palette
  12. structure file blocks 0: pos: 0, 0, 0 Position of

    block state: 0 Index of block in palette palette All different blocks 0: name: minecraft:dirt
  13. Minecraft Commands Extensive system that can do almost anything Some

    examples: • Change weather • Kill mobs / players • Teleport mobs / players • Start / stop time • Give items, take items
  14. Minecraft Commands Can be executed using • Chat, starting with

    / • Redstone • Command line (servers-only)
  15. Minecraft Commands Can be executed using • Chat, starting with

    / • Redstone • Command line (servers-only) • RCON (Send commands to a server)
  16. RCON Execute Minecraft commands remotely • Send commands from any

    server • Only needs host, port, password
  17. RCON Execute Minecraft commands remotely • Send commands from any

    server • Only needs host, port, password • Composer package available
  18. RCON - Security • Just a password is not that

    safe • Do not use default port
  19. RCON - Security • Just a password is not that

    safe • Do not use default port • If possible, use IP whitelisting in firewall
  20. RCON - Examples Used for • Automatic whitelisting of users

    on paid servers • Interactive livestreams
  21. What we just did Read a 1 x 1 x

    1 structure file to use as a base
  22. Resources Repository with information https://github.com/ThomasBerends/php-minecraft Composer package reading Minecraft’s file

    format https://github.com/rickselby/NBT Composer package for RCON connections https://github.com/thedudeguy/PHP-Minecraft-Rcon
  23. A last note... • Most talks get hardly any feedback

    on Joind.in • It’s one of the best things you can do to improve a conference Please take 10 minutes of your time Give feedback