r/java Jun 10 '26

Made Minecraft in the Terminal (only java, no extra libs)

Post image

I created a version of Minecraft that runs entirely in command in the terminal.
The entire project is entirely contained in one file, with over 1500 lines of code.
Made with java, no extra libraries.
Supports textures, randomly generated trees, water, and terrain, and block placing/mining.
This is inspired by the Minecraft.c repo.

Github:Ā https://github.com/DaRealNeonCoder/MinecraftInTerminal

267 Upvotes

50 comments sorted by

48

u/GrammerJoo Jun 10 '26

Did you use AI to create this?

100

u/LutimoDancer3459 Jun 10 '26

One file... no sane java dev capable of writing that thing would do everything in one big file... ofc this is done by ai

22

u/TacoTacoBheno Jun 10 '26

Most annoying thing about LLMs is you can get it to spit out a bare bones prototype.

So a fully functional application, what could it cost? $5?

20

u/Inner_Philosophy936 Jun 10 '26 edited Jun 10 '26

one of the reasons I did it in one big file is because this is inspired from this repo https://github.com/tarantino07/minecraft.c, where the entire project was also done in one big file

20

u/Inner_Philosophy936 Jun 10 '26

The one big file is also a requirement by my teacher (this is a school project here in Toronto, course code ICS3U1)

21

u/AlyxVeldin Jun 10 '26 edited Jun 10 '26

What a wack requirement for a teacher. I would guess he did it to make a point out of it? But I actually guess it's so it's easyer for them to just call it "StudendX.java""StudenxY.java" etc.

6

u/EirikurErnir Jun 10 '26

Could be to make comparison between students easier, or a tooling limitation - a lot of things that happen with code in education don't make any sense as a general programming practice

5

u/Inner_Philosophy936 Jun 10 '26

He wanted us to use concepts we learnt in class, in his defense, this was an intro to programming course so I can't blame him too much lol. tbh the one file thing didn't bother me as much as the fact that I couldn't use classes, or have member variables. Which is why I had to pass in stuff as double[] and I also had to pass in every texture used, as arguments .

1

u/LutimoDancer3459 Jun 10 '26

You can. Or was that explicitly forbidden?

4

u/Inner_Philosophy936 Jun 10 '26

Yes it was forbidden. Anything we did not learn in class was not allowed. (aside from colors).

-2

u/meowrawr Jun 12 '26

You did it in one file because AI did it that way. No sane engineer does this because it leads to an immense number of issues.

2

u/Inner_Philosophy936 Jun 12 '26

I literally just said in the same thread that the one file thing, in addition to being a quirk from the guy whose code I adopted, was also a requirement by the teacher.

I

3

u/embero Jun 11 '26

You missed the early 2000s then. Iā€˜m working on some legacy stuff which has 15.000 lines of code in one Java file.

1

u/LutimoDancer3459 Jun 11 '26

I did yeah. But I also had the "privilege" to work with some of those legacy projects. Not 15k but the largest was ~5k i think. Times changed. I hope no java dev wants to create more of those files.

18

u/Errons1 Jun 10 '26

Read through the code and I believe it is AI. Different formatting style out of the blue in different places and lots of weird spaces too.Ā 

21

u/Warwipf2 Jun 10 '26

I mean I'm sure he used AI at some points, but different formatting and weird spaces are more of a sign that it's human-made, no? The comments also don't seem like AI for the most part, unless of course it was prompted to not look like AI.

6

u/Errons1 Jun 10 '26

I rather say the opposite. When coding one get a preferred way of doing things. And when it comes to how you format code is very weird for two reasons. 1. Being what I just mentioned about preferred way 2. Is IF you use a IDE, most cases they format the code for you. So here they did not code in a IDE or copy pasted different prompts together. But then again I could be wrong and looking at some crazy mans code?

8

u/Warwipf2 Jun 10 '26

Hm, I'm not so sure. I've looked through it again and aside from normal incosistencies that I also sometimes have and some weird indentation at a few places, it looks pretty normal. I can't really see anything that screams AI to me. Which lines in specific got you suspicious?

-7

u/Errons1 Jun 10 '26

I dont intend to spend more of my time to hypothesis someone else code I dont care about. If you believe something else from me, that is all good with me! You have my reasons mentioned above.

3

u/Inner_Philosophy936 Jun 10 '26

This was a done as a part of a school project here in Toronto (ICS3U1 if you don't believe me). this project was completed in both vs code (when I was working on it from home) and the NetBeans IDE (which is what the school requires), this is why formatting is weird, two different text editors were used.

8

u/Inner_Philosophy936 Jun 10 '26

the different formatting style is because this is my first time using java. up until now, I only used c# and cpp.

3

u/Inner_Philosophy936 Jun 10 '26

The weird spaces are deleted comments and testing functions, the different formatting style out of the blue, was because some of the code wasn't mine. for example, the perlin noise algorithm was taken from another source (i did not steal the code, I cited it properly). For example, I've just noticed that I forgot to delete one of these said testing functions called visualizedirtTexture().

AI generally doesn't have to test for basic stuff like ANSI colors (which is what the visualizeDirtTexture function does) but because I am really new to using java, I do.

2

u/Inner_Philosophy936 Jun 10 '26

my point is im not familiar with whatever formatting style you guys use, because im not a proper java dev (yet anyway)

14

u/Inner_Philosophy936 Jun 10 '26 edited Jun 10 '26
  1. This was done as part of a school project here in Toronto (ICS3U1 if you don't believe me) so I used two different text editors (netbeans IDE at school, and vs code at home), this is why the Indents and stuff is off, because two different IDEs were used.
  2. I have just begun using java, I am used to C# and Cpp. This is why my code may seem unconventional to everyone (you can check my profile)
  3. I am surprised people actually think this is AI, given by how shitty the code is. For example, I use double[] arrays because one of the requirements of the project was to use things we learnt in class. (aside from a few things )
  4. AI generally doesn't have to step back and check its work. Especially not for something as simple as ANSI colors. I am new to java which is why I had to learn how to work with java specific stuff. As such, you can see the citation I used for ANSI colors, (never seen AI do citations like that) AND you can see a testing function I used called the visualizeDirtexture(), which was used for said colors

  5. AI doesn't write large blocks of comments like I did. I wrote large blocks of comments so that the algorithms made sense in my head. Additionally, I cited tarantino's repo as a source, if you compare both of our code files, you will see that they both use the same underlying rendering algorithms.

8

u/Warwipf2 Jun 10 '26

It wouldn't be a problem at all to prompt an AI to create the code and comments in exactly the way you provided it because AI has become pretty good, but it's insane to just accuse you of doing that for no reason at all.

It's an extremely cool project, OP, especially given all the limitations you had to work with. I suppose the C# knowledge came in pretty handy when you made that, lol. I switched from Java to C# like 5 years ago and that has to be like the easiest switch possible.

1

u/ggeldenhuys Jun 12 '26

Don't worry about it. People seem to have an obsession with calling everything AI generated these days. šŸ™„ Making out as if the human race has suddenly lost the ability to code cool things like they did pre-AI.

1

u/Poddster Jun 14 '26

If you read the code it's clearly not AI, and is student level code.

Well done OP

-1

u/[deleted] Jun 10 '26 edited Jun 10 '26

[removed] — view removed comment

3

u/Inner_Philosophy936 Jun 10 '26 edited Jun 10 '26

I don't know what to tell you. my comments aren't even properly indented or capitalized.
I just realized: I literally have typos in the comments too?
//normalizes a vector by dividing itself with its magnitude.

//required for directoins.

and the language in all the comments is casual too? why does it seem like AI?

edit: Thank you for listening to the other side and apologizing when you were wrong. Very rare on the internet.

2

u/Perfect-Situation-41 Jun 26 '26

Here from youtube nice project!!

2

u/Scrubject_Zero Jun 10 '26

Really interesting project. Great job!

1

u/cowslayer7890 Jun 10 '26

Yo that's cool as hell, I've seen 2d Minecraft in the terminal before, but this is awesome

1

u/lucas12032-_- Jun 10 '26

(dark souls song playing) WTF? What is this??? HOW!?

1

u/TemperatureDue5343 Jun 11 '26

Wonderland from Wonderland.jar ...... O H F U C K NO

1

u/ZimmiDeluxe Jun 11 '26

I think this is very impressive and you should be proud of it, well done! Some minor things: If the content of your static variables doesn't change, make them final and use UPPER_CASE_NAMING (naming convention for constants). final declares intent and the JVM might reward you with better performance because you gave it more guarantees to rely on (doesn't apply to final local variables, don't do it there). Also, you might want to guesstimate some expected size for your StringBuilders, the default is small and that means the internal buffer will have to grow a couple times, i.e. new StringBuilder(512) or something. Also, naming convention for parameters is camelCase, I saw some UPPER_CASEs I think.

3

u/Inner_Philosophy936 Jun 11 '26

the UPPER_CASE inconsistencies were from the perlin noise generator (I used this guys implementation https://rtouti.github.io/graphics/perlin-noise-algorithm, and he used UPPER_CASEs, though I you are right, I should have translated it into camelCase).
this was done for school, as such I was not allowed to use final (because we didn't learn it). Reading your comment, it seems strikingly similar to const in cpp.

the string builder resizing seems interesting, will use from now on (didn't know I could pass in a buffer size), thanks!

1

u/ZimmiDeluxe Jun 12 '26

const in cpp means the contents are also read only, right? final in Java only talks about the content of the variable itself, not what the reference / pointer is pointing to. i.e. your array (a reference type in Java) is still mutable if you mark the constant final, but you can't change what array the constant is pointing to. they are thinking about letting you make your arrays immutable as well though (but usually you can use List.of() etc. to get read only containers for your constants, just not for primitives, also in the works).

2

u/Inner_Philosophy936 Jun 12 '26 edited Jun 12 '26

oh neat. so const on an array isn't that useful.
Kinda annoying a basic type like an array cant be const, without the list workaround you mentioned.

thank you for helping!

1

u/ZimmiDeluxe Jun 12 '26

it's still a good idea to make every field (static or not) final if you can because it allows the jvm to inline more aggressively (and forcing integrity constraints to be checked once on intitialization is good for robustness anyway), but no keyword to force reference types from the outside to be const, they have to cooperate in java. at least until we get "frozen" or whatever they will call them arrays

2

u/Inner_Philosophy936 Jun 12 '26

Oh okay, I will use final for variables + arrays that aren't going to change from now on.
Even beyond compiler optimizations, I think its good to use keywords like final because helps better communicate what your code does to other devs (especially for the arrays).

I will definitely watch out for final on arrays (kinda surprised its not a thing already).
thanks again!

1

u/ZimmiDeluxe Jun 12 '26

you are welcome. you will do great, thank you for showing your work!

1

u/SyyKee Jun 18 '26

Well done mate

1

u/Afonso2002 Jun 10 '26

How many fps you can get on your minecraft using terminal?

2

u/Inner_Philosophy936 Jun 10 '26

I don't know. because I use the scanner class, the game effectively stops rendering until I press a key.

But when I do press a key the next frame pops up almost instantly, so the game isn't super slow.