r/GraphicsProgramming • • Oct 18 '26

Source Code I rewrote Minecraft Classic versions in plain C

A while ago I posted my C rewrite of pre-classic versions. Now I did the same with Classic: every version from 0.0.11a up to 0.30, plus the dedicated servers.

It renders the same way the original did in 2009: fixed-function OpenGL, a display list per chunk, glFog, no shaders. I tried to keep the output exactly like the original.

Uses GLFW, GLEW, zlib and stb. Play around, feedback is welcome!

github.com/degradka/mc-classic-c

456 Upvotes

62 comments sorted by

17

u/pierspad Oct 18 '26

What's the difference with Minecraft Java edition/bedrock edition?

Up to which version do you plan do rewrite?

What do you think about setting up few benchmarks (such as world generation speed, chunk loading etc.) to compare it with the original? Maybe this wasn't your goal, but I think it will be way more painful for you to optimize and parallelize plain c

32

u/degradka Oct 18 '26

This is Minecraft Classic, way before Java Edition as we know it. After classic there is indev, infdev, alpha, beta and then the release. So this isn't a rewrite of modern Minecraft, just the early versions that were a browser game.

0.30 was the last classic version so that's where this project ends, but in an ideal world I'd go up to the 1.0 release version.

The goal was a 1:1 recreation in C, but later I want to make a separate repo where I'd prioritize performance. Right now it's basically Java translated to C, and of course if I rewrote it the proper way, with multithreaded world gen and chunk building and a modern renderer, it would be much faster.

62

u/Gobrosse Oct 18 '26

so to be clear, this is a line-by-line port from decompiled Java, by hand? not LLM-generated?

128

u/degradka Oct 18 '26

Yep, I continued my mc-preclassic-c project (started 3 years ago) and worked version by version

Of course sometimes I used ai to understand why I got seg faults and other errors, but all of the code is written by me

86

u/Netherman555 Oct 18 '26

Yeah anybody who gets mad at using ai for questions needs a reality check for better or for worse, its part of the world now

36

u/AvidCoco Oct 18 '26

Using AI for bug fixing etc is the best way to use it for coding for sure. It lets you stay focused and not have to stop for 3 hours to figure out what you did wrong.

5

u/certainlystormy Oct 18 '26

i've been using claude on & off for assistance with things i don't understand in lecture and it is SO nice to not spend five hours googling something. one of my courses has us learning assembly to interact with some microprocessors and i was sick last week, so i didn't get the intro everyone else did. its amazing that i can just ask a question about some instruction syntax and then verify its answer by building and running my project

3

u/sinterkaastosti23 Oct 20 '26

It does deteriate the devs debugging skills tho

3

u/Nuclearo-Dinosauro Oct 21 '26

Debugging skill is googling, reading, trial and error and bashing your head. Then remember it to avoid it. This is no different using AI, only it takes less time.

Structuring, organizing, optimizing code is where the important decisions are.

-1

u/AvidCoco Oct 20 '26

Thats a non-issue in my opinion. If a tool can solve a problem as effectively as a human there’s no need for a human to up-skill in that area.

It’s like saying using C deteriorates the dev’s assembly skills.

1

u/sinterkaastosti23 Oct 20 '26

Thats not the same

Devs still need debugging skills to understand what the LLMs tell them. And LLMs wont always be able to find the bug

1

u/AvidCoco Oct 20 '26

The way I think of it is I’d rather write higher level code that expresses my general intent without having to worry about every edge case, undefined behaviour, etc. I ask Claude to review my code and fix any obvious issues, I even have it write custom ClangTidy checks for me to make sure they don’t regress, and when bugs do slip through I have Claude fix them. All of that means I can focus on what actually adds value and moves the project forward.

-14

u/tree-hut Oct 18 '26

Least obvious insecurity coping

5

u/Netherman555 Oct 18 '26

Im not a fan of AI but its in practically everything. Using it to find out issues is basically just using it as a search engine. Plus its shoved in everything so much to the degree that I've never even paid for an AI and end up using one practically every day.

16

u/EC36339 Oct 18 '26

Segfaults are the one thing where I would resort to an oldschool debugger. AI would simply take longer or struggle at this task.

9

u/yawara25 Oct 18 '26

LLMs can use debuggers now.

10

u/kat-tricks Oct 18 '26

debuggers are free

4

u/yawara25 Oct 18 '26

Yes, that is correct. Many of them, anyway.

3

u/kat-tricks Oct 18 '26

the same cannot be said for the LLMs that can use them

2

u/yawara25 Oct 18 '26

Also correct.

-1

u/kat-tricks Oct 19 '26

oh god please dont fucking do the thing where you pretend you just wrote a random fucking sentence that just happened to be contextually relevant i swear to fucking god i am so done with this shit

0

u/[deleted] Oct 20 '26

[deleted] — view deleted comment

→ More replies

1

u/g0atdude 25d ago

I guess you never used paid software in your life

1

u/kat-tricks 24d ago

did i say this was a moral issue?

You do the maths. What makes more sense- pay once for professional software (if you can afford to), or pay many times for an LLM. And if you want a good one, Astra isn't cheap...

1

u/EC36339 Oct 18 '26

They could for a while. It's just a strange choice to use LLMs ONLY for running debuggers and not for everything else.

1

u/augustusgrizzly Oct 21 '26

yeah nah im just leaving this sub at this point...

0

u/Cylian91460 Oct 18 '26

No and no, it's a reimplementation in C not a decompilation

9

u/Gabrunken Oct 18 '26

Thats simply amazing man, keep it up

5

u/degradka Oct 18 '26

Thank you!

3

u/Competitive_Cash5216 Oct 22 '26

Really cool dude! also i'm pretty sure classicube also does the same thing.

1

u/degradka Oct 22 '26

Exactly, plus it has modern rendering pipeline

6

u/Firepal64 Oct 18 '26

This seems great. I'm curious about the decompilation process

18

u/degradka Oct 18 '26

Thanks! It goes roughly like this:

I get the original jars from Omniarchive and decompile them with CFR. Up to 0.0.13a they weren't obfuscated, so you still get the real names, which is nice. From 0.0.13a_03 on everything is single letters, so that's where it gets annoying.

RetroMCP has community names for 0.0.23a_01, so I wrote a little matcher that carries those names over to newer jars by comparing how the classes and methods look. Whatever it can't match I name by hand based on what the code does.

Then for each version I diff it against the previous one and port what changed. Diffs miss old bugs though, so before calling a version done I go through the whole jar again. For the big diffs I used AI, and checked what it did against the jars.

One thing I didn't expect is that decompilers lie sometimes. CFR reorders statements, makes up || chains that aren't in the bytecode, and once showed an object being created twice when it's actually created once. So whenever something looks weird I just check the bytecode with javap.

To make sure it actually matches, I run the original jar's code with a fixed seed next to the C version and compare the output byte for byte. World gen, block drops, TNT, mob spawning, save files, all of it.

2

u/TheJackiMonster Oct 18 '26

Looks pretty good!

6

u/outofindustry Oct 18 '26

display list, now that's a term I've never heard for a long time.

1

u/LeateWonceslace Oct 21 '26

Why are you using the beta version of cobblestone instead of the alpha version?

1

u/degradka Oct 21 '26

I’m using the original textures for each version, what are you talking about? Could you add a pic?

1

u/LeateWonceslace Oct 21 '26

I could be wrong, then. I remember the cobblestone being way less detailed than that to start with.

1

u/Renulev Oct 18 '26

What about copyright infringement, though? The textures are proprietary!

3

u/degradka Oct 18 '26

I think Mojang is ok with older versions, we’ll see

1

u/psicodelico6 Oct 19 '26

Does ir use less memory?

8

u/degradka Oct 19 '26

Just did the test, standing still after generating a world:
Original - 349mb
C version - 183mb
And for fps, original is 954 fps and c version is 2218

And that’s without any optimization

1

u/AloneBlueberry9390 Oct 19 '26

Wow, that’s really cool… How long did the entire project take?

2

u/degradka Oct 20 '26

Thanks! Can’t exactly tell because I was inconsistent, but the project started with preclassic 3 years ago

3

u/TimeSFG Oct 18 '26

Awesome sauce

2

u/ArmyFrosty7976 Oct 22 '26

You really interested me and I'm thinking of porting your version to my OS, but before that I need to do a Damn OpenGL (I think I'm porting TinyGL)

2

u/EBASHY_SOLI Oct 22 '26

АХ классический майн что может быть лучше

0

u/tree-hut Oct 18 '26

So what is the point of this, just learning? Since you didn't even modernize the rendering pipeline

8

u/degradka Oct 18 '26 edited Oct 18 '26

Learning, game preserving, modernize it later

1

u/BingoBongoVrn 26d ago

It doesn’t look fully AI-generated. The first part looks written by a person, and the later work was very likely done with heavy help from an AI. Nothing proves this either way, but the signs are fairly clear.

Phase 1: Jan–Sep 2024, looks hand-written

  • There are about 25 small, step-by-step commits whose messages admit to problems: “add level saving/loading which throws segfault”, “implement frustum which doesn’t work properly”, then “implement frustum that actually works”.
  • The code reads like a beginner doing a line-by-line port. It has wordy comments on almost every line (“// Calculate index from x, y, and z”, “// Is dark tile”) that follow the commented Java in thecodeofnotch’s repos. It also has inconsistent naming, like levelRenderer_lightColumnChanged next to Level_init, and K&R () instead of (void).
  • There are no em-dashes anywhere in the 2024 code.

Phase 2: Sep 25–26 2025, strong signs of AI

  • Commit 15b1d20, “fix segfaults, block placement, cleanup build, and add README”, rewrites all 27 files at once (+1066/−1146). The beginner comments disappear, and every file gets a header like // level.c — world storage, lighting columns, IO, and solid-cube queries. That em-dash summary header is a typical ChatGPT habit, and it now appears in 125 of the 180 source files.
  • New code gains the habits AI models tend to have: (size_t) casts everywhere, (Java parity) notes, designated initializers, and static caching of QueryPerformanceFrequency.
  • Three more game versions and particles appear in about 15 hours, overnight, with ~2,000–2,900-line commits. Much of that is copying earlier version folders, but the speed is still notable.
  • The “update timer” commit adds macOS mach_absolute_time support, even though the README only covers Windows and Arch Linux. Adding code for platforms nobody asked about is a classic chatbot tendency.
  • One comment talks to a reader: “Slight shading like leaves; you can also just use 1,1,1”. That’s chatbot phrasing that got pasted into the code.

Phase 3: Jul 2026 bush fix, likely an AI coding agent

  • Commit e69c90f has a comment describing the code’s own history: “(this previously drew a flat shaded box diagonal… same bug already found and fixed in mc-classic-c)”. AI agents often leave comments like this; people rarely do.

What a person clearly wrote

  • Many commit messages: “fix versions fuckery i’m stupid”, “oopsie, move README”.
  • The README’s jokey intro and outro (“rewritten as God intended”, “If you think this is a dumb project, you’re right. But it runs.”).
  • The README’s build instructions, with their curly quotes and polished step layout, may have been AI-assisted.
  • The two outside pull requests: one is a bot security fix from orbisai0security, the other a one-line GLEW fix.

Overall: a person started a real hand-written C port in 2024, then in 2025 had an AI (most likely ChatGPT or similar) rewrite and extend it. Most of the code you see in the repo today was probably AI-written or AI-rewritten, with the author steering it and testing the result.

PeriodLinesShare
2024 (looks hand-written)~2,620~21%
Sep 2025 burst (likely AI)~9,560~78%
2026 fixes~34<1%Period Lines Share2024 (looks hand-written) ~2,620 ~21%Sep 2025 burst (likely AI) ~9,560 ~78%2026 fixes ~34 <1%

-9

u/helpprogram2 Oct 18 '26

What’s plain about c?

13

u/degradka Oct 18 '26

Meaning without anything extra like c++ or framework

4

u/lukkasz323 Oct 18 '26

everything.

-2

u/Novel-Umpire3867 Oct 19 '26

Now do it in Rust

2

u/zedin27 Oct 19 '26

Why in Rust specifically?

1

u/g0atdude 25d ago

No no, do it in brainfuck please

1

u/psicodelico6 Oct 19 '26

Yes, please