Ironically, at the time, since it was only available for Windows, I’m not sure I ever actually played it—everything I knew about it was from YouTube videos. After they released a Mac version a couple years later, I did try it out, and enjoyed it, although I never got too into it. I think there’s some kind of strange attraction that people have to writing bad Terraria clones. You see them *everywhere* on amateur game development forums.

Part of the code’s charm is its unashamed verbosity, with the same commands repeating many times, rather than collapsed down into loops:

if (key.getKeyCode() == key.VK_Q) c = ‘q’;
if (key.getKeyCode() == key.VK_W) c = 'w’;
if (key.getKeyCode() == key.VK_E) c = 'e’;
if (key.getKeyCode() == key.VK_R) c = 'r’;
if (key.getKeyCode() == key.VK_T) c = ’t’;
if (key.getKeyCode() == key.VK_Y) c = 'y’;
if (key.getKeyCode() == key.VK_U) c = 'u’;
if (key.getKeyCode() == key.VK_I) c = 'i’;

This little tour of the computer keyboard (starting here with the top row) continues through most of the alphabet. 

And the inline data tables are many, full of magic numbers:

Short[][] blocktools = {{},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {11, 12, 13, 14, 52, 55, 58, 146, 149, 155, 158, 170, 173},
                                   {11, 12, 13, 14, 52, 55, 58, 146, 149, 155, 158, 170, 173},
                                   {11, 12, 13, 14, 52, 55, 58, 146, 149, 155, 158, 170, 173},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {7, 8, 9, 10, 51, 54, 57, 145, 148, 154, 157, 169, 172},
                                   {11, 12, 13, 14, 52, 55, 58, 146, 149, 155, 158, 170, 173},
                                   {},

This goes on for 168 lines. There’s a nice rhythm to the patterns, even if their meaning is completely inscrutable from the code.

The particular flavor of obsessiveness this shows is, I think, very tied to age and experience, and perhaps this is what makes the project so relateable to other programmers. I can well remember my own attempts writing adventure games in Commodore BASIC, using only goto for flow control. At the time, I didn’t really get functions, which seemed excessive, an indulgence for people who didn’t appreciate the power of goto.

The particular flavor of insanity in TerrariaClone, however, is also reflective of its history as code transported from one language to another. The project began in Python, which the programmer was more familiar with.

Before TerrariaClone, I think my only programming experience was really basic Python scripting—we’re talking “Battleship”-level. Originally the game was written in Python using PyGame, and I think that the reason I moved to Java was to avoid people from copying the source code—at that point I was under the illusion that it would be possible to sell the game

Where Python is quite lenient about encapsulation and structure, Java is more conservative. If one comes to it without understanding this, they might be tempted to stuff the main program flow into a single init(). This method grew so large that the Java compiler crapped out (1300 lines), so the developer moved the bulk of the code to another function, named codeTooLarge(). 

Although he has since removed 500 examples of unnecessary boxing – also artifacts of this transition to Java – we were left with a taste of what code looks like that doesn’t quite get typing:

public static void print(String text) {     
     System.out.println(text);
}
public static void print(int text)
{    
     System.out.println(text);
}
public static void print(double text)
{
     System.out.println(text);
}
public static void print(short text)
{    
     System.out.println(text);
}
public static void print(boolean text)
{    
     System.out.println(text);
}
public static void print(Object text)
{    
     System.out.println(text);

Since he posted it on github, some folks have tried to help fix it. Others have opted to port it to a third language for some reason

Since then, Radon has learned to code properly. You can see his more recent and reformed style in these recent projects.

Thanks to Radon for sharing this with the world!