Skip to content(if available)orjump to list(if available)

Browsercraft: Java Minecraft in the browser

waveringana

When I was in fourth grade, I'd take the half a mile walk to the library almost daily which always made my parents happy because they assumed I was going to read, but instead I was hopping onto their computers, going to http://minecraft.net, and playing minecraft on IE :)

Thanks for the nostalgia

afavour

The longevity of Minecraft blows my mind. I was always aware of its existence but never looked into it. Now my kid is getting into it. So many generations of kids! It's incredible really.

That said, it has been a little sad digging into the current state of Java vs Bedrock, Bedrock iPad vs Bedrock Switch. The platform ubiquity is wonderful and the tradeoffs are what they are. But if folks were able to create a touch-capable web-powered Java Minecraft that would be a great fit for the iPad.

ClikeX

It's basically LEGO, it tickles the mind. Which is ironic, because LEGO Worlds isn't nearly as inspiring as Minecraft.

naikrovek

The children yearn for the mines, apparently.

eddd-ddde

Also, Minecraft is like a gateway drug into Factorio. Dangerous stuff!

immibis

An interesting fact about Minecraft is that when it came out, storing the block IDs for the loaded area used up a big chunk of your computer's RAM and had to be optimized as much as possible. So it was 8 bits per block space, and when they expanded to 12 bits, they added on another array with 8 bits per 2 spaces.

Now, it doesn't even use block IDs any more. It uses one whole object per block type, one pointer to one of those objects per block space, and has a lot more block types. The on-disk format stores the entire string name of the block, once per 16x16x16 region it occurs in.

momojo

Got any resources on this? As a kid I never thought about it but as a programmer, I always wondered how you scaled up these kind of problems.

porphyra

I used to do that except it was to play Runescape lol. The local library got some really nice Pentium 4 computers too.

null

[deleted]

nullbyte

Funny enough, the original version of minecraft used to run in the browser too! It used Java applets. That was a long time ago, I remember playing it as a kid

neuroelectron

Yes that's how notch was able to distribute it while circumventing publishers. Very smart move at the time.

diggan

Java Applets weren't some magical "workaround" for distributing without publishers, lots (well, subjective) of indie developers were distributing binaries via websites at the point of the first alphas of Minecraft. Of course, way more popular nowadays as there are dedicated platforms for it.

8note

the initial scope of minecraft was also in line with the java applet games of ~2005, like the ski simulator. minecraft came well after the applet era, almost to the end of the flash.

huh. Minecraft is the taylor swift of video games. the last big star before big tech took over discovery and access for an industry.

schindlabua

I got into Minecraft via 4chan, of all places. People used to make posts about it and how cool it was and others would naturally talk crap about the game.

gavinray

5 years ago, I watched a YouTube recording of a meetup talk given by one of the CheerpX engineers:

https://www.youtube.com/watch?v=7JUs4c99-mo

In it, they showed a functional demo of porting an OSS multiplayer C++ game entirely to the browser with WASM.

Afterwards, I read some of their engineering content and was blown away.

It's been fascinating to watch the CheerpX/CheerpJ progress from afar over the years.

apignotti

Thanks for your kind words, appreciated.

Link to our blog, we try to regularly publish high quality content: https://labs.leaningtech.com/blog

apignotti

Hi everybody, happy to see our CheerpJ demo is appreciated.

CheerpJ is a WebAssembly-based JVM that can run unmodified Java 8 and Java 11 applications. Java 17 will be supported later in year.

I am the lead developer of CheerpJ and CTO of Leaning Technologies. AMA.

skrebbel

Cool stuff!

Hey I saw a typo on https://cheerpj.com/cheerpj-core-licenses/, it says "liencesees" halfway the page

apignotti

Thanks for spotting this, we'll get it fixed ASAP

henrycrutcher

How much is the licensing for a small company wanting external users to use it to use an app hosted online?

apignotti

Small Business licenses will be available with the release of CheerpJ 4.0, expected in mid April 2025.

They will allow self-hosting and will be priced on a per application / per website basis. They will be priced to be affordable and ensure that CheerpJ enjoys a wide reach.

If you are interested before the release, please do get in touch (info@leaningtech.com).

geokon

Would it work for a JavaFX app? (not sure I'd be able to shrink the bundle size enough for it to make sense though)

apignotti

JavaFX is not yet supported, but we plan to get it to work soon.

The issue here is that there is very little Java in JavaFX, it's mostly native C++ code. This makes it actually quite similar to the LWJGL library used by Minecraft.

Our plan is to use for JavaFX the same technology we have developed for LWJGL.

geokon

thanks! that's kinda what I figured. And now it's not part of Java's "core" so it'd make sense if it was "out of scope"

AlphaWeaver

Another comment mentions MinecraftForFree.com...

In middle school, in an attempt to get around the school firewall, I copied the HTML code from that website to my own to play Minecraft at school. Since my domain wasn't on the blocklist, it worked! But when my friends started using it to play, even after they hadn't bought the game, I resolved to add a login wall.

I built a backend proxy in PHP that would POST their credentials to the Minecraft API to make sure they had purchased the game. I still think it's funny to think I had no ethical qualms about circumventing the school firewall, but piracy was where I drew the line.

SunkBellySamuel

This is the main way I used to play Minecraft in the Beta days, thanks!

spicybright

There's a very funny story behind MinecraftForFree.com which is what most people used back then.

Notch (the creator of minecraft) was angry someone was posting his game online for free. He emailed the owner, Dylan, of the site threatening legal action.

Instead of going down a legal route, Dylan challenged him play a game of quake3 to settle the dispute.

If notch won, Dylan would take the site down. If Dylan won, notch would would leave him alone and let him keep hosting the site.

Notch agreed, won the match, and Dylan followed the promise and took it down forever!

awkwardpotato

> If Dylan won, notch would would leave him alone and let him keep hosting the site.

Small correction, Dylan always planned to take the site down. They were playing for Minecraft capes[0] for him and his two teammates. The original livestream of the match is still up on Twitch also.[1]

[0] Cosmetics that used to be very rare and only given out by devs or at MineCon

[1] https://twitch.tv/videos/38469359

mzajc

There are even recordings of their match (in two parts), they're quite funny: https://www.youtube.com/watch?v=g_Fu0SZ7PN8

lxgr

Wow, same here, but I somehow completely forgot about that!

OsrsNeedsf2P

The fact I'm playing this at 20 FPS on Firefox with a RX 7600 shows how much web browsers have regressed in 10 years, not how much they've advanced.

zimpenfish

> The fact I'm playing this at 20 FPS on Firefox with a RX 7600

Vanilla Minecraft is known for being awful for FPS even outside of a browser. There's a reason most people use a whole slate of performance mods just to get actual decent performance.

(I've got a Ryzen 7 with a 3080 and it would frequently hover between 40-50fps even with graphics turned down. Install the performance mods and I can get >120fps with fancy graphics and shaders.)

InMice

A longstanding performance effecting bug was fixed in the recently released 1.21.5 and the difference is night and day at least for vanilla clients.

This one: https://bugs.mojang.com/browse/MC/issues/MC-170134

I now never see below 60 fps when for all my years of playing this bug would bring down my FPS to the teens or 0 all the time no matter what hardware.

zimpenfish

> A longstanding performance effecting bug was fixed in the recently released 1.21.5

Good to know that they're finally considering performance fixes but obviously involves moving to 1.21.5 and until there's mods to disable the bits I don't like, I'll be sticking with 1.20+mods.

piperswe

Minecraft back in the day was a Java applet, so the game was running in a native JVM. This demo is running the game in a WebAssembly JVM, so performance is absolutely going to suffer. If the game were actually written for the web platform, it would perform significantly better.

singularity2001

well Wasm had the promise of giving near native speed, but since they still don't offer direct write/share of memory it results in abysmal FPS.

kulahan

This is a 20-ish year old game. It really shouldn’t matter.

null

[deleted]

Ralo

This implementation isn't using webworkers either. Moving the java VM to a webworker would likely improve performance 10 fold.

TeeMassive

It's basically java -> wasm/webgl -> your computer

A 10 times hit compared to a native C implementation on performance doesn't really matter anymore, but a compounded 10x10 times will.

Rohansi

I get similar performance in Chrome on my phone (Pixel 7a). Perhaps this just runs poorly in Firefox?

ConfusedDog

I used to love Minecraft as a kid until my kid ruined it for me. This 5-year-old loves to be in Creative mode and put me in Survival mode and set up traps and rounds of enemies for me to fight my way out. Not relaxing at all anymore.

doubled112

My 7 year old's favourite activity in Minecraft is to blow stuff up. I don't know whether to be concerned or not, but at least we've convinced him that it's really not cool to blow other people's stuff up.

Like you say, not very relaxing.

kulahan

Send that child to the demolition career. There’s good money in blowing up buildings!

doubled112

Exactly! There is a demand for constructive deconstruction.

Consent is everything?

pfoof

The craziest part is that it executes on my iPhone SE 2020 in Safari. Textures work, shading works, pretty insane. I even managed to break a block.

apignotti

Mobile is indeed supported, although the performance is not yet as nice as we would like.

The trickiest issue is input, since the "look around with your mouse" interaction maps very poorly on a mobile platform where "mousemove" implies touching / clicking.

We plan to eventually figure out a mobile-optimize UX, but we will most likely prioritize improving the performance first.

Jotalea

There's also Eaglercraft, which achieves the same result, but it has functioning multiplayer, and runs up to version 1.8.9, though you'll need a beefy computer.

satoshinm

This looks amazing! Both Eaglercraft and Browsercraft (though Eaglercraft seems to be further along) — the closest realization to the dream I've had for years of running a fully-featured Minecraft in the browser. Quite promising, I can only wonder where these projects will end up as they develop further, wishing for the best...!

Why is this so exciting to me? I started playing Minecraft back in the Java modding days, which really picked up steam around 1.2.5 and, by my estimations, peaked around 1.7.10. There was a veritable cornucopia of mods widely available, to enhance the game in a plethora of ways. I modded my game so hard I undoubtedly ran more third-party code than first-party/Mojang. Minecraft was a platform for creative expression, freeform and unconstrained. The golden age of Minecraft modding!

But it wasn't all unicorns and rainbows. There was a dark side of modding: the ease of use, or lack thereof in getting mods setup. Modpacks helped, but you still had to run untrusted code, and you still had to have a compatible PC. This is what (nearly) killed Minecraft for me. I wanted to play with my friend, but his PC had Windows upgraded and lost Java or OpenGL compatibility, and he eventually dropped his desktop and switched to tablets, phones, and consoles. My highly curated developed modded technical world became inaccessible.

Contrast this unfortunate situation with the browser: with "load and go" functionality as Douglas Crockford calls it, you can just visit a website and play, provided sufficient specs. What if we could play modded Minecraft (preferably 1.7.10), with all the mods to our hearts content, right in the browser, accessible to anyone?! And anyone could develop and distribute their own mods without concern, being safely executed within the browser sandbox.

I don't know how close Eaglercraft is to this utopia, but I find the possibility very enticing.

TeaVMFan

+1 for Eaglercraft. It's based on the open source TeaVM project ( https://teavm.org/ ), which transpiles Java to JS or WASM to run efficiently in modern browsers. With numerous shipped production Java-in-the-browser projects, TeaVM is my preferred option for Java in the browser thanks to its performance, build speed, and Apache license.

pidgeon_lover

Is this at all related to Eaglercraft (web: https://eaglercraft.com/, src: https://git.eaglercraft.rip/eaglercraft), which is also browser-based Minecraft?

apignotti

No, this is the unmodified Minecraft JAR running on top of CheerpJ, a WebAssembly-based JVM.

burgerone

There's a similar but "illegal" other client called eaglercraft. It bumps this up a notch with a much more "recent" version of MC, by compiling java to javascript