PHP + Minecraft

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

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. Who am I? Thomas Berends Developer @ NetAnts, Roermond ThomasToSpace

    youtube.com/ThomasToSpace twitch.tv/ThomasToSpace
  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. What is Minecraft?

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

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

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

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

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

    VR
  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. PHP + Minecraft: Why? I like combining hobbies Programming Minecraft

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

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

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

  39. Data directory • Worst name ever

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

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

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

  43. What is a map?

  44. What is a map?

  45. map_0.dat • Notepad shows gibberish

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    on paid servers • Interactive livestreams
  77. Demo

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

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

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

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

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

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