Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

migblock#1: creating a minecraft client

so, if u havent heard the news, migblocks direction as a project has changed, it is now an open source minecraft client

https://github.com/harramooli/migblock

which is a pretty sick idea, but now i have to make the thing, hahahaha


so the first step, was making a connection to the minecraft protocal, thanks to https://github.com/PrismarineJS, this was very easy to pull off, and i can let these geniuses handle the minecraft stuff, and i can focus on migblock

but hang on! isnt prismarineJS written in javascript? and isnt migblock writen in c#? well yea thats correct man, it is hahaha, but thanks to some other geniuses, we have this: https://www.gnu.org/software/libc/manual/html_node/Standard-Streams.html, and we can use it to create a child process of a javascript program and read and write to it, so all we do is bring the compiled javascript binary into our unity assets and create an executing instance of it, just like when running an internal server for singleplayer, simple!

wait u can compile javascript? yep, thanks to the node package, pkg! https://www.npmjs.com/package/pkg, i havent tested if this works in a standalone build yet, but lets hope it does! 

... yea im a little worried now, so lets test it before we continue

first ill create a simple project in javascript, actually nah ill use one i already have... enter js009, the awesome project that prints a bunch of blockdata to view id differences for documentation 


awesome, very simple, prints a bunch of output lets compile it with pkg and then upload it to my server (that does not have node or npm installed) and see if it runs as standalone (it should)

we run: pkg main.js -o test.out


done! now we can use scp to upload it to the server... copying... (its 148MB)... done!

login... and test.out is there... lets run it! yep! it works perfectly! so it will work in build releases for migblock, nice!


OK, ONTO THE REAL DEVLOG

so the next thing in our story is how i got the world to render! exciting, basicly when a chunk loads in the nodejs module, it sends and event to the event handler in the c# unity project, and then the project will render the terrain./.... but converting minecraft world data into migblock engine (qublock) data... well that was not easy, it took a few attemts and some playing around...

heres some failed attempts:


but eventually i got it working, and i was able to render the terrain from minecraft inside of unity



but we had a problem... as u can see here, the player (steve) in minecraft is looking to the left, at a mountain, BUT in unity, the character is looking left at a tree... and the mountain is on the right..... so somehow, the minecraft world data is being flipped when it gets into unity......



which is like, what the hell do i do next???? well, the answer, (i thought at first) was pretty simple, 

"derr me just flip camera projection horizontaly derrrrr", this would work in theory, but still, it didnt, but trying it took some work


almost there, but now the entire matrix is screwd up, i could of fixed that by changeing the material to render in reverse, but i didnt think of it, but good thing to, cos my day was abt to get even harder


yea, culling is always needed when rendering for games, and i managed to break it XD

but after some playing around, i found that it turns out minecraft worlds and my engeine (qublock) are completely flipped, like when compared, so minecraft information comes in, and u have to write it as z, y, x, and then it works, you CAN just do it normally, x, y, z, but then the game character will be out of wack and all fucky, so simple fix was to change the chunk index math to be z, y, x, and then convert all incoming events to z, y, x, then it works perfectly!

heres a video showing how awesome it is now that its all working!


Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.