r/GoldenAgeMinecraft • Developer • Aug 05 '26

Discussion The decay of the Java source code

The source code of the Java Edition is in decay. We can all experience it by looking at how unplayable modern versions are without performance mods.

But performance is not the only thing. Bad performance is a result of overengineered code.

When I was making mods for Indev and Infdev during the beginning of my career the codebase was very simple and well-structured. The main class contained a lot more than it ideally should, but it's the fate of all Java codebases and there is no running away from it.

A few weeks ago I was revisiting 1.11.2 Far Lands and I noticed that the code was now a bunch of Factories.

I haven't seen the latest source code (why would I?) but seeing the dramatic change I'd bet it's ridden with layers upon layers of abstraction, factories, and so on.

String IDs are a huge part of it. Old Minecraft used numeric IDs. Later, in 1.8 I believe, shortcuts were added, but they still just pointed to those numeric IDs.

In 1.13, everyone's least favourite version, the numeric IDs went away for the most part, replaced by stringId's which are by definition much slower.

Bad performance is a byproduct of "good code".

And, on a sidenote, the reason the LCE runs so well on such old hardware is partly because 4J didn't give a phick about good code.

In Java when they ran out of space in the texture atlas they removed it, implemented automatic atlas generation, and all that nonsense which only wastes CPU cycles and makes the thing slower.

4J just increased the size of the texture atlas. Yeah.

Old Minecraft had two classes. Iirc their names were Block and Item, and they stored the static instances of every single block and item in the game along with their IDs and such.

Modern Minecraft probably has registries instead of this. And yes, for mods it is a godsent, but not so for performance.

That's been some yapping about things most people don't care about, so sorry about that.

0 Upvotes

38 comments sorted by

36

u/helicophell Aug 05 '26

Good code > Fast code

The majority of Bedrock's problems comes from a decade of tech debt, since it's built upon MCPE
There's a reason it's called bugrock

Also, there's something called time complexity. ID's? Atlases? Imagine complaining about stuff that's O(n)

There's bigger fish to fry in terms of performance. Chunk loading and entities mainly

-15

u/gargamel1497 Developer Aug 05 '26

I agreen't.

Good code is bad as while it makes you feel good it's most often terribly slow.

Fast code taken to the extreme, in the meanwhile, is often completely unreadable and unmaintainable.

That's why a balance needs to be maintained, and that's what Notch's code did.

There were no factories, no unnecessary strings.

There were performance issues, of course, but it wasn't due to the "good code overhead" as there is now.

And while yes, chunk loading and entities are crucial, the rest is also important. Even with the most efficient rendering and worldgen mods I can still feel that modern Minecraft is just slower than old Minecraft.

4

u/helicophell Aug 05 '26

Said "unnecessary strings" make the game more comprehensible, debug-able and easier to extend

Just tell me you dislike OOP and be done with it

I've coded in Java before. I don't necessarily like the language much. I'm currently taking a course on code maintainability that utilizes Java 7 (25 years old)
Unmaintainable code is a nightmare. Because I've written it before

-4

u/gargamel1497 Developer Aug 05 '26

They absolutely do. But at the same time they are a performance nightmare. That's just what they are.

Especially on-the-fly-resizable garbage-collected strings languages like Java and C# provide. Character buffers in C are worse than integers, but they are still better than this GC-ed mess.

I don't dislike OOP. I might surprise you, but Objective-C is one of my favourite languages. I'd do a lot more stuff in it if its runtime was faster though...

Java 7 is not 25 years old. Java 7 was released in like 2011. 15 years ago. Or are you 25?

Unmaintainable code is indeed a nightmare as I recently witnessed myself, but so is overly good code.

I spent six months remaking an old mobile game for PCs. I used Java for that, and for the most part I followed Notch's principles of not going head on with all what abstraction can offer but in a few instances (including the aforementioned save system) I couldn't restrain myself and wrote gorgeous abominations.

And a while back I ran this game on a Pentium 4 computer which is eight years older than the computer I wrote the game on.

It runs like crap. I made some optimizations but the core cannot be changed without rewriting the whole thing from scratch which I'm not willing to do right now.

Good code is too good to be good.

3

u/helicophell Aug 05 '26

15 not 25, my bad, still a long time (and no stringbuilder or improved switch case). Pfft, funny you mention because I'm not even 25 yet

Still, using strings over ints isn't that big of a deal. You're using some 6-20x the clockcycles for an O(n) process

In a vacuum that's bad. In context where you have chunk loading happening, it's insignificant. Barely a factor

You know Minecraft would have much better chunk loading if Notch did it right. That's tech debt permanently scarring Java Minecraft's core. God's the issues early minecraft has carried onto today

I'm never building a game engine

2

u/[deleted] Aug 05 '26

[removed] — view removed comment

1

u/gargamel1497 Developer Aug 05 '26

People often blame Java and garbage collection but I dare disagree.

Survivalcraft, a game written in C# which is just Java made by Microslop, runs so much better than Minecraft Bedrock which is written in C++. On a budget phone from 2010.

20

u/tajoma9x Aug 05 '26

Notch's code absolutely did not balance readability with cleanliness 😭😭😭😭it is neither of those things

6

u/InternetUser1807 Aug 05 '26

I'm only intimately familiar with the source of 1.2.5 but "old Minecraft" absolutely had more than 2 classes. Wtf are you taking about?

A lot of this is very man-screams-at-cloud.

Numerical ids were unsustainable.

Automatic atlas generation allows for features that would be harder to implement without it.

As a C developer Minecraft has always had a lot of Java smell, but I mean, yeah, its Java.

-4

u/gargamel1497 Developer Aug 05 '26

Of course it had more. It's just a way of not writing an essay for every word I speak but apparently redditors are too smart to understand that, and it's not the first time I have to deal with this.

It had two such classes that contained all the block and item instances and IDs. That's what I meant, master redditor.

3

u/InternetUser1807 Aug 05 '26

That wasn't some reddit gatcha, your point was confusingly worded.

Yes it's true that very old versions had just one big array of static Blocks and Items.

Old versions were also a lot less complicated, and what blocks and items could do was a lot more limited.

21

u/lucasxi Aug 05 '26

This argument is not grounded in reality whatsoever.

20

u/Sad-Fix-7915 Aug 05 '26

Performance-wise, vanilla 26.2 absolutely shit the fuck out of 1.13, 1.7.10, heck even b1.7.3 and Bedrock edition (*since renderdragon) and that's without Vulkan. Unless you are running the game on say a Pentium 4 with a 5400rpm HDD...?

Modding-wise?

  • Numeric IDs are not sustainable. Back in 1.12, beds were block entities due to that exact reason.

  • Modern Minecraft is primarily data-driven. World generation, terrain features, villager trades, enchantments, loots and so on are defined via datapacks. They are way more convenient, easier to work with, much more extensible and not gonna lie the "performance hit" you are talking about is barely noticable (if it even exist)

  • Registry system is a godsend you can't convince me otherwise.

  • Atlas stitching is slow, yes, but with the addition of respack atlas definition that is mitigated somewhat.

  • DFU is also really good (albeit overengineered I'd say), and performance is no longer a problem as in latest updates.

You legit can't tell me static instances of block/item and whatnot are better than a full fledged extensible registry system, with per-item properties and component being dynamic and can be re-used anywhere.

Good maintainable code > fast non-sustainable code

2

u/gargamel1497 Developer Aug 05 '26

But I do get why they write overengineered code. It gives one a good feeling.

I felt really good having spent two days writing an automatic serialization system, even though it is highly dependent on internal class names and is much longer than just manually saving the values.

But this urge needs to be fought. In my current project I'm fighting the urge to overengineer things (and using C instead of Java helps with that tremendously) and so should the developers.

6

u/Thicc_Wallaby Aug 05 '26

You are talking out of your ass. Modern versions are not unplayable without performance mods. Lmao

3

u/electricpanda_ Aug 05 '26

1.20 fixed the performance issues, im pretty sure most of the lag past that is just because hardware

but otherwise i agree, 1.13-1.19 is awful without performance mods

2

u/TheMasterCaver Aug 05 '26

Funnily enough, somebody once compared various versions, including my own "fork" of 1.6.4, and fond that even with optimization mods 1.20 ran worse (FPS, world load time on creation, memory. I'll note that TMCW does not need 500 MB for 12 chunks, they probably used a modern GC which has a higher overhead):

Minecraft TMCW5 1.6.4 Mods (FPS 130-180 12 Chunks GC500)
2023-07-06 10:22:20 [SERVER] [INFO] Starting integrated minecraft server version 1.6.4
2023-07-06 10:22:25 [SERVER] [INFO] Raxelgrande joined the game

Minecraft 1.20 (FPS 30-60 GC1000 starts at 600MB it cycles about 3 times per 10 seconds)
[11:11:15] [Server thread/INFO]: Starting integrated minecraft server version 1.20.1
[11:11:50] [Server thread/INFO]: Raxelgrande joined the game

Minecraft 1.20 Personal Mods (FPS 80-120 GC1600 starts at 800 it cycles around 2 times per 10 seconds)
[11:16:47] [Server thread/INFO]: Starting integrated minecraft server version 1.20.1
[11:16:58] [Server thread/INFO]: Raxelgrande joined the game

https://drive.google.com/file/d/1ecjhOKS5qki9Ku8E2-ZtmHr28nvfJ5DX/view

Of course, vanilla 1.6.4 had significantly lower performance (no idea how, I had similar performance on a now 20 year old computer and get 400-500 FPS on Far on still decade old hardware, I still suspect something with their system since I do not see 900 MB of memory used, a screenshot, nor does allocating like 4 GB make it use more, example for TMCW, at 16 chunks):

Minecraft 1.6.4 (FPS 60-80 12 Chunks GC900)
2023-07-06 10:27:06 [SERVER] [INFO] Starting integrated minecraft server version 1.6.4
2023-07-06 10:27:11 [SERVER] [INFO] Raxelgrande joined the game

(there is always the caveat that actual performance on a given version will vary from system to system, I'd even seen people claim that e.g. 1.6 ran way worse/better than 1.5 back in the day despite very little actual changes between them)

Funnily enough, my coding methodologies are the exact opposite of Mojang's, e.g. I did what I called the "unflattening", merging many blocks by using metadata (4096 block variants even without adding support for 4096 block IDs, which is itself 65536 variants*). All that is needed is additional support for metadata-based properties, e.g. light levels (I can add a block that has 16 light levels in a single ID, as such blocks like furnaces, pumpkins, redstone lamps/torches were all merged; 16 variants of stone slab with the same hardness? Easy to fix, even with vanilla code as "getBlockHardness" already includes a world and coordinate parameters).

*Mojang was so concerned about running out of block IDs by 1.12 yet they wasted so many by not utilizing metadata more or even tile entities (e.g. shulker boxes could have simply stored their color in the already existing tile entity):

https://www.minecraftforum.net/forums/minecraft-java-edition/discussion/2880312-why-did-mojang-waste-so-many-block-ids-when-they

Wonder what this shows? A quarter-million (1089 chunks x 256 = 278784) "rainbow block" tile entities (full 24 bit color, only 65536 are used here, I did this to demonstrate that it is indeed practical to use that many tile entities, as long as they render as a standard block, i.e. the tile entity is simply used as "extended metadata"):

The reason why beds were so bad for performance is because Mojang decided to give them an entity model and render them as such, I use a standard block model with colored overlays so there are also only 10 textures in total (5 base/5 overlay, Mojang was using the equivalent of 16 textures per color):

MC-276855 Beds are far more expensive to render than most other blocks

(a comparison of the rendering performance of various blocks, chests are so bad because they render as an entity while barrels are indistinguishable from cobblestone despite using the same tile entity, I assume since I added barrels by reusing the chest tile entity with its "chestType" set to 2 and the double chest code disabled)

5

u/Gabriel55ita Aug 05 '26

Modern Minecraft runs better than older, what are you even talking about?

4

u/InternetUser1807 Aug 05 '26

Yeah, with the exception of 1.13's abysmal server performance that took a few updates to get back in line with 1.12, Minecraft hasn't really degraded in performance like OP is claiming

2

u/Superbob5523 Aug 05 '26

Performance has improved for me recently and can run perfectly well on my 3070 without mods. That being said Mojang is literally in the process of modernising rendering for vibrant visuals which will in turn improve performance. So this is definitely something being worked on

2

u/Pannoniae Aug 05 '26

it's pure facts though :)

1

u/Kurtisdede Aug 05 '26

I agree a bit, that making the game data driven has understandably ballooned the code size a lot, and the customizability we've got in return is I feel pretty underutilized in 2026 still. I don't agree that keeping atlases was the right move as it makes changing only a few textures harder etc - dynamically making the atlas is definitely the way to go.

Also two classes? Lol absolutely not. Sure, Block.java contained most of the blocks' basic data like hardness and light values, but there were tons of classes to add specific behavior to one block only like BlockBed.java and such. And do you think that it's a good thing to have less classes? Heck, why have classes at all, or seperate code into different files? Just have a million line main function, why not?

But "bad performance is a byproduct of good code" is in general really, really wrong lol

> The main class contained a lot more than it ideally should, but it's the fate of all Java codebases and there is no running away from it.

I really don't understand this point? What is it about Java that makes it so you have to bloat up the main class?

1

u/Zoegrace1 Aug 05 '26

I don't play those versions of minecraft though

0

u/Pedka2 Aug 05 '26

never stop cooking chief

-14

u/boringfantasy Aug 05 '26

It’s crazy AI can’t just optimise this. I use it 24/7 and it works amazingly for such cases. Does Mojang not use frontier models?

5

u/gargamel1497 Developer Aug 05 '26

I'd bet they use AI and that's another reason why modern Minecraft is so slow.

Enjoy your shitty profession, vibe coder.

0

u/boringfantasy Aug 05 '26

I’m not a vibe coder lol. I review AI code and so do my colleagues. It’s not GPT 3.5 anymore, stop burying your head in the sand.

5

u/gargamel1497 Developer Aug 05 '26

I don't use AI and I never will.

I actually want to be a good programmer and not a vibe coder. I want to be the author of my code.

The overengineered serialization code, even though it runs like ass, is something I'm rather proud of. Because I wrote it. I designed it. I implemented it.

Vibe coders don't get that feeling. Or if they do, it's fake. It's not their code that they are writing.

0

u/boringfantasy Aug 05 '26

Alright it’s your right! But in industry, it’s going to impact your productivity if you don’t use it and you may get subpar performance reviews. Most of us are just trying to get through the day. We still care about quality; but speed is incredibly important these days also.

3

u/gargamel1497 Developer Aug 05 '26

Yeah, you gotta type fast or your latest javascript framework will become outdated even before you fully switch to it lol.

2

u/boringfantasy Aug 05 '26

We work in C++ and Go mostly.

Most of us are just trying to make ends meet. We can’t all moral grandstand.

4

u/Kurtisdede Aug 05 '26

You have to keep in mind that you're probably talking to a teenager who doesn't know how the sector works.

1

u/boringfantasy Aug 05 '26

Yeah fair enough.

1

u/TheRetroWorkshop Texture Pack Artist Aug 06 '26

Yes, some of this is fine or even correct. But most of it is very anti-human and unstable, like the chatbots, and 'vibe code' being at the heart of Microsoft, and the WEF literally saying at Davos 2023 or so that '25% of jobs will be taken by A.I. in the near future' (many experts now actually claim that it's closer to 50%).

What I'm getting at here is, I don't find it useful to 'get through the day', unless you know there will be many more days in the future. Not saying that you shouldn't care about life, or become a criminal, just because your culture won't last for 10,000 years, or even 1,000 years. That's too great a timeline; and it's ideal to focus on each day, as opposed to taking a utopian, long-term approach. But that requires that you act RIGHT each day. 'Right' means 'stable' or, 'that which will lead to 10,000 years of history if repeated'. A.I. isn't that. 'Doing whatever my boss tells me just to get through the day' isn't that. 200 years is a reasonable number to keep in mind, when judging such things. If something feels like it's stable for 200 years, then it's likely reasonable and just. If it's clearly going to fail within 20 or 50 years, then it should be ruthlessly questioned, if not rejected and removed.

Famously, H.G. Wells once complained about the British educational system (circa 1900), because it was too slow to update to cutting-edge science, etc. He said that the system took about 30 years to properly update. But what the utopionist failed to realise is that (a) education isn't strictly for cutting-edge science, but also trades, and average citizens; and (b) rapid updating leads to a failure of the citizens to even be properly educated.

I think you can see this in action on the general scale, by looking at high schools today. Gen Alpha is a literal mess, unable to even walk right, talk, or spell. The UK government just went so far as to say, 'it's fine, you don't really need to know how to read and write... just become a construction worker, we'll get you there'. Won't unpack that (but one thing we might mention is how shockingly insulting that is to working class positions, and how stupid it is, to assume that bricklayers don't require some fundamental skills -- they do require a bit, if you want a well-made house, at least).

We're not talking about 90 IQ people who left high school at age 12, and became an amazing bridge builder. That's not how life works. Now, before you go on about how 'not all of Gen Alpha have 90 IQ, though'. Yes, I know. But the mean is 100, and the average is 95-109; and it's a non-trivial minority with a low IQ (about 20% have sub-83, for example). This isn't being solved by getting rid of jobs, children, marriage, religion, social clubs, and family ties. It's making it all much worse.

Some years ago, this infamously or famously led to the whole 'learn to code' Twitter thing. Because, that was their genius answer, speaking of coding. They wanted truck drivers with 95 IQ to learn to code, despite their inability and/or lack of fundamental interest. So, it naturally saw major backlash, where they were reminded that humans don't work like that.

Instead, what we're going to see over the next 50 years is the rise of a cyberpunk dystopia. In other words: the top 1% are going to be doing better than ever, and anybody with coding skills, 150 IQ, lots of money, etc. will have value and/or be able to adapt to any digital/virtual job and task. But the other 99% are going to start stacking up at the bottom, without education, work, meaning, money, or food. This will lead to crimes, riots, depression, lack of population, and general downfall. We're already seeing it according to the birth rates, depression rates, school reports, among other datasets. We are seeing lots of people 'coding' or doing other things thanks to A.I. But this itself isn't stable. This is why the A.I. bubble will burst sooner or later, and why there will be profound fallout. Everybody doing 'jobs' via A.I. isn't stable, for a few reasons. That's why Gen Z are the worst workers in history (according to the data and results), and Gen Alpha is set to be worse still. A.I. isn't helping many people, or culture more broadly.

Japan just admitted that it's facing a population crisis, for example, and hasn't yet figured out exactly how they want to meet the next century. But they at least now know that they have a real problem. A.I., virtual reality, social media, gambling, games, etc. isn't magically fixing it. They're going to hit all-time low population by 2080, if not sooner. After that, if the population doesn't climb above replacement rate, it's just maths. They'll wipe themselves out by 2100-2150, no matter what. A.I. doesn't help you become a parent, doesn't foster the next generation, doesn't solve any of that (at least, not directly -- and I don't see strong evidence for any indirect fostering, either).

The world leaders know this. They're trying to find ways to 'solve it' or correct it, or somehow bypass it. Global birth rate is towards 1, now. About 8 billion people. So, over two generations (2076), it'll crash to roughly 2.5 billion; an earth-shattering loss of ~6 billion. That's the greatest mass murder/death toll in human history, and it's not even close. Almost nothing as ever been so deadly before, other than abortion itself, every war, and cancer/other general forms of death that are pretty much unavoidable. Even still, you don't get 6 billion from any of those single sources; you have to combine them.

I'm not saying A.I. caused this (rather, the birth rate problem pre-dates modern A.I.), only that it's not only not helping, but is actively making it worse, and faster.

1

u/umotex12 Aug 05 '26

Yeah you can don’t like ai like me but saying it can’t be used to code in 2026 is just disinformation

1

u/TheRetroWorkshop Texture Pack Artist Aug 06 '26

I assume he means, 'it often makes bad code' or 'is an unstable way of making code', as opposed to, 'it's impossible for any A.I. to make any kind of code'. I mean, A.I. has been doing remarkable things since whenever Magnus used it for Chess and Microsoft switched their business goals (circa 2017). Almost 10 years. And since 2021 (more so, 2024), there have been major breakthroughs, and it's taken over almost every area of life. For example, 2025 was the biggest year for A.I. replacing human jobs/removing human workers. Millions still out of work, now. And this is only the beginning. WEF said at Davos 2023 or so that A.I. will 'take 25% of human jobs' -- but most experts have since claimed that this is shaping up to be closer to 50%.

No idea when modern 'work' was invented, but most people say with the British Empire's industrial revolution circa 1750. Before the U.S. even existed. 300 years will be lost, and utterly reshaped. And it's going to make the 1700s and 1800s look like a joke, so this is more important than indicated.

Hence, Klaus of WEF literally wrote a book called The Fourth Industrial Revolution.

It's not helped by the weird sub-set of people who actively want A.I. to replace humans more directly (i.e. a future without humans). In this case, it's the worst possible vision, and never existed before, in any system. Every system had humans, no matter what the system was -- every group wanted humans. This is the first time, we're not only seeing a shift unlike almost any other in the last 8,000 years, but we're seeing a faction on the side of the death of humanity. And that rather proves the point. Transhumanism to the point of total nihilism.

Now, I'm not saying they're going to win. I have hope. At least, I plan to fight against it, even if it's impossible for me to win: this is the Tolkienian form of bravery (though it may even be the modern British form, since it predates Tolkien, and is evidently nested within Catholicism) -- to fight on, even when you truly believe victory is impossible. This is Sam (if you've seen/read LOTR). (I can also assume that this pre-dates Catholics, or at least exists elsewhere in the world. It's just not supremely common.) But I digress.

Down with A.I.