making Multi-Player Minecraft in C++ is HARD!

  Рет қаралды 27,560

Low Level Game Dev

Low Level Game Dev

4 ай бұрын

In this video, I will talk about how the multi-player in my Minecraft code works!
#programming #cpp #gamedev #minecraft #multiplayer
Join my Discord:
/ discord
Check out Midnight Arrow on Steam 💪:
store.steampowered.com/app/23...
Join this channel if you want to support me 😻:
/ @lowlevelgamedev9330
Source code:
github.com/meemknight/ourCraft
Music:
Minecraft soundtrack: C418 - Aria Math
Minecraft soundtrack: C418 - Moog City
Evan King - Booty Shake Robot
/ contextsensitive
contextsensitive.bandcamp.com/

Пікірлер: 117
@givowo
@givowo 4 ай бұрын
fun fact about minecraft: while it used to not be the case, nowdays singleplayer is just a server that is only open to you. it also means open to lan just works without anything new
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
well most games are made like this becaise it's just easier, but i didn know that you can play Minecraft on lan with no external tools that's nice
@Curione23
@Curione23 3 ай бұрын
Opening to lan just allows the game to send packets to the wifi or hotspot
@jimsnyder745
@jimsnyder745 3 ай бұрын
​@@lowlevelgamedev9330p
@acablade
@acablade 4 ай бұрын
You would be surprised of how dumb and lazy the actual minecraft networking is
@GuguinhaMuchosJogos
@GuguinhaMuchosJogos 4 ай бұрын
Can you elaborate? Just curious
@MARIO-de9ew
@MARIO-de9ew 4 ай бұрын
notch code in a nutshell
@AndrieMC
@AndrieMC 4 ай бұрын
notch when lazy and then left mojang with this lazy and dumb code and mojang still using it to this day only getting new stuff added
@acablade
@acablade 4 ай бұрын
@@GuguinhaMuchosJogos no prediction whatsoever, weird edge cases, movement is clientsided, hits are clientsided. using a huge packet with unnecessary variables for turning player head(they fixed this i think) its a shitshow overall
@patahgaming
@patahgaming 4 ай бұрын
​@@acabladedo you know MC youtuber who talking about this? I just want to know how screw it was
@theDragoon007yaboiCJ
@theDragoon007yaboiCJ 4 ай бұрын
believe it or not this video alone already taking more effort than java Minecraft ever did for their clunky multiplayer
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
😂😂 thanks but I still have a lot to do
@NullCyan
@NullCyan 4 ай бұрын
3:23 jumpscared
@JoseRomagueraM
@JoseRomagueraM 4 ай бұрын
Good video! I recommend you to use a tick based simulation. Its basically a fixed step update and every update has his own tickIndex, thats a safer way to timing between client and server and also simplifies some problems
@bacon_with_brussels_sprout
@bacon_with_brussels_sprout 3 ай бұрын
It also helps making block timings more synchronized
@knitnatsnokprogramming
@knitnatsnokprogramming 4 ай бұрын
An Optimizations Video is the most important one
@Yowax
@Yowax 4 ай бұрын
Instead of using contiguous IDs for entities you should really use UUIDs, the chance of collision is minimal and there's less of a hassle with keeping the ids unique.
@AndrieMC
@AndrieMC 4 ай бұрын
fun fact: the actual Minecraft also uses uuids for when needed (entity ids and some other stuff are incrementing numbers tho)
@AndrieMC
@AndrieMC 4 ай бұрын
5:15 cleint
@sohamtilekar5126
@sohamtilekar5126 3 ай бұрын
You Can Hashing algorithm to give an ID, Server will make a seed and send the same seed to all clients the client will add ID based on that seed.
@peterkcodes
@peterkcodes 4 ай бұрын
neato, this is exactly how i implemented the networking in my game!
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
nicee so that means that I still have hope 😂🙏
@peterkcodes
@peterkcodes 4 ай бұрын
@@lowlevelgamedev9330 depends if my game turns out any good 😅
@niuage
@niuage 4 ай бұрын
Seems like such a headache to implement multiplayer haha. Well done tho, you seem to power through all the issues!
@craftingtable7032
@craftingtable7032 4 ай бұрын
5:27 💀💀
@MaskMajor
@MaskMajor 4 ай бұрын
Holly shit din accent mi-am dat seama ca esti roman, super proiectul!
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
😂😂 cum ti-ai dat seama tho?
@MaskMajor
@MaskMajor 4 ай бұрын
modul in care pronunti cuvintele te-a dat de gol xd bafta la masterat!
@Bogdan-Dode
@Bogdan-Dode 4 ай бұрын
Felicitari pentru continut, poate poti sa faci ceva cu Godot 4 "making a game with 0 knowledge" :))
@alexale5488
@alexale5488 4 ай бұрын
Vazand romani pasionati de game dev ma face intr-o oarecare masura mandru :) Initial nu suportam game engine-urile, mi se pareau incarcate. Am codat in C# (Monogame) si Python (PyGame). Am stat 2 ore cu foaia si pixul in mana pana am gasit un algoritm okish pentru camera. Am implementat o clasa "Camera" care are cateva atribute si o metoda ce foloeste ca parametrii player-ul si un spritebatch. 2-3 ore de reconceput algoritmul si trial and error... in Godot am reusit sa pun o camera cu 2 click-uri in 5 secunde care sa functioneze impecabil. Acest aspect m-a determinat sa invat Godot, pentru ca in situatia in care ma aflu, productivitatea e mai importanta. Also, in Godot se poate folosi si C# ceea ce mi se pare cool, o sa fure de la Unity incet incet oameni si studio-uri (cred ca stiu cu totii ce a facut Unity). Chiar luna trecuta era un post pe Godot in Bucuresti care a fost activ o luna, mi s-a parut wow.
@depralexcrimson
@depralexcrimson 4 ай бұрын
why are you sending updates to the client based on where an item should be every now and then instead of letting the client predict where it's gonna be? just use your physics functions you already have on the client to do the 'fall', this way you save everyone the packets... massive improvement imho and this way you don't have any weird stutters and on top of that you also save the server the cycles and also you save bandwidth AND you also make it 100% accurate (or maybe almost 100% depending on how you implement it) server sends height at which item was dropped -> sends to client client -> calculates server sends coordinates of where the item is when it finally is stopped -> sends to client client -> confirms and picks up item. of course it's not as simple as it sounds as you'd have to account for items encountering various obstacles, and ice, water, etc.
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
well I actually do that but you can't rely this the server has to correct you in case things go wrong. Immagine 2 players drop items, who will be responsible for what item? they might have slightly different reprezentations of the world and things like placing a block a seccond late can determine if the item falls or not through that block. So in the end you could probably have each client be responsible for his items but at that point the other client will update you in the end. So at this point it's just easier to update the stuff on the server. The server needs to know what's happens anyway to save the world and validate who takes the item. So as far as I know ther's no other alternstive than what I do. And if I want to add propper security again you need the server stuff
@venoenix
@venoenix 4 ай бұрын
nice
@sournois90
@sournois90 4 ай бұрын
dude this looks so much better than og minecraft
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
😂😂 thanks
@dzdm6299
@dzdm6299 4 ай бұрын
optimisations
@rookiecookie153
@rookiecookie153 4 ай бұрын
I think bedrock is a C++ recreation too, also you did super good!!
@scarm_rune
@scarm_rune 4 ай бұрын
a terrible one at that
@hughjanes4883
@hughjanes4883 4 ай бұрын
I love cpp recreations that are closer to java
@rookiecookie153
@rookiecookie153 4 ай бұрын
@@scarm_rune ikr
@rookiecookie153
@rookiecookie153 4 ай бұрын
@@hughjanes4883 same
@juniuwu
@juniuwu 4 ай бұрын
@@hughjanes4883 my theory is that they did it in c++ partly to handicap modding efforts. because yeah, the performance improvements from just writing cpp java style is minimal.
@EesaSharma
@EesaSharma 4 ай бұрын
Hello, is this game made using Pika or did you make a new renderer/engine for this project?
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
it's just made from scratch, I tnink it's easier this way
@FuIbion
@FuIbion 4 ай бұрын
Ahah you should've implement some networking in your engine ^_^
@FortisConscius
@FortisConscius 4 ай бұрын
Didn't Minetest already achieve a multiplayer voxel engine in 2011? Isn't that C++? Maybe check that out. How they did it.
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
never heared of Minetest thanks for pointing it out I'l check it out. And yes Minecraft after all also did it I just don't really know how
@FortisConscius
@FortisConscius 4 ай бұрын
@@lowlevelgamedev9330 That's the joy of programming, though - solving the puzzle of how it all works! Minetest is open source unlike MC, which is mostly secretive, so reading the code will be easy... but understanding it? Much more challenging! Good luck and have fun!
@hyxlo_
@hyxlo_ 3 ай бұрын
Minetest came out in 2011????
@FortisConscius
@FortisConscius 3 ай бұрын
@@hyxlo_ Indeed it did.
@evilwizardtherapist
@evilwizardtherapist 4 ай бұрын
You're so cool. 😮
@HumanGamer
@HumanGamer 4 ай бұрын
You should add fancy shaders (and maybe Ray Tracing?)
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
yess I am working on more shader stuff 💪, no RTX tho OpenGL doesn't have support for opengl
@solidnywonsz
@solidnywonsz 3 ай бұрын
​@@lowlevelgamedev9330 "OpenGL doesn't have support for opengl"? 🤨
@rxn7
@rxn7 3 ай бұрын
​@lowlevelgamedev9330 opengl doesnt have support for opengl? 😅
@LinguisticMirage
@LinguisticMirage 4 ай бұрын
YES YES YES YES! MULTIPLAYER 🗿 Add physics.
@vladls
@vladls 3 ай бұрын
miencroft phesycs
@dean8012
@dean8012 4 ай бұрын
You need to censor the image in 5:36 (and the rest of the parts containing it) or your video will get flagged, which will be a shame since this content is top class and should be viewed by many.
@Yilmaz4
@Yilmaz4 4 ай бұрын
that's a popular meme tho, it's everywhere on youtube
@josegd112
@josegd112 4 ай бұрын
1:38 "Stary"
@alexale5488
@alexale5488 4 ай бұрын
This is simply of how censored is the world we live in... I miss 2000 years...
@whalegum
@whalegum 4 ай бұрын
In my opinion you are making things harder for yourself by having the client action and server confirmation technique. It would save you a lot of effort to just make everything server-sided and have the server be the ultimate authority, but of course that comes with a bunch of downsides too. It just seems absolutely ridiculous to create a full blown undo queue, and definitely doesn't feel like the correct design. Almost seems like you are making the game less performant while the server more performant which just doesn't stick with me as a game developer. Also you are using UDP right? I would have liked to see your implementation of the package acknowledgment setup you have because I was working with something similar recently and it felt very awkward to implement. Anyways, great video as always, keep it up!
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
I wish things were easier, the server is autoritive but it simply is not possible to wait for it. It can take up to a seccond or more for the server to allow you to place the block so ther's no way we can way for that. There are some resources on my Discod that might help you with what you are implementing check them out in the resources 💪
@kotlinsky.
@kotlinsky. 4 ай бұрын
u sure u have to calculate item drop on client side? i mean, why not just use builtin server, whilst drop just removing item from inventory. server will update this slot, if event was cancelled
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
well the server has to at least acknoledge the creation of a new item, rn it will just validate all of them but I will be able to reject them later if needed
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
the think is I can't wait for the server to drop the item that would take too long
@realismqueen3884
@realismqueen3884 4 ай бұрын
bravo frate
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
imi place ca deja nici nu mai intreaba lumea daca sunt Roman 😂
@realismqueen3884
@realismqueen3884 4 ай бұрын
nu trebuie sa mai intrebi, se cunoaste
@SandwichGamesHeavy
@SandwichGamesHeavy 4 ай бұрын
pls publish this!
@AndrieMC
@AndrieMC 4 ай бұрын
he needs to get new default textures, since hes not allowed to distribute this because of the textures, and if he doesnt change 5hem and distributes it, then he might get a knock at his door from mojang
@SandwichGamesHeavy
@SandwichGamesHeavy 4 ай бұрын
@@AndrieMC yea, he should do that
@alexale5488
@alexale5488 4 ай бұрын
@@AndrieMC I hate companies who act that way :(
@hellomine2849
@hellomine2849 4 ай бұрын
Sub si like!
@lowlevelgamedev9330
@lowlevelgamedev9330 3 ай бұрын
te pwp 💪
@soumyameta
@soumyameta 4 ай бұрын
make it in golang
@mikaay4269
@mikaay4269 4 ай бұрын
I dont really enjoy "Making X game with X thing" videos because they usually focus on minor stuff and arent very entertaining, but this video/series is actually quite nice
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
thank you 💪 I hope more people will share your opinion and find this video
@mikaay4269
@mikaay4269 4 ай бұрын
@@lowlevelgamedev9330 Are you going to build an extendable server to try out a simillar concept to bukkit/spigot?
@AndrieMC
@AndrieMC 4 ай бұрын
Java Edition can run on mobile, so why do you need bedrock for mobile?
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
I mean java is not really very fast and remember that Minecraft was available on mobile even a long time ago when the phones weren't that poweefull
@alexale5488
@alexale5488 4 ай бұрын
​@@lowlevelgamedev9330 Yep. I remember it was made in LWJGL (today it's continued by LibGDX). Since it was bought by Microsoft attempts were made to slowly rewrite the game in C++. Frankly, Java did fine even back then and I would recommend it for 2D games where it can handle things with no problem (Terraria was made in C# using XNA modules, FNA or Monogame today).
@XyndraNerd
@XyndraNerd 4 ай бұрын
Note that minecraft does not reset player position on invalidation(you can jump of ghost blocks)
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
oh ok thanks , if you know any resources that talk about how it is done let me know on my discord pls 🙏 I would love to learn more
@acablade
@acablade 4 ай бұрын
@@lowlevelgamedev9330wiki.vg/Protocol might help
@XyndraNerd
@XyndraNerd 4 ай бұрын
I just observed that from how it works on most survival multiplayer servers. you just need to join one, get a block and try it out
@drexter469
@drexter469 4 ай бұрын
Are you romanian?
@lowlevelgamedev9330
@lowlevelgamedev9330 4 ай бұрын
de ce toata lumea isi da seama de asta 😂?
@alexale5488
@alexale5488 4 ай бұрын
@@lowlevelgamedev9330 Let us be proud with you :)
@drexter469
@drexter469 3 ай бұрын
@@lowlevelgamedev9330 accentul tau in engleza este unul de roman :))
@AndrieMC
@AndrieMC 4 ай бұрын
romania lol
@ItzRomeoYT
@ItzRomeoYT 4 ай бұрын
Mojang WILL sue you.
@AndrieMC
@AndrieMC 4 ай бұрын
Yes but ONLY if he uses the minecraft textures, he can do whatever with it beside using mojang code or assets, the textures are assets
@dzdm6299
@dzdm6299 4 ай бұрын
hh
Best Way To Start Learning C++!
4:55
Low Level Game Dev
Рет қаралды 11 М.
I Remade Minecraft But It is Optimized!
9:39
Low Level Game Dev
Рет қаралды 94 М.
Tom & Jerry !! 😂😂
00:59
Tibo InShape
Рет қаралды 61 МЛН
ROCK PAPER SCISSOR! (55 MLN SUBS!) feat @PANDAGIRLOFFICIAL #shorts
00:31
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 3,6 МЛН
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 466 М.
C++ Developer Learns Python
9:26
PolyMars
Рет қаралды 2,7 МЛН
Learning C++ by making a Game... in 1 Week?!
10:14
Floky
Рет қаралды 372 М.
Is 8-Bit Minecraft Possible?
13:56
Inkbox
Рет қаралды 1,1 МЛН
I re-coded Minecraft purely for MAXIMUM FPS
11:26
Element X
Рет қаралды 621 М.
What does a Game Engine actually do?
16:45
Ellie Rasmussen
Рет қаралды 141 М.
My 1 Year Game Dev Journey - From School to Sea of Thieves
9:20
My GameDev Pal
Рет қаралды 913 М.
I added Entities to my Minecraft Clone 🐽!
8:15
Low Level Game Dev
Рет қаралды 10 М.
Operation Hellstorm
41:10
cubicmetre
Рет қаралды 159 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 688 М.
Can I make Multi-Player Minecraft from scratch in C++?
6:19
Low Level Game Dev
Рет қаралды 7 М.
Tom & Jerry !! 😂😂
00:59
Tibo InShape
Рет қаралды 61 МЛН