Making Minecraft, but the server can have UNLIMITED threads (almost)

  Рет қаралды 22,209

Low Level Game Dev

Low Level Game Dev

25 күн бұрын

In this video, I will talk about how I optimized the server for my Minecraft C++ clone
#cpp #gamedev #multiplayer #minecraft
Join my Discord:
/ discord
Wishlist Midnight Arrow:
store.steampowered.com/app/23...
Join this channel if you want to support me 😻:
/ @lowlevelgamedev9330
Music:
Evan King - Everything is Okay
/ contextsensitive
contextsensitive.bandcamp.com/
Minecraft soundtrack: C418 - Haggstrom
Minecraft soundtrack: C418 - Aria Math

Пікірлер: 87
@marklisjak2740
@marklisjak2740 23 күн бұрын
The same second i finished watching the last minecraft clone video you drop a new video. Keep up the good work!
@lowlevelgamedev9330
@lowlevelgamedev9330 23 күн бұрын
fuck now I need to make a new one in like 2 minutes 😭😂
@marklisjak2740
@marklisjak2740 23 күн бұрын
Do it please i think we can all agree they are great!😊
@BlatentCheater
@BlatentCheater 23 күн бұрын
yo llgd can you make a tutorial on multiplayer game with features like chat and stat saving? Im too dumb to do it lmao.
@LuaanTi
@LuaanTi 22 күн бұрын
In my old Minecraft clone attempt, I decoupled the entities from chunks too; it can get really painful when entities habitually cross chunk boundaries - such as exactly in the crazy chicken farm in your example. And of course, you don't want the _player_ to have to think about chunk boundaries if you can help it. Quadtrees can be much more stable, and allow you to keep your worker threads actually working, since you don't have to assign individual chunks (which 99% of the time have nothing to actually compute) and instead, you try to balance the quadtree nodes to have similar amount of computation (in this case, mostly just entities, but you also want to support active blocks most likely). At the same time, the way the quadtrees are made, you can still have fairly simple random access and storage, and decreasing or increasing "resolution" is relatively cheap (you definitely want to have a sort of hysteresis, though, to make sure you don't go there and back again every frame). Mind, chunks work reasonably fine too; my main motivation was to make proper synchronization reliable. Chunks make things like duping almost unavoidable (and fairly trivially predictable) without massively compromising performance, especially in multiplayer. It's crazy how many games still have to resort to silly solutions like "two people can't open the same chest at the same time" :D And they're still probably by far the _simplest_ way to build worlds like this. Simplicity is a huge boon.
@chriss3404
@chriss3404 19 күн бұрын
I'm curious, did your use of quadtrees impact the networking side of things (specifically compression) for your clone? I know that Minecraft uses palette-based compression for chunks. What approach did you take (& why pls :) )?
@LuaanTi
@LuaanTi 19 күн бұрын
@@chriss3404 No, this was strictly server-side stuff; the client worked on chunks and received full chunks for just the blocks from the server, as well as a list of "potentially visible" entities. I experimented with a few approaches to compression, but ultimately Gzipping the palettised data was already way better than my target and very simple. Some of the approaches I tried had much better performance or compression, but in the end, it was mostly a waste of time, honestly :D It would have been awesome if we were still on 56k internet, though. My current project uses a more complicated system, but it also isn't just about chunks of voxels, and is designed for decently realistic geology. It's also still buggy as hell :D Every time I have to work with it painfully reminds me of how ridiculously easy a simple heightmap or voxel world is in comparison.
@dan2800
@dan2800 21 күн бұрын
You are making basically folia (paper mc shot at making Minecraft multithreaded) implementation of splitting chunks into threads without hopefully like 40-60% overhead of java
@user-uq8lz9oq4i
@user-uq8lz9oq4i 22 күн бұрын
You thought about adding lods? There's a mod called Distant Horizons for Minecraft which adds just that. The mod is kinda crazy as it lets you do render distances like 512 without basically any major performance penalty. Do recommend you give it a look
@viper_exe_
@viper_exe_ 20 күн бұрын
the Voxy mod is a much better solution. It performs better, looks better, and has practically no overhead. While at the same time being much less of a headache to get working for this minecraft clone.
@user-uq8lz9oq4i
@user-uq8lz9oq4i 20 күн бұрын
@@viper_exe_ Wow, did not even know this mod existed. Thanks!
@JerryThings
@JerryThings 19 күн бұрын
I'd be interested in seeing how it scales with more and more simulated players 100, 500 and 1000, where about 25% of them explore the world and load chunks. Love this series!
@lowlevelgamedev9330
@lowlevelgamedev9330 18 күн бұрын
well I still have to move world generation to another thread and for now sending packets is not optimized so it's a bottle neck but well see
@Mormert
@Mormert 23 күн бұрын
Thanks for the Midnight Arrow steam key ;)
@Kajetanv22
@Kajetanv22 22 күн бұрын
Could you create a highly technical video discussing caching and multithreading in C++? One of the challenges I encounter with C++ is the abundance of options and varying approaches adopted by different developers. Recently, a friend shared a video from a conference where the speaker said that jthreads are preferable 99% of the time. BTW, I had an interview with Nvidia's DLSS team where I was tasked with designing and implementing a simplified cache (20 min for it), only problem for me was just writing in modern cpp STL (I prefer to have my implementations and use them). You have great videos! :)
@sharokhkeshawarz2122
@sharokhkeshawarz2122 23 күн бұрын
Oh boy you give me so much inspiration! Love your videos keep it up man!
@Noe_
@Noe_ 22 күн бұрын
I think this is a similar implementation to the folia project by paper mc. Very interesting! But I still don’t understand how you would teleport entities between different chunks and threads
@lowlevelgamedev9330
@lowlevelgamedev9330 22 күн бұрын
well I can put entities anywhere in the word and they will get asigned to their new chunk as a post process step after the multi threaded things, so I would still need to somehow know where's the position I want to teleportan entity to. But it is possiblt.
@limieon
@limieon 10 күн бұрын
Those videos always motivate me and bring me to continue working on my voxel "engine" but everytime I do, I see how hard it is and wanna switch to Unreal
@fudjinator
@fudjinator 23 күн бұрын
if you are concerned about it being slow to move entities to a new chunk you can just make each entity only move its own chunk ownership when its position in chunk space is larger than the size of the chunk, and the check can just be done within whatever method is used to change the position of the entity. For instance if the entities position in "chunk space" is 15.5 8 we know the entity has now "left" the chunk since the max block index in chunk space along x is 15 so the entity can be marked to move to a new chunk.
@lowlevelgamedev9330
@lowlevelgamedev9330 22 күн бұрын
well actually that's what I do, in the end it is just a few extra checks per entity so it shouldn't be that bad, thanks 💪
@oliverbiwer4300
@oliverbiwer4300 22 күн бұрын
this can still become tricky. what if your chicken wanders to a currently in-active chunk? what if it wanders diagonally into a region that is loaded by another thread. how does it even know that this movement is allowed? (that there is no block that prevents the movement) what if you have 3 chunks in a row, the left chunk is handle by thread A because a player is somewhere in the left side doing stuff. it is full of pig. the right chunk is handled by thread B, because a player is somewhere in the right and the chunk is full of chicken. the center chunk is inactive since it is too far away from both players. now you have pigs walking across the chunk borders and chickens walking across the chunkborders and suddenly both threads need to lock this foreign chunk a few times to transition their animals into it. also later the animals need to check if they even can leave the chunk since there are animals piling up at the inactive chunk border !? or maybe same level of worse-ness: when an animal wanders into an unloaded chunk this chunk will be loaded for a few seconds, to not have them pile up, but now ... which thread handles this chunk? or maybe better: in this case the chunk regions count as "connected" and will be merged!?
@fudjinator
@fudjinator 22 күн бұрын
​@@oliverbiwer4300 This is also why I suggested marking it to moving and designating the work later (eg. when the requested chunk is valid). If the chunk isn't valid yet we can consider the current chunk as the fallback and the entity can load in with a slight error. In practice when I make my chunks I try to separate it into modules for each purpose for this very reason. Hence the entities can be put into entity chunk groups with a chunk position while the actual chunk data and mesh may not exist yet, but it doesn't matter because these "entity groups" already do, and if they don't I can just create it on the fly in the same thread, since its trivial to make a list opposed to generating thousands of blocks. As for which thread "owns" the chunk I don't think it matters. Just let one thread win and when its done the other thread can stop waiting and do its work after. Of course this is using a mutex but I think it's fine in this scenario since the work is trivial and not often.
@GavinBogie
@GavinBogie 18 күн бұрын
This is like PaperMC's Folia! Awesome project!
@NinetyUnderScore
@NinetyUnderScore 18 күн бұрын
I think there is something similar to this used on 2b2t for optimization due to the constant 300+ player count in one world. Its called Folia.
@Madman5465
@Madman5465 22 күн бұрын
Great video as usual :)
@user-iy9dr3vv5u
@user-iy9dr3vv5u 22 күн бұрын
seems like mojang actually does work on the updates, its just not visible to us
@sam02h
@sam02h 18 күн бұрын
I've been working on a paper (not intending to publish) with a very similar multiplayer chunking systems for the last 2-3 years. The idea is to adapt a game protocol, and allow it to be able have this style of what I call "sub-space environments" across a distributed cluster of servers. Allowing the game server to be distributed and served at the edge. The basis of it is to discuss unique issues that arise, such as what I refer to as the "line problem". If 1000 players stood in perfect positions in a long line, how would the server split up the handling of that "environment". There are multiple solutions to this, but they all come with drawbacks. I would love to hear your solution to this!
@asdanjer
@asdanjer 16 күн бұрын
You should take a look at folia as it implementes exactly this in Minecraft Java.
@NoobStuff2007
@NoobStuff2007 22 күн бұрын
this is so good! where did you learn all of this man?
@zipiro8942
@zipiro8942 23 күн бұрын
Hope they see the thing...
@Ht-60
@Ht-60 21 күн бұрын
Will you add colored lighting? Its super hard, im aware But colored lights in minecraft would be so cool
@lowlevelgamedev9330
@lowlevelgamedev9330 21 күн бұрын
I would like to but right now the light updates take the most time to compute so unless I find a way to optimize them very well I won't be able :((
@unitazer
@unitazer 21 күн бұрын
Randomly got it into my recomendations, and so far this is probably one of the best things that i've seen. Like in general, this is extremely impressive. but i still have 1 question that you might have already gave the answer to in another video ( but im too lazy to watch every single one ), why dont you use linux? You sound like the kind of guy to recompile your custom kernel fork on your gentoo thinkpad 12 times per day, and only use neovim, but somehow you dont?
@lowlevelgamedev9330
@lowlevelgamedev9330 20 күн бұрын
😂😂 I mean if I would do os dev and I gave it a small try I would do it fully from scratch so no unix starting point, and for now since I do gamedev linux doesn't really help me with developement
@causalguide
@causalguide 22 күн бұрын
what if cross multiplayer wirh real mc?
@fazin85
@fazin85 23 күн бұрын
epic mate
@Ddos2212
@Ddos2212 23 күн бұрын
What is the goal for the project, or just for fun? When will you consider it finished?
@lowlevelgamedev9330
@lowlevelgamedev9330 22 күн бұрын
it is for fun but I want it to be playabale soon enough 💪
@addmix
@addmix 23 күн бұрын
No, this can't be. You have to run everything on the server under a single thread, because that's how minecraft does it.
@_HetShah_
@_HetShah_ 23 күн бұрын
My friend, it's a clone dedicated to improve what we already have so it doesn't hurt anyone running server on multi-threaded
@addmix
@addmix 23 күн бұрын
@@_HetShah_ Bro really has autism, doesn't he?
@kayastuff9367
@kayastuff9367 22 күн бұрын
​@@_HetShah_ i think he's joking
@_HetShah_
@_HetShah_ 18 күн бұрын
@@kayastuff9367 Who knows 🤷🏻‍♂️
@alacastersoi8265
@alacastersoi8265 20 күн бұрын
umm just make the world load in blobs about how they are connected, load a new blob alongside two separate blobs, then switch over to them. easy.
@pepethegood
@pepethegood 20 күн бұрын
does it have AO on blocks? It would be much fancy
@lowlevelgamedev9330
@lowlevelgamedev9330 20 күн бұрын
yess, it's actually ssao
@celdaemon
@celdaemon 21 күн бұрын
the fov feels so claustrophobic TwT
@lowlevelgamedev9330
@lowlevelgamedev9330 21 күн бұрын
ye I'll change it
@Assassinboy3000
@Assassinboy3000 19 күн бұрын
could you fix the camera and physics, it feels really robotic and weird for some reason
@patrlim
@patrlim 20 күн бұрын
it would be sick if this worked with vanilla minecraft
@lowlevelgamedev9330
@lowlevelgamedev9330 20 күн бұрын
ther's actually a mod that adds this to minecraft, it's called folia
@UnifiedCode
@UnifiedCode 23 күн бұрын
pls fix the normals light looks weird on blocks
@lowlevelgamedev9330
@lowlevelgamedev9330 23 күн бұрын
hmmmm Idk what exactly you are talking about but I would like to fix it so can you please send me a message on my discord server and tag me, with a screenshot or something?
@Broom-fz2gm
@Broom-fz2gm 21 күн бұрын
I think you start creating the first video of the C++ tutorial series for beginners when C++23 comes out, because in C++23, the hello world script will be different compared to C++20. *Hello world script in C++20:* #include int main() { std::cout
@user-sb5vt8iy5q
@user-sb5vt8iy5q 23 күн бұрын
subbed
@lowlevelgamedev9330
@lowlevelgamedev9330 23 күн бұрын
💪💪
@TheMyszeek
@TheMyszeek 18 күн бұрын
What would happen if 2 players running regions on separate threads would approach each others?
@lowlevelgamedev9330
@lowlevelgamedev9330 18 күн бұрын
the regions are calculated each tick, so the 2 regions would just become one, ther's no performance penalty to joining 2 regions because they are just recalculated each time and that doesn't take much, it's just a matter of moving some pointers around
@lozaramon1126
@lozaramon1126 23 күн бұрын
sa mor eu daca nu esti roman, imi plac mult videoclipurile tale , tine-o tot asa :)
@mihaelasimerea9700
@mihaelasimerea9700 22 күн бұрын
De ce sa fie roman?
@lowlevelgamedev9330
@lowlevelgamedev9330 22 күн бұрын
da exact cum zice si Mihaela, de ce sa fiu roman?
@Papieog
@Papieog 22 күн бұрын
I am guessing he thinks that because of the accent, to me it sound more like polish
@NoorquackerInd
@NoorquackerInd 23 күн бұрын
This sounds similar to the Folia project from PaperMC devs
@lowlevelgamedev9330
@lowlevelgamedev9330 22 күн бұрын
I think yes they also do this, but that's what someone told me, I haven't looked it up
@glenn6657
@glenn6657 21 күн бұрын
I always wonder why mojang inst able to do stuff like this, cuz others are able to so what's holding them back?
@lowlevelgamedev9330
@lowlevelgamedev9330 20 күн бұрын
wellmany reasons, they havea big team and big codebase so this slows them down (for the caves updates they had to refactor the entire world gen), give a task to a programmer he'll do it in a month, give it to to programmers, they will do it in 2 :)))
@hilligans1
@hilligans1 19 күн бұрын
Because this is not possible to implement and retain a lot of Minecraft mechanics the way they are, doing it region based like this works well yes but limits what blocks are allowed to do. Redstone as we know it isn't possible with this system for example.
@ChillerDragon
@ChillerDragon 23 күн бұрын
Are you planning to open source the game?
@lowlevelgamedev9330
@lowlevelgamedev9330 22 күн бұрын
it is already bro, link is in the description 💪
@ChillerDragon
@ChillerDragon 22 күн бұрын
I don’t see any link ._.
@Satoshinork
@Satoshinork 22 күн бұрын
Add a hand
@gargamel3478
@gargamel3478 22 күн бұрын
Your clone is nice, but I don't like the lighting used. All blocks look too shiny, it's very unnatural.
@lowlevelgamedev9330
@lowlevelgamedev9330 22 күн бұрын
I actually have some shading settings, the first pre release will allow you to configure the shading in hopefully something that suits every one 💪
@marks_shot
@marks_shot 23 күн бұрын
cmek
@lowlevelgamedev9330
@lowlevelgamedev9330 23 күн бұрын
cbuild 😭
@javierignacioavalos3028
@javierignacioavalos3028 23 күн бұрын
Shame for mojang, glory to you. What mojang did in 10 years, you my friend, did in months.
@itsmeagain1415
@itsmeagain1415 23 күн бұрын
bro, you know notch did it before mojang had shit on minecraft, and he fokin made it in YAVA!!!
@HassanIQ777
@HassanIQ777 23 күн бұрын
shame that the Java game is more optimized than the C++ game
@javierignacioavalos3028
@javierignacioavalos3028 23 күн бұрын
@@itsmeagain1415 Exactly. Thats why I posted what I posted. Mojang has going a downward slope since it was bought by Microsoft. I have no beef against Notch, my thing is against Microsoft.
@itsmeagain1415
@itsmeagain1415 23 күн бұрын
​@@javierignacioavalos3028 all my homies poop on microsoft and their terrible decision-making fuckster mind responsible for all their depression inducing software experience across the board
@itsmeagain1415
@itsmeagain1415 23 күн бұрын
@@HassanIQ777 idk how this happens exactly but I think the thing is that the JVM has on its side A HUGE LOT of low-level optimisation mechanisms and they are able to utilise them in the most efficient way possible for programs written in java to have this huge boost in highly optimised environment/masterfully parallelisable, yeah some mastermind 10x C++ engineer can achieve some similar performance for a piece of his highly optimised code, but would never use this level of optimisation for normal stuff/maybe performance intensive but not REALLY
@inxomnyaa
@inxomnyaa 22 күн бұрын
watching this felt like a waste of time, i learned nothing sadly
How Minecraft Surpassed the Game it Copied
10:08
Henke
Рет қаралды 198 М.
I Remade Minecraft But It is Optimized!
9:39
Low Level Game Dev
Рет қаралды 90 М.
когда достали одноклассники!
00:49
БРУНО
Рет қаралды 2,6 МЛН
Glow Stick Secret 😱 #shorts
00:37
Mr DegrEE
Рет қаралды 146 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 118 #shorts
00:30
I Solved All of Minecraft’s Problems
21:03
Knarfy
Рет қаралды 461 М.
Minecrafts Oldest BUGS That Mojang CAN'T Fix…
13:26
TheMisterEpic
Рет қаралды 1 МЛН
Expanding the world of my roguelike indie game | devlog
5:58
25 Seriously Broken Things in Minecraft
10:10
Skip the Tutorial
Рет қаралды 3,1 МЛН
Blazingly Fast Greedy Mesher - Voxel Engine Optimizations
23:35
The coolest shader effect that nobody uses
8:03
Nitro-Gen Studios
Рет қаралды 58 М.
I Made a Neural Network with just Redstone!
17:23
mattbatwings
Рет қаралды 284 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 675 М.
I added Entities to my Minecraft Clone 🐽!
8:15
Low Level Game Dev
Рет қаралды 10 М.
когда достали одноклассники!
00:49
БРУНО
Рет қаралды 2,6 МЛН