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
450
PHP + Minecraft
PHP + Minecraft as given at SymfonyWorld 2020 on Dec 3, 2020
Thomas Berends
December 03, 2020
Tweet
Share
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
Adopting Sorbet at Scale
ufuk
77
9.5k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
690
The Invisible Side of Design
smashingmag
301
51k
Code Review Best Practice
trishagee
69
18k
Agile that works and the tools we love
rasmusluckow
329
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Fireside Chat
paigeccino
37
3.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
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