So i decided to do something that’s never been done before yep that’s right i recreated minecraft Now you may be thinking why in the world would you attempt such a feat it’s impossible and i would agree with you in fact this was a huge headache in all seriousness why would i recreate something that a million other people have already recreated well i felt like everyone who had recreated minecraft Just didn’t do it justice it’s not that their clones were inferior than mine but they really are just kidding but they didn’t do some of the more gameplay-feeling stuff what i mean by that is they implemented a lot of the basic mechanics and then stopped they didn’t add menus they didn’t add debug Statistics they didn’t add saving and loading screens all that type of stuff so i decided i would implement all the parts of minecraft you know except all the hard stuff so here’s how my journey went the first piece of any good minecraft clone puzzle is rendering a square this Ended up taking me a lot longer than i thought it would have taken but eventually i got a square up on the screen and since this is a minecraft clone i decided to make it all minecraft like and added a grass block texture unfortunately i lost all the footage for This stream so here’s the end result next i need to be able to place any old block texture in the game this can be done a huge number of ways but i decided to just do the stupidest simplest method out there which was to patch all the textures together into one big giant Image it ended up looking like this this part wasn’t that difficult but i don’t like making my life easy so i had to make it more difficult i want it to be super easy to add new blocks into the game in the future so i came up with the Most clever block creation scheme ever i call it yaml actually i didn’t really come up with this basically you can just write up a description of the block put whichever textures you want to use in here add a few other details and bada bing bada boom you got your new block We’ve got squares and textures so we basically have minecraft right wrong minecraft needs a 3d player controller so i went ahead and wrote some super clever code that i stole directly from a website and next thing you know i’ve got a 3d player controller of course it Never works right the first time anyways i fixed that up and thought to myself squares are great but what if we had cubes cubes are pretty simple in theory they consist of eight vertices which are just the different corners of the cube i also have to attach some extra data so the Program can figure out which texture to apply to which face and once that’s all figured out well you got a cube this took me way longer than it should have because i was over engineering the crap out of it i eventually got there in the End and i made this giant chunk of cubes now that we have cubes we need to create chunks and cull the interior faces you see if we just draw all the interior faces of the cubes the gpu does a lot of unnecessary work and ends up lagging Horribly so we can just say hey computer if there’s a block next to me don’t draw that side and that’s basically the process i take now there are some gotchas like if you have a glass block you clearly want to draw the side of the Cube but those are pretty easy to add in once we get this done now we can save some gpu work and we can go ahead and generate a bunch of chunks now let’s just apply some simplex noise and now we have terrain now we’re getting places The next thing that would be nice to do is add chunk serialization and deserialization this is basically the process of saving and loading a chunk since i coded this in c plus and stayed pretty close to the hardware i can literally dump the raw binary straight To a file and then i just load that raw binary back in now we can save and load chunks this is great but i was running into some horrible lag issues and my program was using you know 30 gigabytes of ram for a 12 chunk radius so i had to fix That over the process of a couple weeks i added some horribly over engineered multi-threading and some janky vertex compression i basically stole hopsin’s idea of compressing chunk data into a couple bytes per block which brought my ram down to like four gigabytes and then i added multi-threading to speed things up a bit What’s next on the list well we need a way to handle entities we need a method of storing several entities in our world and having a way to iterate over those entities that have some features we’re looking for for example our physics wants to find all the entities that have Box colliders so it asks for those and it does some physics stuff i used something called an entity component system for this and added a quick and dirty method to add entities like players to the game with this in place i could add physics physics is harder than It looks well actually physics looks pretty hard but i won’t bore you with the details i basically needed a way to stop the player from falling through trunks and a way to raycast into the world to see what the player’s looking at so i eventually settled on a couple Of methods i liked and was able to add some simple physics next up font rendering and hud stuff like i said before i wanted to add in the ability to do menu stuff that a lot of people didn’t add in their clones so i had to code up a simple font render That basically loads a font on your pc generates all the glyphs puts them all in a texture so that i can display text to the user now i had some text alignment issues and everything but i eventually got it all sorted out now i can make menus and buttons and all that Good stuff it’s actually starting to feel like a game At this point my pc was just crying for some help the way i initially coded this wasn’t the best basically i would calculate all the chunk stuff on the cpu then copy and transfer that to the gpu once it was ready and this was just horrible for performance and wasted a Ton of ram i implemented this thing called opengl as do which basically allows me to ask the gpu for some pinned memory once i get a hold of this memory i can write to it as i please and it will automatically initiate a dma transfer when necessary and now the gpu Just has the data it needs this sped things up and reduced my overall ram usage to around one gigabyte for a 12 chunk radius not too shabby next i decided to move on to more important things like hot bars commands and light coating up a hotbar was pretty quick and Easy since i had all the other gui stuff done but i really wanted to add minecraft lighting into the mix now minecraft lighting is actually a lot harder than i thought it would be and i’m still trying to get it working really good the basic idea is simple Enough in minecraft if you have an air block it gets a light value from 0 to 15. it generates its light value based on the blocks around it it takes the highest level around it and subtracts 1 from that if it has direct access to the sky then it automatically gets a light Level of 7 to 15 depending on the time of day i spent so long trying to get this work just right it turns out i was using the wrong approach the whole time i was trying to calculate all the lighting at the same time and store sky Levels and light source levels in the same memory turns out this was a dumb idea because it leads to all sorts of weird problems trying to figure out what a light level should be so instead i found a great article that stored the sky levels separately from light source Levels this means that you can calculate all the sky levels once and as the day turns into night you don’t have to do any fancy updates but can just take the sky level or the light source level for that specific air block you just choose whichever one is higher Around this time i added in some cube maps which made the game feel much more like minecraft after that i added some proper command line parsing which was pretty quick and painless i basically just store a bunch of commands in the code and if anybody ever types in something that matches one Of those commands i check if they passed in the proper arguments and stuff and that’s basically where i’m at as you can see you can join a world play around in the world place blocks ad blocks place light sources and all sorts of stuff i plan on adding support for Multi-colored lights crafting inventory management multiplayer support 3d models mobs and some more stuff if you’re interested in seeing me code this in real time you can check out my twitch at twitch.tv slash games wthgate and if you want to download this clone you can download it in a link in the description I will warn you it will most likely crash but it won’t break your computer at least i hope it won’t i might post another video on youtube in the future with some updates if you want that and if this video gets like 10 000 likes i’ll create some tutorials on how you Can create your own minecraft clone using whatever language you want just kidding i’ll be making those tutorials no matter what but you can still like this video anyways if you enjoyed this video please leave a like and subscribe and i will see you guys next time is You Video Information
This video, titled ‘I Coded Minecraft in *Only* 3 MONTHS!!!!’, was uploaded by GamesWithGabe on 2021-11-15 13:49:55. It has garnered 131889 views and 9965 likes. The duration of the video is 00:08:56 or 536 seconds.
Follow me on Twitch: https://www.twitch.tv/GamesWthGabe Download the Clone (Windows x64 only): https://github.com/codingminecraft/StreamMinecraftClone/releases Watch the old streams: https://www.youtube.com/channel/UCX9O5F062HVFmx9CNPGiMgg Join the Discord: https://discord.gg/4tHeAkxNg7
In this video I go over the past few months of me tinkering on a Minecraft clone. I have added many different things to this clone. Some of the things I have added include: dynamic block creation, world saving/loading, OpenGL AZDO, order independent transparency, physics, 3D player controllers, commands, cubemaps, lighting, and more. I hope you enjoy my overview of how I went about recreating an iconic game, and I hope you’ll join me as I create more videos diving deep on specific game mechanics in the future!
0:00 Intro 1:09 The First Square 1:59 Adding New Blocks 2:17 3D Player Controller 2:36 Cubes and Chunks 3:35 Chunk Serialization 3:56 Optimizations 4:19 Entity Component System 5:01 Font Rendering and HUDs 5:33 OpenGL AZDO 6:08 Hotbar and Commands 6:22 Lighting 7:25 Cubemaps 7:44 Current State
Lighting Article (Part 1): https://web.archive.org/web/20210429192404/https://www.seedofandromeda.com/blogs/29-fast-flood-fill-lighting-in-a-blocky-voxel-game-pt-1 Lighting Article (Part 2): https://web.archive.org/web/20201112022602/https://www.seedofandromeda.com/blogs/30-fast-flood-fill-lighting-in-a-blocky-voxel-game-pt-2
Animations Created Using Manim Community: https://docs.manim.community/en/stable/index.html Thank you 3blue1brown and your amazing community for Manim!
——————————————————————— Website: https://ambrosiogabe.github.io/ Github: https://github.com/ambrosiogabe
Here are some books I recommend if you want to learn about game engine development more thoroughly. I do not profit off any of these sales, these are just some books that have helped me out ๐
My Recommended Game Engine Books: Game Engine Architecture: https://www.gameenginebook.com/ Game Physics Cookbook (Read this before the next physics book): https://www.amazon.com/Game-Physics-Cookbook-Gabor-Szauer/dp/1787123669 Game Physics (Ian Millington): https://www.amazon.com/Game-Physics-Engine-Development-Commercial-Grade/dp/0123819768 Game Programming Patterns (Free): https://gameprogrammingpatterns.com/
My Recommended Beginning Game Programming Books: JavaScript Game Design: https://www.apress.com/gp/book/9781430247166
My Recommended Java Books: Data Structures/Algorithms: https://www.amazon.com/Data-Structures-Algorithms-Java-6th-ebook/dp/B00JDRQF8C LWJGL (Free, but I haven’t read this thoroughly): https://lwjglgamedev.gitbooks.io/3d-game-development-with-lwjgl/content/