Playing Minecraft with MultiMC without installing Java on Windows

One of the most frustrating aspect about installing Java to play Minecraft is that the installer would try to integrate Java onto Windows. It would come with a control panel applet, a web browser integration, an annoying updater, and worse of all: a toolbar ads on the installer itself, all of which is not necessary to play Minecraft at all!

Thankfully, Mojang have bundled Java runtime onto the official Minecraft launcher. And for a lot of people it will do. For me however the bundled runtime is simply too out of date, a lot of mods will display warning about bugs specific to the earlier versions.

Finally, the idea of installing the official Minecraft launcher just to use it’s bundled runtime with MultiMC just seems strange to me.

What used to work

In the past, simply extracting the offline installer from Java.com will net you a working Java installation. That is no longer the case, I don’t know why but something seems to change in the installation process.

Another thing that used to work flawlessly is obtaining the jre (or jdk) from the Oracle JDK download page in the zip or tar.gz format. Like the installer method above, extracting the archive will net you a working jre installation. This actually still works, but for Java 8 due to licensing change on Oracle side an Oracle account are now required for Java 8 download. I may have a Oracle account myself, but the steps for obtaining the download has become so convoluted and the experience so shitty that I just don’t bother anymore.

So how do I obtain the Java runtime?

There are two main source of Java binary that I frequent. The first is the official openjdk website, they have binary in zip format ready to go in the same vein as the Oracle download page above (the website is run by Oracle in fact). For this guide/blog post we’ll use AdoptOpenJDK instead as the has the following advantage over the official JDK website:

  • The official website does not offer binary for Java 8
  • The official website also does not offer JRE

Why Java 8?

You may have notice that I mentioned about getting java 8 even though the latest version of Java is 12. There is 3 reason for Minecraft players to use Java 8 instead of the newer one:

  • Forge simply is incompatible with newer Java versions
  • Mojang compile and test Minecraft rigorously on Java 8, while they do make sure that Minecraft runs on newer Java version 8 is the first-class citizen

For me personally, I choose Java version based on these criteria

  • Mods: Java 8
  • Vanilla with the latest performance enhancement Java has to offer: Latest
  • No fuss: Java 8

Obtaining OpenJDK zip file

The AdoptOpenJDK website is very easy to use. You’ll want to do the following:

  1. Go to the release page and select the Java version that you want
  2. Select the hotspot JVM
  3. Select the platform that your want (probably Windows x64)
  4. Select either the JRE and the JDK. You’ll want to make sure that you’re getting a zip and not the msi file.
A normal Minecraft player will only need the JRE

JRE vs JDK

A JRE is smaller than a JDK. This makes it desirable for Minecraft player who did not wish to waste bandwidth and disk space on unnecessary development tools that they do not use (which is most Minecraft player).

Using the downloaded file

First, you’ll want to extract the content of the zip file. The destination can be anywhere you like.

I personally like to extract the zip content directly into the MultiMC folder

Then, configure MultiMC to use the javaw.exe inside the extracted folder

Locating javaw.exe
MultiMC configured with the Java that we just download.

Testing

Try opening Minecraft and see if it’ll run, to be extra sure that we’re running the Java that we just downloaded, press F3 in game to see which version of Java it is running on, it should match what we just downloaded.

The Java version is 12.0.2 64bit, the same one that was downloaded.

Using ASP.NET Core Scaffolding with MongoDB

I recently want to create a CRUD web application, because I don’t want nothing special .NET Core scaffolding feature seems like a great choice. Unfortunately there’s no easy way to use it with the MongoDB’s driver.

That however doesn’t mean that I can’t use Scaffolding at all as it turns out, I only have to modify the generate code a to get the Scaffolding page to work with the MongoDB driver. It require work sure, but its better than writing the entire thing from scratch.

How to use scaffolding with MongoDB

Our little project example will be based on this MongoDB API example. Unlike the docs however we will not be building an API and instead will build a standard CRUD web application. For this little project I’ll use Visual Studio 2017, you could also follow this little guide with VS 2019 or the dotnet command line application if you want. Anyway let’s get started…

1. Setting up the project

We’ll first be creating a ASP.NET Core 2.2 Web App with Razor named “MongoBookStore”.

When our project is ready, we’ll install the MongoDB driver via NuGet.

2. Create our Model

First, create a folder named “Models”. Then, inside our new folder create a new file named “Book.cs” and paste in the following code

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace MongoBookStore.Models
{
    public class Book
    {
        [BsonId]
        [BsonRepresentation(BsonType.ObjectId)]
        public string Id { get; set; }

        [BsonElement("Name")]
        public string BookName { get; set; }

        [BsonElement("Price")]
        public decimal Price { get; set; }

        [BsonElement("Category")]
        public string Category { get; set; }

        [BsonElement("Author")]
        public string Author { get; set; }
    }
}

Our project structure should now look like this:

An opened Book.cs file inside the Models folder

3. Use Scaffolding to generate CRUD pages

Now here comes the fun part, we are going to use Scaffolding to generate CRUD page and then once done, we will change the Code Behind to use the MongoDB Driver instead of Entity Framework Core.

First of, we’ll create a folder named “BookStorePage” inside the folder named “Page”

Then, right click on the newly created folder –> Add –> New Scaffolded Item…

In the add razor pages, select Book as a model class and create a new data context class.

Once you press “Add” wait a bit and you should have your new CRUD page.

4. Switching from Entity Framework Core to MongoDB Driver

Next we will replace the entity framework context and database access code with MongoDB ones.

The files that you’ll modify are:

  1. MongoBookStoreContext.cs
  2. Create.cshtml.cs
  3. Delete.cshtml.cs
  4. Details.cshtml.cs
  5. Edit.cshtml.cs
  6. Index.cshtml.cs
  7. Startup.cs

For MongoBookStoreContext.cs, replace the entire files content with the following:

using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
using System.Security.Authentication;

namespace MongoBookStore.Models
{
    public class MongoBookStoreContext
    {
        public MongoBookStoreContext(IConfiguration configuration)
        {
            // Connect to the Mongo database and obtain reference to Book collection
            MongoClientSettings settings = MongoClientSettings.FromUrl(
                new MongoUrl(configuration.GetConnectionString("MongoBookStoreContext"))
            );
            settings.SslSettings =
                new SslSettings() { EnabledSslProtocols = SslProtocols.Tls12 };
            var mongoClient = new MongoClient(settings);
            var database = mongoClient.GetDatabase("BookstoreDb");
            Book = database.GetCollection<Book>("Books");
        }

        // Readonly IMongoCollection, our equivalent to DbSet
        public IMongoCollection<Book> Book { get; }
    }
}

For each of the other files do the following:

// Add this using statement
using MongoDB.Driver;

// Replace this (Create.cshtml.cs)
_context.Book.Add(Book);
await _context.Book.SaveChangesAsync();
// With this
await _context.Book.InsertOneAsync(Book);

// Replace this
await _context.Book.FirstOrDefaultAsync(m => m.Id == id);
// With this
Book = await (await _context.Book.FindAsync(m => m.Id == id)).FirstOrDefaultAsync();

// Replace this (Delete.cshtml.cs)
Book = await _context.Book.FirstOrDefaultAsync(m => m.Id == id);
if (Book != null) {
   _context.Book.Remove(Book);
   _context.Book.SaveChangesAsync();
}
// With this
await _context.Book.FindOneAndDeleteAsync(m => m.Id == id);

// Replace this (Edit.cshtml.cs)
_context.Attach(Book).State = EntityState.Modified;
try
{
    await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
    if (!BookExists(Book.Id))
    {
        return NotFound();
    }
    else
    {
        throw;
    }
}
// With this
await _context.Book.ReplaceOneAsync(m => m.Id == Book.Id, Book);

// Replace this
return _context.Book.Any(e => e.Id == id);
// With this
return _context.Book.Find(e => e.Id == id).Any();

// Replace this
Book = await _context.Book.ToListAsync();
//With this
Book = await(await _context.Book.FindAsync(m => true)).ToListAsync();

// Replace this (startup.cs)
services.AddDbContext<MongoBookStoreContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("MongoBookStoreContext")));

// With this
services.AddScoped<MongoBookStoreContext>();

Adding Connection String to project’s secret

If you’re been developing application that requires storage of sensitive information then you’ll know that hard coding things like username and password is not a good idea, which is why we’re adding our connection string to our project’s secret instead of putting it in our code directly.

First off, let’s clean off the old connection string generated by the scaffolding tool, open appsettings.json and delete the “ConnectionStrings” and its value from the file.

Then, taking a look at our code in MongoBookStoreContext.cs you’ll notice immediately notice the code that connect to the MongoDB database

// Connect to the Mongo database and obtain reference to Book collection
var client = new MongoClient(configuration.GetConnectionString("MongoBookStoreContext"));
var database = client.GetDatabase("BookstoreDb");

Quite a few thing is happening here. First off, configuration.GetConnectionString(“MongoBookStoreContext”) is a shorthand for GetSection(“ConnectionStrings”)[“MongoBookStoreContext”] which in itself will try to read the following key: “ConnectionStrings:MongoBookStoreContext”.

Let’s add our connection string. Right-click on our project and select “Manage user secret” a file named “secrets.json” will open.

Opening secrets.json

As explained above, our code will read from “ConnectionStrings:MongoBookStoreContext” so create a new entry with that as the key and your actual connection string URI as the value. If you don’t know what your connection string URI is then consult this MongoDB document.

In a production system, you’ll need to insert the same key and value except as an environment variable.

Making our new CRUD page accessible.

There are endless way of doing this. But I’ll just go for the quick and dirty way: redirecting our home page to our new CRUD page.

Go to the file Index.cshtml and OnGet() method with the following:

public ActionResult OnGet()
{
    return Redirect("/BookStorePage/Index");
}

Testing our new CRUD page out

Go ahead and press the “IIS Express” button to launch our new website. Once our website is loaded you should be on the Index page of our new set of CRUD pages. Go ahead and play around, our job is done.

Wrapping Things up

We may have to do some work, but our shiny new CRUD page works pretty much as well as the one generated for standard SQL without modification. I hope you’ll find this guide useful. Thanks for reading.

This finish solution is available on Github.

Working around disabled WiFi Adapter with Android and turning it on with Windows Update

So there is this funny thing about the computers at my university college: they’re crippled. In fact, they were crippled both intentionally and unintentionally by university staffs.

So in what way are they crippled you may ask? The answer is that they were prevented from accessing the internet. This actually makes sense because the university staff obviously do not want the student to go on the internet and cheat during lab exams. This makes even more sense when the fact that they turned it off just before examination were taken into consideration.

Internet is inaccessible
The WiFi adapter is disabled and the average student do not have admin access

There is just one tiny problem: they do not bother to turn it back on! So now pretty much every lab computer are unable to access the internet regardless of whether there is a lab test going on or not.

Thankfully there is an workaround if you own an Android phone. You may have already know that one of standard features of Android is the ability to tether your mobile internet to your computer via USB, but that is not all! It can also tether WiFi to your computer.

Let’s connect this computer to the internet

To tether WiFi to your computer, simply connect to your phone to the computer via USB and make sure that your phone is connected to WiFi (you might want to turn off mobile internet to make sure that you really are using WiFi). Once everything is connected simply turn on the option to tether via USB.

Note: I’m using MIUI on Pocophone F1, that being said this should work on other android phones too

Once everything is in place then you should be able to access the internet now. Your phone now acts as a WiFi adapter for the PC.

Finally connected!

But wait, there’s more!!

There is in fact a way to turn on the WiFi without admin access, however to do this we required three things

  1. An internet connection (hence the Android trick)
  2. An outdated copies of Windows 10 (with respect to feature updates)
  3. A Windows Update that has not been set up with policies preventing feature updates or blocked

These university computer happens to met criteria two and three (They run Windows 10 version 1803 and were not even joined to a domain), this combined with the Android trick earlier meant that it qualifies.

Let’s … update Windows ?!?

With everything in place, simply open the setting app, go to Windows Update and check for update. You’ll want to take the feature update (not like you have a choice anyway).

Hello darkness my old friend

When everything is done and the computer restarted, you’ll notice that the WiFi adapter is now back on without you needing to type any admin password!

Fun fact: I actually forgot to take this screenshot on the day that I write this blog post and have to go back to the lab for the screenshot

TL;DR, Ajarn plz turn on WiFi adapter after test.

Enabling PopCap old game’s 3D acceleration on newer computers

Update: Before trying this guide I recommend you to try out executable patches by GitHub user cheez3d first. Try this one out if your game is not in the repository or the patch doesn’t work.

If you have a newer computer and are feeling nostalgic then there shouldn’t be any problem with install old PopCap games and playing it right? After all those games are still available on steam, origin, and a number of online game storefront.

As it turns out there is: 3D acceleration doesn’t work

The message that you will get for every old PopCap games ever if you’re unlucky
For Bejeweled 3, not only does 3D acceleration cannot be enabled but the graphics glitched out at certain part too

It should be noted that not everyone will experience this. I have personally experience with with my AMD Radeon R9 200 Series graphics card, but my friend who has a GeForce GTX 1060 card despite being newer, does not experience this. Furthermore, my Surface Pro 4 which has a Intel integrated graphic used to not experience this until Windows Update update the driver.

The fix

As it turns out I’m not the only one with the problem, this steam community thread detail the fix for bejeweled 3. However following its instruction blindly just cause my game to crash (I am also not sure that the Windows 8+ and resolution explanation holds up as my Surface Pro despite having resolution higher than 1600×1024 still have this problem, and my old computer despite running Windows 10 and not meeting the resolution doesn’t have this problem). After much trial and error I finally found the proper fix for the problem.

As it turns out there is two fixes, one for games that are really old, and another for games that are newer. Unfortunately I don’t know where exactly the line are drawn (seems to be “before bejeweled 3” and “bejeweled 3 and after” to me) so I suggest reader follows “Fix for really old games” first, before trying “Fix for newer games”.

OK enough background, grab the latest WineD3D for Windows here and follow one of the instructions below.

Fix for really old games

First off, make sure that the game in question is opened at least once so that the necessary folders were created first. As an example I will apply the fix to “Plant Vs Zombies“.

Navigate to C:\ProgramData (the folder is hidden, just type it into Windows Explorer address bar). There should be a folder named “PopCap Games”, if there is no such folder then go to “Fix for newer games”. Enter that folder, there should be a folder named after the game that you want to apply the fix (again, no folder = “Fix for newer games”). Entering that folder should reveal that it is a blank folder.

A “PopCap Games” folder inside “C:\ProgramData”
Inside the “PopCap Games” folder contain folder(s) named after the games that is applicable for the fix
A blank “PlantVsZombies” folder

What you want to do then is copy the following files from the downloaded zip archive to the opened folder:

  • d3d9.dll
  • ddraw.dll
  • dxgl.dll
  • libwine.dll
  • wined3d.dll

And you’re done. Repeat these steps for every games that you want to apply the fix.

Fix for newer games

I only owned one such game that is applicable to this fix: “Bejeweled 3“

Unlike the previous fix, instead of copying the files to “ProgramData\PopCap Games\<Game>” folder, we instead copy the files directly to the game folders.

Different storefront installs the game into different locations so you’re to find the game files location on your own. I can only give you instruction if you use steam (since that what I use).

If you install the game via steam then you can access the game files by right clicking the game title -> Properties -> Local Files -> Browse Local Files.

Accessing the game folder if you’re install the game via steam

Like the previous fix we can apply the fix by copy the previously mentioned 5 files into the game folder

The 5 files that you need to copy
Done

Warping it Up

Applying one of those 2 fixes should allow every old PopCap games to work with newer computer, keyword being “should”. I can’t test this for every PopCap games or every computer configuration so you might experience some problems that I do not have. If you do then I suggest you try the following:

Anyway I hope that this guide helps you as much as it helps me. Now if you’ll excuse me I’ll go back to playing Bejeweled Poker.

Getting Hyper-V networking to work with ReactOS (How to)

Background

Hyper-V, unlike its more popular VirtualBox or VMWare, does not have a terribly good support for non-mainstream OSes. Thus, it came as no surprise that guest ReactOS support is not very good either. Networking in particular does not work at all. After digging through the internet for solution I only found bits and pieces of information which eventually are enough to get networking to work. However there’s still no convenient how-to for those who just want the networking to work, as a result I decided to create one.

Credit

I would like to thank Pi_User5 for pointing out the correct Hyper-V legacy adapter driver that was needed. The post in question can be found here.

Required Driver Files

As per the linked post, the driver can be download from here. The files that you want are in int_v505.zip\i386\WNT50.

I also repackaged the driver files into an ISO file which can be inserted into the VM. It can be downloaded from here.

Setting up networking

VM Setup

When setting up the Virtual Machine you’ll want to left the network configuration alone (If you already set up your virtual machine then no worries, just follow the next step).

mmc_2018-08-02_13-59-57_cropped.png

Change network adapter to legacy network adapter

Video of the process

Select the network adapter and press the “remove” button

2018-08-02_15-33-57.png

In the “Add Hardware” section, select “Legacy Network Adapter” and then press “Add”

2018-08-02_15-34-38.png

Select the newly created Legacy Network Adapter and choose the Virtual switch that you want to use.

2018-08-02_15-23-31.png

Install the driver

After installing ReactOS, a new hardware wizard should pop up, cancel until it ask to install driver for “Ethernet controller”. Even if it was not a fresh install of ReactOS, the wizard should still popped up.

2018-08-02_14-20-24

Choose “Install driver from specific location” and in the next screen, navigate to the driver files (If you choose to mount the iso then there’s a very good chance that the location is in D:\).

vmconnect_2018-08-02_14-21-42.png

When you press next, the driver should be successfully installed, restart the VM and enjoy internet connection.

Conclusion

At the end of the day its all about the driver, unfortunately the driver installer in ReactOS leave a lot to be desired. Anyway, I hope you found this guide helpful, thanks for reading.

Trying to apply patch(es) for enterprise to other Windows 10 edition

I have a friend who run Windows 10 Anniversary Update on his computer and refused to upgrade to newer version of Windows 10 due to a simple reason of laziness and the “if it ain’t broke don’t fix it” mentality. However support for this version of Windows will end in only 10 days from the day this article is written. As a result I decided to experiment a bit to see if it’s possible to install updates Microsoft issues for its enterprise customer into unsupported Windows installation.

Before we start however, I would like clarify that this article is a the record of my experiment . I only want to know if it’s possible, so as a result I won’t be digging too keep or trying many configuration.

Wait!, update?, upgrade?

You may have noticed that I’ve used the world update and upgrade distinctively, that is because in the Microsoft Windows world, while these two words has similar meaning, there are some very important difference.

Update

When I say update I refer to the patches that were delivered though Windows Update which was not labeled as a ‘Feature update’. Microsoft typically issue these every Patch Tuesday. These updates are usually bug-fixes and does not change the version of Windows (If the computer is running Windows 10 Anniversary Update it will stay that way). They are also typically smaller than a upgrade. While many types of update exists we will only be focusing on cumulative updates.

Upgrade

The other side of the coin, an upgrade is referred to by Windows Update as a ‘Feature update’ (for example, an upgrade to an upcoming version of Windows 10 is referred to as ‘Feature update for Windows 10, version 1803’). An upgrade is essentially changing an installation of Windows from one version to another (i.e. Anniversary Update to Fall Creators Update) and the version number to change accordingly (i.e. 1607 to 1709).

The versions of Windows 10

There are many ways to refer to a version of Windows 10, previously in this article you have seen me referred to them using both marketing names (Fall Creators Update) and the 4-digit version numbers (1709). Alongside those two you can also refer to them using internal codenames (Redstone 3) and build number (16299.309). Build number is a little bit trickier than the rest as unlike the other three both upgrade and update change this number (only upgrade change the other 3). A build number has two parts separated by a decimal separator, the whole number part(16299) and the decimal part (309). An upgrade change both, while an update only increment the decimal.

The experiment

Now that we got the definitions out of the way. Let get started on the experiment themselves.

Getting Started

To prepare for the experiment I first need to choose the version of Windows which is supported for enterprise and education customer yet unsupported for everyone else. Currently, only Windows 10 1511 fit the bill so that’s what I will use. Installing the latest iso into the virtual machine gave us the build number of 10586.164. The edition in this case is Core Single Language.

vmplayer_2018-03-29_16-26-32

Once the virtual machine is good to go. I need to find the patch that are applicable to only the enterprise and education edition, navigating to the Windows 10 update history web page reveal KB4088779 to be the latest patch that met this condition, thus it was downloaded via Microsoft Update Catalog.

2018-04-01_13-48-15

Doing things the naïve way

Of course, if the patches can be installed by simply double clicking and let Windows Update do all the work then the experiment would end here. However, as one might expect the installation failed with this message:

2018-03-29_16-30-19

Using an alternative method

Now that using the oblivious method doesn’t work I then choose to use the tool called DISM. DISM, which stands for Deployment Image Servicing and Management, allow us to service online or offline Windows installation. In this case, I will use DISM to manually add the patch component to the online installation (Online installation means the Windows installation that you are using). I can do this using the following steps:

  1. Extract the content of the patch (DISM does not support adding .msu to an online installation)
  2. Locate the main .cab file (In this instance: Windows10.0-KB4088779-x64.cab)
  3. Start an elevated PowerShell session.
  4. Insert this command: Add-WindowsPackage –PackagePath “x:\path\to\Windows10.0-KB4088779-x64.cab” –Online –Ignore Check (where x”:\path\to\ is an actual path)
  5. Wait
  6. Restart when done

vmplayer_2018-04-01_20-10-15

vmplayer_2018-04-01_20-11-05

 

After the restart is completed, I look for the build number: still .164, no luck, thus I begin to look for an absurd solution.

Using an absurd method

I called this absurd because, at this point, no matter what your ‘why’ is for not upgrading, going any further is the much worse alternative to simply upgrading. Nevertheless, because I am curious if it’s still possible I continue on.

For this method, I choose to try changing 4 registry key to try to fool windows update into installing the patch. The key can be located here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion and HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion. For both location I change EditionID’s value to ‘Enterprise’ and ProductName’s value to ‘Windows 10 Home Single Language’.

After all that is done I retry the naïve method, still no dice. I don’t even bother with the alternative method.

Using an absurdly convoluted method

Not giving up yet I use the last method that I think may still work, it is last mainly because of how convoluted it is.  Anyway, this method involve booting into an Windows PE environment and using DISM to service the installation as an offline installation.

I boot into the Windows installation disk and perform the following steps:

  1. Access the command prompt via repair this pc > troubleshoot > command prompt.
  2. Insert the following command DISM.exe /Add-Package /PackagePath:X:\path\to\file.msu /IgnoreCheck /ScratchDir:C:\path\to\scratchDir (where PackagePath point to the .msu or .cab file and ScratchDir point to a scratch directory [duh])

A couple of things to note:

  • I interact with DISM directly via command prompt because PowerShell was not available.
  • We need to manually specify Scratch Directory because the default location is in the ram disk which does not have enough space.

Despite the message that the operation is successful, the build number is still the same, and there’s no indication of any change.

vmplayer_2018-04-01_22-02-51

“How can the operation being considered successful, if nothing was operated?” –EnviableYapper0, doubting his ability to English

Conclusion

I have tried 4 different ways to apply the patches, none of them worked. DISM may have gave me hope, those were thrown out the window the moment the build number were checked. There’s no indication of change no matter how hard I tried. So this experiment can be safely concluded as  Maybe, after all this it is still possible but I have given up.

Even if it is possible, as mention earlier we have passed the point where it would be easier to simply upgrade.