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

PHP + Minecraft

5f9d156e426f007430696a8200eab495?s=47 Thomas Berends
December 03, 2020
160

PHP + Minecraft

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

5f9d156e426f007430696a8200eab495?s=128

Thomas Berends

December 03, 2020
Tweet

Transcript

  1. PHP + Minecraft Doing unconventional stuff by combining PHP and

    Minecraft
  2. What is Minecraft?

  3. What is Minecraft?

  4. What is Minecraft?

  5. What is Minecraft?

  6. What is Minecraft?

  7. What is Minecraft?

  8. What is Minecraft?

  9. What is Minecraft?

  10. What is Minecraft?

  11. What is Minecraft?

  12. What is Minecraft?

  13. What is Minecraft?

  14. What is Minecraft?

  15. What is Minecraft?

  16. What is Minecraft?

  17. What is Minecraft?

  18. What is Minecraft?

  19. What is Minecraft?

  20. What is Minecraft?

  21. What is Minecraft?

  22. What is Minecraft?

  23. What is Minecraft?

  24. What is Minecraft?

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

    Playstation • Xbox • Nintendo Switch Java • Windows • MacOS • Linux
  26. PHP + Minecraft: Why? I like combining hobbies

  27. PHP + Minecraft: Why? I like combining hobbies Programming

  28. PHP + Minecraft: Why? I like combining hobbies Programming VR

  29. PHP + Minecraft: Why? I like combining hobbies Programming Minecraft

    VR
  30. PHP + Minecraft: Why? I like combining hobbies Programming Minecraft

    VR 3D Printing
  31. PHP + Minecraft: Why? I like combining hobbies Programming Minecraft

    VR 3D Printing
  32. PHP + Minecraft: Why? I like combining hobbies Programming Minecraft

    VR 3D Printing
  33. PHP + Minecraft: Why? I like combining hobbies Programming Minecraft

    VR 3D Printing
  34. First step: First look at the game files

  35. First step: First look at the game files • Saves

    folder
  36. 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
  37. Data directory

  38. Data directory • Worst name ever

  39. Data directory • Worst name ever • But contains… maps?

  40. Data directory • Worst name ever • But contains… maps?

    idcounts.dat map_0.dat map_1.dat map_2.dat etc.
  41. What is a map?

  42. What is a map?

  43. What is a map?

  44. map_0.dat • Notepad shows gibberish

  45. map_0.dat • Notepad shows gibberish • Google to the rescue!

  46. map_0.dat • Notepad shows gibberish • Google to the rescue!

    It’s.. NBT?
  47. map_0.dat • Notepad shows gibberish • Google to the rescue!

    It’s.. NBT? Custom format, the map has: • colors • xCenter • zCenter • scale
  48. 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!
  49. SlimMap • Open source project • Made with Symfony &

    Leaflet.js • Shows Maps made by players
  50. SlimMap - Demo

  51. We can get things out of the world... Minecraft Save

    Maps
  52. We can get things out of the world... Minecraft Save

    Maps ???
  53. Structure Blocks • Can Save parts of the world to

    the file system
  54. Structure Blocks • Can Save parts of the world to

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

    of blocks
  56. structure file • Ends with .nbt • Contains a set

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

    of blocks • Also used by game itself to create structures like villages • Can be saved manually
  58. 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
  59. structure file blocks 0: pos: 0, 0, 0 Position of

    block
  60. structure file blocks 0: pos: 0, 0, 0 Position of

    block state: 0 Index of block in palette
  61. 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
  62. Minecraft Commands Extensive system that can do almost anything

  63. 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
  64. Minecraft Commands Can be executed using • Chat, starting with

    /
  65. Minecraft Commands Can be executed using • Chat, starting with

    / • Redstone
  66. Minecraft Commands Can be executed using • Chat, starting with

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

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

    server
  69. RCON Execute Minecraft commands remotely • Send commands from any

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

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

    safe
  72. RCON - Security • Just a password is not that

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

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

    on paid servers
  75. RCON - Examples Used for • Automatic whitelisting of users

    on paid servers • Interactive livestreams
  76. Demo

  77. What we just did Read a 1 x 1 x

    1 structure file to use as a base
  78. What we just did Find the palette and change name

    of the single block in it
  79. What we just did Write the new block to an

    existing nbt file
  80. What we just did Write a success message!

  81. 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
  82. 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
  83. Questions?

  84. Thank you! Any feedback is welcome! Twitter: @ThomasBerends