Offline to Online Switch on a Minecraft Server

Illustration

It all started with my kids learning about Minecraft skins and their dad not being able to get their new look working in the game. No matter what, they would stay Steve and Alex. Quick search told me skins are not supported in offline mode and my home server was setup as such. No worries I thought - I’ll just switch online-mode setting in [server.properties](http://minecraft.gamepedia.com/Server.properties) from false to true and that will be it.

However, after I restarted server, my whole family got to start from scratch. We were in skinned bodies but we were also in new locations. It was as if we logged onto the world for the first time. To make it worse, nobody had access to commands anymore. Our ops status has been effectively revoked.

As I added myself to ops again through Minecraft server GUI, I noticed that ops.json got two entries for my user name but each with different UUID. And I could find both UUIDs in my world’s save directory world\playerdata. That got me wondering. What would happen if I would delete file with new UUID and rename old UUID file to it. That is, if my old UUID was 76116624-b235-36a2-a614-ed79be1855ed and my new UUID was d8b2b4e0-1807-4177-a3ca-46afbd1d7538, would renaming 76116624-b235-36a2-a614-ed79be1855ed to d8b2b4e0-1807-4177-a3ca-46afbd1d7538 enable me to get back into my offline body?

Fortunately yes. Transplantation of player data succeeded without any issues. So I went through all save directories and changed played data from old to new UUID. But that wasn’t all. As we were all ops with different ops level for various worlds, I had to visit every ops.json and adjust for that. Simple search/replace was all it took.

And guess what, if you ever decide to make your server offline again, same annoyance in guaranteed since Minecraft has different UUIDs for online and offline mode. There simply seems no way around it. Later I found that people have even built tools to help them with rename.

As Minecraft requires you to verify your credentials at least once over Internet when you buy it, I cannot believe that there is technical reason behind this. Even more because this change was seemingly introduced only with version 1.7.6. My best guess is that it was added as some sort of anti-piracy measure. And as all such measures do, it ended up annoying more paying players than pirates.

In any case my, now online, server recovered from its temporary amnesia and digging could start again.

PS: Paranoid among us might want to check for UUIDs in whitelist.json too.

Moving From Mercurial to Git (Part 2)

With decision to move away from Git, next big step was to transfer existing repositories. While there is a semi-reasonable Git support on Windows, any major dealing with Git is made much easier if you have Linux laying around. In my case decision was to deal with CentOS.

First step was to install all stuff we’ll need - Git, Mercurial and git-remote-hg script:

yum -y install git
yum -y install mercurial
yum -y install wget
mkdir ~/bin
wget https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg -O ~/bin/git-remote-hg
chmod +x ~/bin/git-remote-hg

With that it was time to clone the first repository:

git clone hg::https://bitbucket.org/jmedved/vhdattach

In ideal world this would be all and we are close. If omitted, this step would skip reproducing branching structure on Git. But, while we are at it, I wanted to recreate branching structure I’m used to. Since conversion process leaves all branches inside remotes/origin/branches path, I wanted to move things around a bit:

cd vhdattach
git branch -a | grep 'remotes/origin/branches' | grep -v default | xargs -n 1 -I _ echo _ | cut -d/ -f 4 | xargs -n 1 -I _ git branch _ remotes/origin/branches/_
git branch

Next (optional) step was to fix my old commits:

git filter-branch --env-filter '

OLD_EMAIL="unknown"
CORRECT_NAME="Josip Medved"
CORRECT_EMAIL="jmedved@jmedved.com"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

Since my move to Git was intended to be final I also wanted to change origin. My new home was to be GitHub:

git remote rm origin
git remote add origin git@github.com:medo64/vhdattach.git
git push --all

With that my move was complete.


Part 1

[2020-05-01: There is a bit newer version of this guide.]

Moving From Mercurial to Git (Part 1)

I used to be a huge fan of Visual Basic. When Visual Basic .NET arrived it seemed as most logical thing to use it instead of newfangled C#. However, it became clear quite quickly that Visual Basic is second-class citizen in that universe. Outside of a few exceptions, C# would get everything first. Whether it is a new feature or support for a new platform, Visual Basic would lag behind. So I switched and I haven’t looked back.

Reason why I tell this story is because I am doing similar switch again. I love Mercurial. It is a beautiful distributed versioning system which hides all complexity from a user whether it is in a command line or a great GUI client. It is modern, smart, and well designed system. Any fault with it is just nitpicking and more than outweighed by its features. All that said, Mercurial is also a second-class citizen.

Other distributed source control system almost everybody has heard of is Git. It is powerful and it has reasonable command line interface (although that wasn’t always the case). What it doesn’t have is proper GUI support nor it is equally well designed as Mercurial - especially when it comes to multiplatform support. Git is a bunch of different tools and it shows (you can make a hobby out of finding different commands that do exactly the same thing). However, fact is that you can get used to its shortcomings.

Community gathering around Git is much bigger than anything Mercurial can offer. Small part of it is due to its undeniable power. But I believe big part is due to being Linus’ baby. That gave it an early boost and, once you get used to its peculiarities, there is simply no reason to go to the other versioning system. And more people brings even more people in. And gets more people working on development. So peculiarities became bugs and get fixed. And platform liveliness brings even more people and better. Positive reinforcement at its best.

Simple search for Git vs Mercurial hosting or Git vs Mercurial push best illustrates the difference in usage. Git has simply won. Mind you, that doesn’t mean that Mercurial is going to die - I surely hope not. But it is going to be always an alternative choice.

All that said, I will be moving my open source project to GitHub. Private projects I don’t intend to share will stay with BitBucket but I will be switching them to Git as I do updates. Only things staying on Mercurial will be projects I am sharing with others and those I don’t update at all.

And time with Mercurial wasn’t really wasted - far from it. I would go as far to tell that it is the best distributed version control for taking the first steps. Pretty much all things I’ve learned can transfer directly to Git.

So long and thanks for all the fish.


Part 2

IPv4 Multicast Messing Things Up

I have a reasonable size home IPv4/IPv6 network with 10ish devices accessing it most of the time. And all worked in a perfect harmony until one morning when wife told me she cannot print on our wireless printer (cheap Brother MFC-J435W). While printer seemed fine, all computers seemed to think of it as offline. Without resolving problem I went to work only to be greeted with information that wife’s tablet (Asus Prime) isn’t working either.

After some debugging I pronounced network on both devices dead on continued working on a small utility that uses broadcast to share some basic data over network to whoever might be listening. As I upgraded versions from night before with new code, printer suddenly started to print again. For a minute or so and then stopped again. And few more times that evening. Whenever I restarted media server, printer would work for a while.

Well, I believe you get the pattern.

What exactly causes this particular issue is hard to say. My best guess is that something is wrong with IPv4 multicast packet parser (if it even exists) in both devices. Something in my packets is causing device’s network stack to go haywire. I know it isn’t address itself because I tried with a few other multicast addresses with similar issues. I know it isn’t bandwidth issue since total amount of messages was less that 2 KB/s. In any case, I didn’t have too much time to troubleshoot.

End solution was really simple - I stopped sending my packets using IPv4 addresses and relied on IPv6 multicast only. Not only that IPv6 multicast is a first-class citizen but many network stacks ignore it altogether. Regardless of the exact reason, that worked perfectly.

IPhone in the Hands of Android Guy

During latest round of company phone upgrades I received an iPhone 5S. As long time android guy (since original HTC Desire) I never actually tried any of iPhone devices more than a few minutes here or there. Now, after using it for a few months, I can share my thoughts.

First impression is great - iPhone 5S is built like a brick. With aluminium on back and glass top it is hard to find it a fault. Buttons are nice and firm, audio connector is best I’ve ever seen, and data connector seems like it could handle a lot. Until USB type C becomes the norm, it is probably the most comfortable power/data connector out there. I am generally not a fan of phone cases so my bias might be kicking in, but it is a sin to put such a phone in a case. And phone can handle occasional fall with grace - at least it did for me.

Turning the phone on was a bit of challenge at first since I haven’t had phone with power button on top for a while. But this was reasonably easy to get used to. What I still cannot get used to is lack of a back button. I find it extremely annoying that, once you have gone deep enough through screens, there is often no way to get back except killing application and starting from start. Yes, some of blame lies with application developers, but at least virtual back button would be nice.

Reality is that sometime you will need to reboot your phone. On Android I got half of my grays waiting for phone to shut down and then boot up. And idiotic decision to remove restart menu option in Lollipop didn’t help. I cannot even count the times I would start shutdown and forget about turning the phone back on. While iPhone doesn’t have restart either, procedure is so fast that it is refreshing.

Where I found iPhone infinitely better than any of my previous phones is e-mail. Due to nature of my work, I have multiple company mail accounts. On Android some of them required me to use special applications (e.g. Touchdown), some of them required special access to device (and probably my firstborn too), or they simply would not work at all. On iPhone they all nicely fall in line and allow usage of default Mail application. Yes, there is no technical reason why Android wouldn’t get the same treatment. However, Android allows more and IT departments jump on it. With iPhone there is only one way how things are done and they learned to accommodate.

Not all is great mind you. Keyboard application that comes by default is simply awful if you need to enter any amount of passwords. I find myself regularly switching through multiple keyboard screens in order to enter anything. Yes, fingerprint sensor can alleviate some of that pain but keyboard is definitely worst one I’ve seen in years. And yes, you can get other keyboards in Apple store and it is frightening how you can actually pay for keyboards with even worse layout.

And Store itself contains bunch of half-baked applications that cost actual money. Yes, there are many half-baked applications in Android store, heck, I even built some myself. But they are free. It doesn’t matter how crappy application is, there’s a cost associated to it in Apple’s store. And yes, there are good free applications but they are mostly coming from big companies. Small utility apps come at a cost.

And application management is crazy. Yes, there are multiple screens but you cannot put your applications there just willy-nilly. Every screen is a list and you will not put application to bottom-right before you fill every other spot. Folders are equally dumb with only nine applications allowed before you get into multi-screen folder. Design so awful that I cannot fully describe its horrors in words.

Preloaded applications are of reasonable quality but nobody will use all of them. And there is no way to remove them from screen. Don’t have Apple Watch or you don’t care for Safari? Tough luck, there is simply no way to remove them. Yes, you can put them in folder but that is as elegant as me telling my socks are suddenly clean if I turn them inside out.

And I finally understood all the jokes about Apple Maps. I tried it a couple of times and it didn’t bring me to my desired destination a single time. Best it could do was to bring me on an opposite side of a building block. With it every day is April 1st. And Siri only knows how to start that abomination - you cannot configure it to start any proper mapping application. So Apple screwed the single thing I used voice recognition for. And I don’t even want to start about Siri.

To access any content on your iPhone you will need iTunes application. That piece of software is greatest sin against humanity since WW2 ended and you need it for even the most simple operations. Wanna ringtone? Stop bitching and use iTunes. And don’t have ringtone longer than 40 seconds. And no, you cannot use MP3 files for it. After being beaten into submission by iTunes, I was really thankful to see that at least my images are accessible as a (read-only!) drive.

Would I buy iPhone for my own private use? Not a chance. Its price is simply not justifiable to me regardless of its good looks and excellent (hardware) design.

However, phone absolutely shines for business use. Ease of setting multiple e-mails without all usual IT nonsense is really refreshing and it allows you freedom I’ve never experienced on an Android device. If you ever had to deal with big company’s IT department iPhone is worth every penny.