ah Minecraft everyone loves a good bit of Mining and crafting uh even though child labor was abolished in the 1930s the children still yearn for the minds and Minecraft is the bestselling game of all time and it's pretty simple and like uh I like money so how hard could it be to [Music] clone so okay okay where do I begin uh well Minecraft is 3D so got to do that but what is 3D well okay what you think of as 3D in every video game is actually lies and deceit to render anything in a game
you need to tell a graphics API like open G to throw stuff up onto the screen and every quote unquote 3D Graphics API is actually just a 2d one but pretends to be 3D by using the mystical power of math so okay okay you start with the idea of a cube which is pretty cool in all 3D is cool but it's just a bunch of connected points in 3D space which doesn't mean much as as I said earlier the API does not know 3D but if you then do some weird crazy matrix multiplication and TDA
the idea of a 3D object has been mutilated and deformed into a 2D shape that looks 3D from a certain angle which can then be rendered by openg GL onto the screen so then you can lie to the masses and say oh look I did 3D and toada a cube now forget that more Cubes but slight issue I can't really move or do anything it shouldn't be a big issue just have to copy how Minecraft does movement and that should be pretty simple it's just some block game I am fully convinced that during the late
2000s and early 2010s Mr notch Minecraft himself was high of his balls on the finest gunja this side of the Atlantic I don't know it was even possible to code movement code this okay okay deep breaths okay relax uh code movement code this socially impaired yeah okay that that's much better language don't to get demonetized so okay my journey began on the Minecraft Wiki cuz where else would you go if you to copy Minecraft and then I found out the exact values and the details on how Minecraft movement works and it worked kind of also
fun fact even though flying is faster than walking it actually has a smaller acceleration but when you're flying you experience less drag and friction because you're in the air and stuff so you can actually build up more speed and that's why flying feels really floaty because the low acceleration means it takes time to build up speed and the low drag means it takes time to lose it too not important but also while I'm on the topic the acceleration for flying on the wiki is actually wrong it's supposed to be 10 times smaller which confused me
a lot at first I just thought I'd mention it because I didn't want to make an account to fix it I'm lazy but okay then I added diagonal movement and that is it exists so if you've played Minecraft for a bit you might have learned that moving diagonal is faster than moving forwards and if you don't know that then now you do and this is something you actually see in a lot of 2D top down games but Minecraft has it too because [ __ ] you that's why but why does that happen o pick me
pick me sure thing little buddy uh is it cuz not normalize the coordinates and the speed increases cuz how triangles work wrong well okay it's sort of like that but it's not the entire story now okay okay the myths and legends are true that long long ago in the fairy tale make-believe lands of Sweden that when the cosmic being known as notch himself gifted the species homeo sapiens with the Cube game that he coded the game to work like this if the player presses forwards go forwards and if sideways go sideways but because of the
good old Pythagoras Theorem and just basic trigonometry [ __ ] Greeks you go 41% % or route two times faster than you should go if you move diagonally as the two speeds combine only if you're crouching that is because you can only go 41% faster if you're either crouching or Sprint crouching which is something I never knew you could actually do if you're just walking normally sprinting or flying then you instead go 2% faster diagonally what the [ __ ] and I was wondering for a really long time why why and God green earth does
this happen well through the power of the Minecraft Parkour Wiki which is a real place and also P it I got the reason why so it turns out those acceleration values from earlier are not the real values okay they're the ones that are used in the physics but they're not the actual ones that are stored that's important because what Minecraft does is a multiplies these stored values by 0.98 uh for some [ __ ] reason and also the values are multiplied by 0.912 because [ __ ] you that's why and then you get those final
values if you're moving forwards then the value multiplied is used and if you're crouching then what happens is you get that 41% increase from trigonometry but if [Music] the normalized triangle is actually still longer than it should be and it is exactly 1 over 0.98 times faster which is about 2% this has to be done on purpose there is no other reason for the physics to be this weird as it would be really easy to fix this but 10 years later it's still here and Minecraft is full of these weird bugs like on the Minecraft
Parkour Wiki it even lists a couple how convenient like the Anvil Collision hit box is so [ __ ] that if you make a wall of anvils back up to it and then look at another anvil in a different orientation you can actually clip through the wall okay that was fixed in 1.9 but you still have stuff like 45° strafing which exploits the weird movement from earlier to get both the 41% and 2% speed increase and also the fact that the Collision for the X and Zed axis is done completely separately which means that some
job jumps and runs are actually impossible based on your orientation but after all that it works remember how I said I was making a Minecraft clone yeah I nearly forgot about that also I got camera movement and block placing working but that's boring now the next task gravity as right now I'm just floating and can't really go up or down so uh let's fig that but what is gravity no no no stop I already did that jokes already getting old now I did add gravity and even collisions but it was much more annoying and stupid
than you would think it would need to be because of Minecraft being a game of lies and deceit that technically always starts a server even in single player it's just a local one that has a separate clock independent of FPS which is always at 20 the clock not FPS which made physics really annoying but it worked and I will not go into the details because they are very very very boring and even thinking about them is making me tired and with some extra Collision code I could even do some parkour and I present to you
extreme gam [Applause] [Music] play Oh Baby triple now that's cool and all but if I show this to my grandma she wouldn't think that's Minecraft so epva stolen art to the rescue so in a Minecraft Java resource pack there are two important folders there's the textures which stores as you guess the textures and most of them are just 16 x 16 pngs but the important folder is the models folder as that contains the actual shape of the block and what textures go on which bit which for something like Cobblestone the model file is literally just
make a cube and put this texture on every single face but for something like a brewing stand for example it's a bit more complicated and it took me so long to code it in so the program could just look around and just generate blocks but now this program can support every single block in Minecraft and if they add more I just pop in a more recent resource pack and it generates them all well okay it doesn't support blocks like chests or Bells because they are technically entities and not blocks or block entities uh why it's
because from the late 2000s to early 2010s Notch Had encounters with the devil's letters don't do drugs kids God will punish you for it but okay next thing textures look like Minecraft but slight issue the lighting man just sucks and Chada now we went from looking like Minecraft Alpha to a later version of Minecraft Alpha very simple all I did was just shade the faces different depending on their orientation which makes depth a lot easier to notice but this all looks off still and voila Minecraft Beta actually no the textures make it look like a
Minecraft release version uh through the power of ambient occlusion now every corner is checked for every block around it and depending on how many there are actually gets shaded lighter or darker and if you're still thinking but it still doesn't look like Minecraft then okay smart guy here are two screenshots which one is the Clone had a good look Four Eyes well guess what nerd none of them are this one's actually from the Clone wait uh no I actually mixed the pictures up that one was from the Clone or is it no no it's actually
from the Clone okay so I got some cool Lighting in but this is too boring this is just too flat and not really a good example of this doesn't look like Minecraft so I added support for loading in Minecraft Terrain it did also mean that I had to code support for loading and Minecraft terrain but uh my time isn't worth that much anyways and it uh works the grass and leaves are all gray oh come on so it turns out that the textures for leaves and grass is black and white well black gray and white
because they don't have a set predefined color and they can look different because if you're in a desert biome they will look a bit yellowish a plains biome they look normal uh uh like tundra biome they all look slightly pale it all changes depending on the biome so you can't really set one texture and that black well black gray and white texture exists like that because you can take that texture multiply it by some color and boom you have this fancy color texture without needing to create like 50 trillion of them and the thing that
actually defines these colors is two different textures one for the grass and leaves and the texture is well can be thought of as a triangle with the X and Y AIS being the actual temperature and humidity of the biome and what happens is you input those as coordinates and whatever color is at that specific point is going to be the color you multiply that texture with so I could add support for all the those different colors and textures or I could be really lazy and just hardcode in one color for the grass and leaves to
be because I don't actually have biomes in yet so it won't actually make a difference you know it's a bit cheaty but you know no one's going to know right you're not going to tell anyone right just just just be quiet and look it works the grass and leaves are now nice and colorful and you can walk around play some blocks and you know it works pretty small world size though so I think I got to increase it oh that's a lot of lag so there are two reasons why this is slow as balls time
is wasted rendering faces of blocks that you can't see as they are being blocked and the ambient occlusion shading stuff has to be recalculated every single frame which is a bit wasteful so I then added Cod that skips rendering the faces that you can actually never see as they're being covered and then it also added code to store and cach the data and some other stuff too so I didn't need to recompute it every single frame and only when the world actually changes and look at that is way smoother now and it doesn't run like
ass you can even build a lower house do some Parkour do a bit of caving you won't really be able to do much of it but you know it works now this does need a little bit of work still so I won't be posting it online to download yet as this doesn't do any meshing so the rendering is still actually really slow and I think it will be better released when you can actually I don't know do some custom terang in maybe break and pick up stuff as well and inventory would be nice because that's
why I actually want to do so you know stick around and maybe I'll post a download sometime but anyways like comment something uh join the Discord I put some stuff there and some sneak peeks sometimes and subscribe with the Bell button on to pick the algorithm like me more and see you in the next video