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

PHP + Minecraft

Avatar for Thomas Berends Thomas Berends
December 03, 2020
480

PHP +Β Minecraft

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

Avatar for Thomas Berends

Thomas Berends

December 03, 2020

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