Ever wondered how wonderful it would be to port Minecraft to the GoldSrc engine? Well, now it exists! The gameplay should be similar to the alpha/beta versions of Minecraft, so block placing/breaking, health, crafting, smelting, and mobs are going to be in the mod

Post news Report RSS Half-Craft: Infinite blocks, Discord

In this article I will summarize the events of how I got infinite blocks working, provide a link to a Discord server, and a link to the mod.

Posted by on

Hey!

So firstly I want to announce that now this mod has a Discord server so you can get the latest news about the mod and chat about Half-Life and life in general! Click this Discord icon to get the invite!


So, what has been going on in the last 20 days? Well, it was mostly figuring out how to get pass the GoldSrc entity limit. I have been using individual entities for blocks, which was the simplest thing to implement at that time, however, it presented me with a maximum 8192 block limit. If you are confused, picture this: a single chunk in Minecraft has 256*16*16=65536, and even if we were to fill that up to the quarter, it would be 16386 blocks! This is going to be a problem, so I started implementing an independent subsystem for chunks and blocks. I also needed to implement custom drawing routines on the clientside.
Everything went fine until I encountered a bug at the last moment which prevented the cube to be properly rendered. It took me a couple of hours to realize that OpenGL asked for a horizontal FOV, and GoldSrc worked with a vertical FOV. I was pissed by the sheer amount of not documenting code properly in GoldSrc already, but this was the worst case. This took me a week to finish due to high school also being a thing.

Yeet

Problems rose up again as I was implementing the networking for the blocks. The base for this networking system is the message system that GoldSrc generously provides with, but it's less generous with the buffer size limits.

This was the message that the game spit out to the console when the message buffer overflowed


See, I was sending a message every time when I spawn a block. This instantly filled up the message buffer when I filled up a single 16*16*16=4096 space. My solution? Create a queue which GoldSrc point entity would empty by a certain amount every time the game looped. This again took a week to finish, but it was worth it and you can see the result in this screenshot.
I was planning to write a new article a few days ago when I realized: Should I implement physics? I said yes, and yet again implemented another system for the physics system that GoldSrc uses. GoldSrc uses C for the physics, while the rest of the code is C++, so this lead to me removing the entire system altogether and physics still doesn't work. Since I was planning ahead in my block system before, I could easily add in new blocks, so I added in 15 blocks into the game and made the world look like dust in the summer sunlight.

Btw, this is actually really slow to render (10FPS) and the background doesn't refresh

As a last thing to add, I will link a Youtube video that shows the current performance of the networking and the drawing system

See you later guys :))))

Post comment Comments
Guest
Guest - - 691,443 comments

This is very interesting, especially the use of entities instead of using brushes. Do you plan on maybe implementing "ray-casting" for lack of better works, to only render blocks the camera can touch with "rays". So you can unload models and reduce the amount of geometry in view? Asuming all of the above, unless you've already done something similar.

Reply Good karma Bad karma+5 votes
b4n4n4 Author
b4n4n4 - - 28 comments

Yes, I am planning to do a similar optimization. It's basically frustum culling and ray casting so only those blocks render that matter. Frustum culling will determine which chunks are in view. The rays will shoot out a ray to the player from those blocks that touch air (including blocks in caves) at the server side and if they intersect a non-non-air block, the block is not going to be sent to the client. Kinda complicated but I think this will definitely give a performance boost in both the client side (less things to draw) and the server side (less things to check in collision detection).

Reply Good karma+3 votes
paul_leps1
paul_leps1 - - 3 comments

unban me from your half-craft discord plz

Reply Good karma Bad karma+1 vote
Magic_Nipples
Magic_Nipples - - 1,325 comments

Nice to see you danced around the old limits of Goldsrc. Similar to what the guest below said, I'd be great to get ray casting in to improve the performance now.

Reply Good karma Bad karma+5 votes
Dune_Jumper
Dune_Jumper - - 1,586 comments

The graphics are blocky lel

Reply Good karma Bad karma+2 votes
Guest
Guest - - 691,443 comments

This comment is currently awaiting admin approval, join now to view.

paul_leps1
paul_leps1 - - 3 comments

sorry i was not sigh in like i was saying unban me from the half-craf discord plz i swear i won't break the rules again

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: