So it’s been nearly three months since I made the last Minecraft and Roblox video in fact many of you thought I gave up on the project and now it may look like I haven’t changed much since the last video but I promise you there’s been a lot of important functionality added and I’m Gonna go through them one by one just to get you up to speed before we add some new stuff so first of all you can Ma so first of all you can now mine blocks and yes it deletes the objects above them as well and the way this is done is Using calling so basically what that means actually instead of explaining what it does let me just show you so if I move this chunk you can see that none of the textures that were facing a block are loaded in and only the textures that were facing the air the ones that we can See were loaded in now also what this does is well there’s no more black lines between blocks and you can also see that there are actually no blocks below these blocks but if I stand over here and mine this block it generates new blocks around it and applies the textures where they Should be Alpha mind that one that also happens and so on and that’s what texture block calling does we can now mind but you still can’t mine plants because I’m lazy you may have also noticed the trees now the trees have been completely reworked they’re no longer modeled they are all Generated using code and if I walk here you can see that only parts of them are generated based on what chunk is being loaded in now this took forever to figure out and many things went wrong I mean this is what the first three look like So trees are now a thing And number three is we can now save chunk differences now what’s a chunk difference basically if you mine a block you just created a chunk difference So the terrain is generated on the player’s computer and the terrain is generated based on a seed but the seed is not aware of any differences a player may have applied because it’s all just mathematical Randomness so if you mind a bunch of blocks or let’s say you place a Bunch of blocks but the placement system is still not here so don’t get too excited but let’s say I mine all these blocks and I walk away now that chunk is despawned but now if we walk back so what the code is going to do is it’s Gonna generate the terrain and then it’s gonna apply the differences on top of them so as you can see it looks exactly how we left it and this feature will also allow for multiplayer since all these differences are actually saved on the server and number four I created the system That determines what chunks should be rendered so first of all in the past the shape of the chunks loaded around you used to be a square then we’re loading a bunch of unnecessary chunks in the corner if we pretend that this is the player these are all the chunks that Used to be generated around the player however in the new system the way it’s done is like this so we’re basically eliminating all the chunks that are over here because well we don’t need to load them because the player can only see the minimum amount if you know what I mean Like it wouldn’t make sense to render it as a square so that’s number one and number two is I added the priority system as in whatever chunk is closest to the players should be rendered first so the way this works is we get the distance of each chunk is from the Player and whichever one is the closest in this case it’s this one it’s rendered first and then whatever is the second for this is rendered second and so on so this ensures that the player will never fall off the map because let’s say a chunk is now rendered quick enough and It’s not there well then we have an issue but in this case that will never be an issue and what this also allows us to do is set crazy high chunk render distances and as you may be able to see it is slowly loading everything up and this system basically just eliminates All lack spikes because in the past what used to essentially happen is I’d be loading and rendering every single Chunk in the same frame and the way it’s working now is it only renders one chunk for like five frames But there’s no relax bikes and you can play with pretty big render distances and one more thing when the player dies you are spawned back in in a random position oh yeah and don’t worry about downloading it takes a second so when you die what basically happens is the Game picks out a random render chunk and if there isn’t one it’s just gonna wait until there is and then he’s gonna pick the first land position if you know what I mean so she’s gonna check every single block until it’s air and then it’s gonna Teleport the player there so you can die as much as you want and you’re gonna be back somewhere around where you die so really most of the stuff I’ve been working on are just optimization and though it would have been pretty boring to record however they are very Essential to this game I mean as you can see like the game is literally running very smoothly with this pretty big environment just because of all these optimizations but we’ve still got a lot of work left and I want to focus on adding multiplayer to this game which Essentially just requires me to network everything and now since the chunk differences are stored on the server mining blocks already works for multiplayer however dropped blocks though in fact the dropped blocks are completely broken because I have to to rework the entire systems like for example if we have a drop block over Here and we mind the block below it it should fall or let’s say we place a block over here then it should get pushed up or wherever the first empty neighbor is and items should also stack so there’s a lot we need to do there and I think it’s going to be a pretty hard feature to add but we gotta get it done will I get it done in this video I don’t know I’m gonna try my best making a dropped object system is actually way harder than I expected it To be and the first thing we gotta do is when you mine a block as I’ve said before it’s Gotta fall down so I just mind the block mine another one and it fell down so let me just dig out a little K for us and as you can see it’s All falling down so there were like three different sort of scenarios we had to consider when mining blocks and the most basic one is if you mine a block let’s say over here and the one below it is mine then it should drop down that one is pretty straightforward the second One is let’s say we mine this block it should move all the way down instantly it’s gonna be a bit hard to see but if I mind this it went all the way here right away and now I know there’s no animations right now but I’ve designed The system in a way that will allow me to add animations pretty simply at least I hope so don’t worry about the animations for now I just didn’t want to waste any time on them and another thing that I had to consider is let’s say am I In the bottom one and then I mine the top one so if I mine the one in the middle then the dropped object that comes out of it plus this one should both go down here and as you can see it did it so I believe those are all the Three scenarios there are and they’re all working fine and well but now we have another bit of a problem I mean it’s not a problem but I personally want to improve it which is well there’s just too many entities in one space so obviously there’s only like four blocks Here so it’s not that big of a deal but let’s say you toss in a stack of stones and you’re gonna have 64 individual teeny tiny blocks all with their own textures just take enough space in your memory and you know I’m a new man now I care about optimization when I do Something I kind of want to perfect it now so logically the next step is going to be to stack the items together and the way that’s gonna work is we check the space and if there’s more than a certain amount then we have to stack them up together and one thing we have To consider is let’s say there’s 65 individual Stones over here well then we gotta create one stack and then there’s got to be one individual block so the stack is going to be a model and then the block is going to be a single block and I’m gonna have to store all that Data in tables everything here is done using tables there’s no physics here and I mean this looks already way better than just having a bunch of blocks just floating around and here I am once again I did in fact manage to get the Stacked objects to Work and for the items to stack well they’ve got to be of the same kind so dirt and stone doesn’t stack obviously we just gotta keep that in mind and now that in mind another block as you can see this is actually a model that I’ve Created and if I’m on another block it didn’t change the way it looks if you keep mining it’s just gonna look like that and honestly I don’t want it to be just too I feel like it would make more sense if it’s like four like three or Four so then like if you keep mining it’s just gonna keep adding individual blocks until you reach as I said three or four and then it starts to look like a stacked object but now when I mine a whole bunch of blocks they’re all just stacking and oh wait why are these Floating oh no anyway so I’ll be right back why is this happening after quite a bit of debugging and reworking certain systems I think everything is I think everything’s operational now so of course when you mine the blocks are gonna stack we know that already so Let’s just mind this out and then what we’re gonna do is we’re just gonna walk away from the chunk so it deloads and let’s see if it stays the same and I’ll have any blocks floating and as you can see it has unrendered because we can’t See it over here and if we walk in this direction it should re-render there we go and as far as I can tell I think everything looks right here so now I think the next step should be picking up blocks I honestly don’t even care that much about animating them for now Because like it it doesn’t look bad in my opinion just having them sitting there but I do think I should make some sort of like dropping animation but you know I’ll save that for the end so this is going to be my multiplayer test and I believe I just got the Dropped objects to work in multiplayer and Mining also works however I’m still lacking a few things like the mining like particle effects are on the Block but if I break this block right here as you can see the environment around it changes and a block is dropped now if I Mind the one underneath they all move down see the issue is I literally for some reason cannot move the camera while I have two like clients open but if you can see they’re like all the way at the bottom you can see a stack or if I do it Over here there we go yeah I don’t know why I didn’t do that okay so look I’m mining everything and it’s updating accordingly okay wait it shouldn’t be displaying these blocks out here because those chunks are now rendered I must fix that but anyways a lot of progress is Being done so there are a few more things I want to add before I finish this recording and obviously number one is gonna be picking up objects although I may not do this first because I kind of think it’s a bit boring but the other Thing that I want to do is I want to modify my terrain generation system so that it allows for more crazy terrain like this because at the moment I feel like it’s a bit basic there’s obvious see no Cliffs there’s not even any caves I’m not sure if I’m gonna do caves yet But the reason it is like this is because I’m using 2D noise and all that does is determine the height of every position of every block but we’re gonna have to use 3D noise rate Cliffs and crazy Terrain I kind of did something that’s very cool with the terrain generation let me just Show you this just look at this look at this beauty what what how did I make this this looks insane like there’s a whole tunnel on like a bridge connecting landmasses there’s Cliffs and overhangs and and yeah that’s about it I feel like we’re getting closer and closer to the actual Minecraft terrain it’s still nowhere near as complex but like oh my God like I want to explore this now like the way I used to look before was very generic because the only values I was changing was the y height which is like the height of the surface level and that was It but if you look over here there is no set surface level because there’s some blocks up here and there’s blocks up here so there’s like two surface levels if you know what I mean so you may be wondering how this is done and basically instead of using 2D purlin noise to Determine where the surface level should be I’m using 3D noise to determine what should be air and what should be a block and the closer this value gets to the actual space surface level okay I I don’t know if I can even explain this just doesn’t make sense but basically Math math is beautiful and sometimes confusing so with the way the code works right now I’m actually going to be able to create biome oh my God this is actually beautiful what what am I looking at okay what is going on with that tree so basically what’s happening Is the first step of the code is to determine where there should be a block and where there should be air and where there should be a block I just set it to Stone and then the second step is well to pick out what biome it should be and Well of course in this case I only have this singular one I don’t even know what it’s called honestly but then what we do is replace the top surface layers with dirt and grass blocks well obviously this can be changed to whatever we want this could be sand it could be snowy Grass blocks but I’m Gonna Save biomes for a Future video just because I want to perfect this terrain first of all and I think we’re getting there and of course the dropped blocks still work they’re all stacking over here all nice and beautiful you still can’t pick them Up though because I’m lazy picking blocks is going to be pretty easy to do you just gotta check the distance that the player is from the Block but I think the important part is optimizing it like if a block is dropped all the way there I obviously shouldn’t be checking if the Player is close to it so I’ll just check the blocks that are around the chunk that the player is in if that makes sense and around the y height I’m actually having so much fun just exploring my own environment and one thing I’m actually pretty excited to add Is oars I’m not 100 sure how to do it but that’s going to be pretty cool and oh my God this is so nice I’m not gonna lie I think I should probably stop running and get back to work so I’m using Trello to track what I should add To the game and so as you can see I’m working on the dropped blocks and when a block is broken I believe I should do the particle effect and I also gotta get placing blocks done caves the way caves is done is actually pretty similar to how I’m generating the terrain at the Moment which is by using 3D noise and we also use something called purlin warms which looks a bit like this so we use the purlin worms to generate like tunnels and then we can use 3D purlin to generate like the big caves and once we Get that done plus the oars plus a death screen and just a little menu the game should be ready for version 0.0 I’m probably not going to make it public when I reach the end of version 0.0 just because I’m afraid this game’s gonna get Taken down or like I guess deleted so in a future version I’m just gonna adapt everything to be more of my style and obviously not use any copyrighted assets and then I’ll make it public wow is just so beautiful I feel like everything’s starting to come together so like if I Go over here and mine these blocks up here there may be no animation but all the drop blocks are actually down there and oh wait I need to make the dropped blocks ignore plants that is not good and see that’s why we test so there is One thing I sort of forgot to show off that’s because there’s really no way to test it unless I’m using like print statements which is crafting the logic for crafting now works even though there’s no crafting table I can simply pass my inputs to this function over Here so in this example the X represents nothing that’s just going to be an empty slot and then next we have the oak wood and same thing with the bottom row this would be crafted in like your inventory so another way to imagine this is Imagine these are empty and there’s wood Planks here and as you can see it Returns the result which is a stick now in the next example I place the wood planks in the opposite side so imagine these two have wood planks and these two are empty and I got the same result and the logic behind this is actually pretty Weird and that’s mainly because I didn’t want to have to save every single possible formula in fact the way that they are saved is pretty weird I first have a table that has the number of rows and then I have a table that has a number of columns So based on whatever I’m given so let’s say we have with planks over here so what my code would do is shrink this down to where there are actual items so this would be a two by one because we have two rows and one column in the blocks so what the code Will do is after it shrinks it down it goes to the two because this number of rows then one which is the number of columns and then it’s going to return all the recipes there are and the results so number one we have a stick And we also have a torch then it checks if the recipe matches the recipe that’s that’s the way it works this way I don’t have to save a whole bunch of possible formulas like imagine this was a normal sized crafting table and a player placed down a wood lock literally anywhere then I would have to return a wooden plane but then I’m gonna have to store Nine separate recipes just for wooden planks and the last couple videos lots of you guys have asked me to show you some of the code or go more in depth into the Technical side but at the same time I know many of you guys don’t even want that because it does sound a little bit boring but if if you want the technical stuff if you want to understand how all this works then Now’s the Time the most important script I have is the chunk Loading module script and that’s because this is a script that determines what should be loaded and what should be rendered anything’s true for unloaded and unrendered and this is sort of the root of every other script by every other script I mean dropped object and the world generation so every fourth Frame I mean this could be any any number we want I find what chunks to load and the way that’s done is I just find like a circular radius of all the chunks that are around the player and then I load those chunks and what that basically means I’m just calling this Function that just goes through all the chunk there are that we want to load and then it calls the appropriate functions in other module scripts and then the same thing is done for rendering however as I said before there is a render priority system and that’s literally Just done by finding the closest one to the player and this is why math is important and after the priority is reordered I simply do the same exact thing I did to the low chunks function and I passed it over to the render chunks and then I just called the Appropriate function and since the first thing that’s done for world generation is loading the way that’s done is I create a 3D table that’s just air and then I fill in the table with any pre-loaded data and what that basically means is if I generated a tree on a Neighboring chunk and some of the leaves had crossed over into this chunk then I just filled them into the table and then afterwards I generate the terrain which is all just going to be Stone and that basically just shapes how the terrain is going to look and that’s where we have All the cool mountains and cliffs and then using that terrain I fill in the surface layer which is obviously dependent on the bio but for us there’s just going to be grass blocks and dirt and then lastly I just fill in the top with flowers trees and so on one thing You may have noticed is not here is the chunk differences and why did that just happen and I do that using a remote event just because if it’s a remote function then I’m gonna have to wait until the server returns something which would slow down the chunk Generation by A lot just because I have to wait for the server every single time which depends on your internet latency so I just fire this event and on the server Riverside what’s going on is I’m literally just returning the values inside of a table if they exist and once The server fires back with all that different information I just go through every single one of them I get the block name the world position I converted into a chunk position and lots of things are being done here so if the chunk is loaded then I just update my loaded Chunks data which is the 3D table I was talking about but I have two tables one of them is the loaded chunks which is just the name of the blocks and where they should be and then I also have another table for the render chunks which is the same thing but instead of The block name I store the actual block that is in the world and then a whole bunch of logic is being done here I’m actually not even 100 sure what I’m doing fine I mean this is a huge function so that’s a bit messy but if we Look at the terrain generation you can see just how short the function really is I mean this is like 25 lines of code so really all the terrain generation that’s being done is literally just a numbers game it’s just a bunch of numbers being toyed around with until You get a result that you like so that’s really how the train is working at the moment it’s nothing too complicated but it’s just important to keep your code organized and readable and it really wasn’t allow video which is why I literally just redid everything so that’s gonna be all in today’s video It’s kind of cool seeing how this game went from something that I thought is like not really possible for me to achieve to figure out some very basic things to now like having gone way further than I thought I ever would and I’m excited to see what I’m gonna do in The next video because even I don’t know maybe caves in order okay bye Thank you Video Information
This video, titled ‘Adding Multiplayer to Minecraft in Roblox’, was uploaded by 2nix on 2023-08-01 14:45:01. It has garnered 107080 views and 5731 likes. The duration of the video is 00:17:59 or 1079 seconds.
thank you for watching!
My Discord Community ➤ https://discord.gg/Uf6Q6zNek9
Socials Twitter ➤ https://twitter.com/2nixRBLX Roblox Account ➤ https://roblox.com/users/33295715/profile Roblox Group ➤ https://roblox.com/groups/15453186/2nix
My PC Specs i7-8700 RTX 2070 16GB RAM
My Equipment Keyboard – Razer Huntsman Mini Mouse – Razer Mamba Monitor – LG 27GP95R-B 27″ 4K Microphone – Rode NT Headset – Sennheiser HD280 Pro
#gamedev #roblox #programming