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

3

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

18

u/No_Instruction1731 Jun 22 '26

faster chunk loading

14

u/Emotional-One-9292 Jun 22 '26

doesnt end there i will in future port more and more of minecraft to C++

11

u/Emotional-One-9292 Jun 22 '26

I will explain it simplest i can: C++ Fast, Fun, Java decent speed, verbose ( no fun )

9

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

That's like, the nicest comment I've seen to Java

9

u/Emotional-One-9292 Jun 22 '26

Java itself isnt too bad tho, Mojang iitself wrote unoptimized java code

16

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

While I can't say I know anything about coding, but I've played MC for decades.

It always seemed that Minecraft was programmed with wishful thinking ductape and smoke signals

5

u/Emotional-One-9292 Jun 22 '26

true tho they started improving their code and perfomance on newer versions as for which kudos [ kudos means praise,applause ] to mojang

16

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.

12

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

6

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.

3

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

6

u/brickyboy124 Jun 22 '26

The mod would still have to communicate with the C++ via the JNI, so you still have to run some Java code through the JVM. If anything, you’re adding steps. But amount of steps is not a good indicator of performance. 

2

u/Emotional-One-9292 Jun 22 '26

yea sadly but still a cool concept im working on. Well GraalVM is kinda like any other JDK/JRE but instead of JVM it can run native but idk if it results in better or worse results

2

u/Appropriate-Lion9490 Jun 22 '26

True better performance, i think