Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PHP + Minecraft
Search
Thomas Berends
December 03, 2020
1
430
PHP + Minecraft
PHP + Minecraft as given at SymfonyWorld 2020 on Dec 3, 2020
Thomas Berends
December 03, 2020
Tweet
Share
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
Git: the NoSQL Database
bkeepers
PRO
427
64k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
It's Worth the Effort
3n
183
27k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Music & Morning Musume
bryan
46
6.2k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Building Applications with DynamoDB
mza
90
6.1k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Transcript
PHP + Minecraft Doing unconventional stuff by combining PHP and
Minecraft
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
What is Minecraft?
Two versions Bedrock • Windows • iOS • Android •
Playstation • Xbox • Nintendo Switch Java • Windows • MacOS • Linux
PHP + Minecraft: Why? I like combining hobbies
PHP + Minecraft: Why? I like combining hobbies Programming
PHP + Minecraft: Why? I like combining hobbies Programming VR
PHP + Minecraft: Why? I like combining hobbies Programming Minecraft
VR
PHP + Minecraft: Why? I like combining hobbies Programming Minecraft
VR 3D Printing
PHP + Minecraft: Why? I like combining hobbies Programming Minecraft
VR 3D Printing
PHP + Minecraft: Why? I like combining hobbies Programming Minecraft
VR 3D Printing
PHP + Minecraft: Why? I like combining hobbies Programming Minecraft
VR 3D Printing
First step: First look at the game files
First step: First look at the game files • Saves
folder
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
Data directory
Data directory • Worst name ever
Data directory • Worst name ever • But contains… maps?
Data directory • Worst name ever • But contains… maps?
idcounts.dat map_0.dat map_1.dat map_2.dat etc.
What is a map?
What is a map?
What is a map?
map_0.dat • Notepad shows gibberish
map_0.dat • Notepad shows gibberish • Google to the rescue!
map_0.dat • Notepad shows gibberish • Google to the rescue!
It’s.. NBT?
map_0.dat • Notepad shows gibberish • Google to the rescue!
It’s.. NBT? Custom format, the map has: • colors • xCenter • zCenter • scale
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!
SlimMap • Open source project • Made with Symfony &
Leaflet.js • Shows Maps made by players
SlimMap - Demo
We can get things out of the world... Minecraft Save
Maps
We can get things out of the world... Minecraft Save
Maps ???
Structure Blocks • Can Save parts of the world to
the file system
Structure Blocks • Can Save parts of the world to
the file system • Can Load them in from the file system
structure file • Ends with .nbt • Contains a set
of blocks
structure file • Ends with .nbt • Contains a set
of blocks • Also used by game itself to create structures like villages
structure file • Ends with .nbt • Contains a set
of blocks • Also used by game itself to create structures like villages • Can be saved manually
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
structure file blocks 0: pos: 0, 0, 0 Position of
block
structure file blocks 0: pos: 0, 0, 0 Position of
block state: 0 Index of block in palette
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
Minecraft Commands Extensive system that can do almost anything
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
Minecraft Commands Can be executed using • Chat, starting with
/
Minecraft Commands Can be executed using • Chat, starting with
/ • Redstone
Minecraft Commands Can be executed using • Chat, starting with
/ • Redstone • Command line (servers-only)
Minecraft Commands Can be executed using • Chat, starting with
/ • Redstone • Command line (servers-only) • RCON (Send commands to a server)
RCON Execute Minecraft commands remotely • Send commands from any
server
RCON Execute Minecraft commands remotely • Send commands from any
server • Only needs host, port, password
RCON Execute Minecraft commands remotely • Send commands from any
server • Only needs host, port, password • Composer package available
RCON - Security • Just a password is not that
safe
RCON - Security • Just a password is not that
safe • Do not use default port
RCON - Security • Just a password is not that
safe • Do not use default port • If possible, use IP whitelisting in firewall
RCON - Examples Used for • Automatic whitelisting of users
on paid servers
RCON - Examples Used for • Automatic whitelisting of users
on paid servers • Interactive livestreams
Demo
What we just did Read a 1 x 1 x
1 structure file to use as a base
What we just did Find the palette and change name
of the single block in it
What we just did Write the new block to an
existing nbt file
What we just did Write a success message!
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
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
Questions?
Thank you! Any feedback is welcome! Twitter: @ThomasBerends