Having a look at the sources of Haven & Hearth MMO client (I)


If you’ve never heard of the H&H, here’s a snippet from their page:

Haven & Hearth is a MMORPG (Massive Multiplayer Online Roleplaying Game) set in a fictional world loosely inspired by Slavic and Germanic myth and legend. The game sets itself apart from other games in the genre in its aim to provide players with an interactive, affectable and mutable game world, which can be permanently and fundamentally changed and affected through actions undertaken by the players. Our fundamental goal with Haven & Hearth is to create a game in which player choices have permanent and/or lasting effects and, thus, providing said players with a meaningful and fun gaming experience.

But what’s special in my opinion is:

  • it’s developed by a team of two Swedes
  • it’s developed in Java using JOGL
  • client’s code is open and the game itself is free, which means there are many alternative clients today.

You can find original sources’ license here:


Following by the link to their official git repository and notes from developers.
However, the source I will be dealing with will come from the ‘Amber’ client:


It provides some additional functionalities and is regularly updated:


Downloading and building from sources

>> git clone https://github.com/romovs/amber.git 
>> cd amber-1.68.0
>> ant

At this moment some weird errors may occure, but if so, just type ant once more and it should build it successfully. Now, to run, type:

>> cd build/
>> java -jar hafen.jar -U http://game.havenandhearth.com/hres/ game.havenandhearth.com

You’ll end up with a menu screen. However, (at least) to me it wasn’t over, because after logging in an error popped op:

Screenshot from 2018-10-06 13-42-35

I got to the file on the top of the stacktrace (Buff.java), found the line, had a guess what’s wrong and corrected the thing from this:

Screenshot from 2018-10-06 13-43-20To this:Screenshot from 2018-10-06 13-43-28

Then build the whole thing once again with ant and I finally managed to log in.

My brief modifications

Camera zoom

So I proceeded through the code for some time after that. I’ve been thinking what would be easy to do and came with an idea of simply enabling maximum camera zoom for a starter. It proved to be easy.

Cameras are managed in the MapView.java,
there’s a chfield function there, which I modified in the following way:

Screenshot from 2018-10-06 14-20-54

Btw, these comments are mine. I hardly ever stumbled on an existing comment, but if so, they’re mostly some rants/hacks over Java. Anyways, I rebuilt the project and got the camera scrolled up to the orbit with arrow buttons – it worked. I could see the whole area of the map around the player:

Screenshot from 2018-10-06 14-18-51

Detaching camera from the player

The following idea was:

  • Space bar would toggle detaching
  • If detached, one could move the camera to the point on the map, by simply click on some place at the map, but the player still wouldn’t move there
  • Space bar pressed once again would attach camera to the player and focus on it

As I said, cameras are managed in the MapView.java.
There’s a function that returns object which defines the player:

Screenshot from 2018-10-06 14-47-27

And a function, that basing on that, returns player’s current coordinates:

Screenshot from 2018-10-06 14-48-16

…which I guessed, is used also by the camera, so I created an object that cached player’s position and updated it when:

  • detached mode is on
  • left click on map occurs

So getcc looks like this now:

Screenshot from 2018-10-06 14-56-15
I injected some of my code into the existing function that handles clicking, that is ‘hit’ function. Parts of it, before editing, looks like this:Screenshot from 2018-10-06 14-58-17And after adding my code, it starts with:Screenshot from 2018-10-06 14-59-19To toggle detaching mode, I edited the ‘keydown’ function, which starts with:Screenshot from 2018-10-06 15-00-37I just added an additional branch to the if-else tree:Screenshot from 2018-10-06 15-01-57

That’s all. I rebuilt it and recorded my modifications that you could watch it:


Next time we will tackle the networking code (which fun parts I already found, reside in the Session.java).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s