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
440
PHP + Minecraft
PHP + Minecraft as given at SymfonyWorld 2020 on Dec 3, 2020
Thomas Berends
December 03, 2020
Tweet
Share
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
We Have a Design System, Now What?
morganepeng
51
7.4k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Bash Introduction
62gerente
610
210k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Statistics for Hackers
jakevdp
797
220k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
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