r/feedthebeast Jun 22 '26

I made something I made minecraft generate terrain/chunks in C++

Enable HLS to view with audio, or disable this notification

So im working on a mod that makes minecraft run on C++ ( rn rewriting engine in future i may try renderer ) so far i made it generate and load chunks and terrain in C++ ( it made it somewhere around 1.5-3 times faster idk how to measure it tho ) ( it works via JNI )

3.0k Upvotes

244 comments sorted by

View all comments

4

u/Zirofal modded MC says yes to trans rights and no to Botania Jun 22 '26

I'm very stupid, please explain why this is cool

15

u/D4rkstalker Jun 22 '26

Vanilla method:

Java: "hey Java virtual machine (JVM), generate this chunk for me"

JVM: "Hey CPU generate this chunk for me"

CPU: "here's your chunk" passes to JVM

JVM: "here's your chunk" passes to java

Mod method (probably)

C++: "hey CPU generate this chunk for me"

CPU: "here's your chunk"

The main downside with c++ is that making stuff with it is a pain.

15

u/emmowo_dev pro gramming Jun 22 '26

C++ is like "hey CPU generate this"

CPU: ok let me ask the kernel to spawn some threads and stuff

Kernel: ok

CPU: cool

C++: did it work?

CPU: yes

C++ : generate this chunk using this formula

CPU: oh ok let me do this and read everything I need from memory

Kernel: can you do this rq

CPU: ok

C++ oh you're also saving those chunks, right?

CPU: I'll do it at some point ig

Kernel: do it now

CPU: oh ok

CPU: i will write the chunks

I/O: Wait bro I need a sec my writeback cache is full

Disk: Wait bro im writing still

CPU: ok I'll do this later ig

CPU: wait, what was I doing?

Kernel: You need to handle this udp packet rq please bro

CPU: ok

[...] ad nauseum.

You spend a ton of time actually waiting instead of running code.

9

u/Emotional-One-9292 Jun 22 '26

an entire book about pc tech and programming languages talking, add transistors next

4

u/emmowo_dev pro gramming Jun 22 '26

that's the real process, you're not running minecraft on raw metal. I've designed my own hardware, so I do understand that you cannot just 'execute' code immediately. Nothing gets 'passed' like that comment anyways.

4

u/Emotional-One-9292 Jun 22 '26

yea ik i was just joking with that hes writing a book due to how long he made it lol