[Tutorial] Client Editing

Forum for alternative clients, mods & discussions on the same.

[Tutorial] Client Editing

Postby LostJustice » Wed Jan 17, 2018 7:57 am

This is a question I often get in discord and decided to share this tutorial I made for some people who have asked me in the past. I hope this can help others as it helped the people I have given it to. There is a good majority of developers who wish to edit the client but are just not familiar with setting up the client or just need help going in the right direction. So this tutorial will walk you through the first steps to allow you to obtain the source code and set up an Intellij IDE to start editing source code so maybe you can add that cool widget you always wanted or just in general practice to get better and learn Loftar's favorite programming language Java.

This tutorial is intended only for Windows operating systems simply because I do not use a Mac and Linux can have some variations. What you do with your client editing is not by any means supported by me or even Loftar and Jorb so you need to figure out the problems you cause by your own editing by yourself or with. (Aka I am helping you set up to code, not writing your client for you.)

So adding this link here for a community of modders. If you are interested in editing the client or have client editing questions or want to contact me faster, click on the link below to join the discord. Note there is some rules of the chat you must read in order to provide a maintained discord.

***I noticed one or two people not getting auto ranked in discord. If it has been more than 5 minutes and you are not autoranked please feel free to PM me on discord if you join the channel. This happens rarely.

Discord Modding Link: https://discord.gg/JAjepQH

Note, I am also human and make mistakes and don't know everything, so if you see an error or have a better way of doing something please let me know either in replies or private message and I will fix it!

So this is the tutorial, I hope it helps some of you. :D

What this tutorial is about?
This tutorial is to help you begin editing client code with in an IDE. It gives a very basic set up of how to run the client from the IDE. What you do with it from there is up to you.


What this tutorial does not cover:
- How to code in Java
- How to use Git
- How to do specific changes and add things
- How to code bots
- Set up issues with IDE or JDK (Use google to resolve these issues)
- Tutorial for other IDE’s besides Intellij.
- How to do it on Mac or Linux (Sorry Windows Support only even though it may work the same way or similar on these)


1. Installing the JDK:

If you already programmed before in Java, you know you need a JDK to compile java classes. It is recommended you use Java 8 for this tutorial since this is what I will be using and for any future tutorials I decide to make.
You can download and install JDK 8 from here:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

2. Installing Git:

Git is a Version control system. It allows for multiple developers to work on a project. This is needed to download the repository. This tutorial will not cover git other than the required parts for this tutorial.
You will need to install Git files which can be found here:
https://git-scm.com/downloads

3. Installing the IDE:

There are multiple IDE’s to use for coding in Java. For this tutorial we will be using Intellij since it has decent Git and Ant build support.
You can download and install the IDE from here:
**Note unless you have a key or license only download and use the Community Edition!
https://www.jetbrains.com/idea/download/

4. Creating the project folder:

After completing steps 1 and 2, it is time to create a project folder. Simply create a folder where ever you what with what ever name you choose on your computer. For me I will be creating a “Tutorial” folder on my desktop as seen below. This is where your project in the next step will be inside of.

Image


5. Creating the project:

Now start Intellij. You will be brought to the screen below:

Image


If you already created a project before in Intellij you need to do File -> Close Project.

If you do not see Check out from Version Control google Adding Git VCS in Intellij.

Now to create the project, click on Check out from Version Control and this screen should appear and you will want to put this link in the first open spot and change the “Parent Directory” to the file you created earlier.

Git Link: git://sh.seatribe.se/hafen-client

Image


Now click Clone and below screen should appear.

Image


Basically now you are copying the client files to your computer so you can edit them when you Clone from git.

Then another small window may pop up asking Would you like to create an IDEA project for the sources you have checked out to C:\Path\To\Project\hafen-client?, click Yes.

Then another screen will pop up with import project. Choose Create project from existing sources and click Next.

Then click Next again. You can also change your project name here if you don’t want it to be called hafen-client.

Then click Next again three more times.

On this screen is where you choose the JDK version. Click the green + to add your JDK and name it 1.8 and the path should be something along the lines of this: C:\Program Files\Java\jdk1.8.0_<Version> depending on the <Version> you installed and where you installed it to. (If you don't find it there try Program Files(x86)!)

If 1.8 already shows then you can just select 1.8 and hit Next.

Then finally click Finish.

You should be brought to a screen which looks like something similar to the image below. If you don’t see the Project drop down on the left, click the Project tab to expand it.

Image


5. Building, compiling, and running.

Before we go on this step, Hafen does not just run and compile the classes. Hafen uses what is called an Ant build file to package and create distributable jars. So you need to “Build” the jars with the Ant build file before running your project. Intellij thankfully has support for using Ant build files which is what we are going to use in this tutorial. So essentially you will change code -> rebuild with Ant -> run client.
So to begin, anywhere on your IDE type CTRL + Shift + A. The search box like the one below should appear somewhere near your mouse.

Image


So from here type Ant Build and press enter. Then a window like the one below on the right should appear.

Image


You will want to click the green + plus. Then in the new folder navigate the folder you created earlier to find the Build.xml file. It should look something like what is shown below.

Image


Once you find this file hit Ok. The screen on the right should look something like below.

Image


You can then double click run or hafen-client to build the client.
**To actually log into the client, make a run.bat with the following text and run the client from the “~ProjectFolder/build/” location.
java -Xms512m -Xmx1024m -jar hafen.jar -U https://game.havenandhearth.com/hres/ game.havenandhearth.com PAUSE

**If you have trouble building your client or want it to build faster, give your configuration more RAM and Memory which can be done by clicking here:

Image


Now you should be able to build and run the client from source. That concludes this tutorial.

loftar wrote:Please proceed and ruin everything. :)


***As Promised:

A quick tutorial over some basic usages of Java Reflections to assist in effectively coding the client:
https://youtu.be/a86DpFtrL4k
Last edited by LostJustice on Mon Mar 02, 2020 8:24 pm, edited 5 times in total.
Image
User avatar
LostJustice
 
Posts: 677
Joined: Sun Mar 25, 2012 3:57 am

Re: [Tutorial] Client Editing

Postby shubla » Wed Jan 17, 2018 9:36 am

I have a strong feeling that if someone is not able to set up the project himself, there is no chance that he could do any meaningful modifications.
Image
I'm not sure that I have a strong argument against sketch colors - Jorb, November 2019
http://i.imgur.com/CRrirds.png?1
Join the moderated unofficial discord for the game! https://discord.gg/2TAbGj2
Purus Pasta, The Best Client
User avatar
shubla
 
Posts: 13043
Joined: Sun Nov 03, 2013 11:26 am
Location: Finland

Re: [Tutorial] Client Editing

Postby iamahh » Wed Jan 17, 2018 12:14 pm

will check this out later, ty

i usually just download the source Zip from github but struggle to setup everything on Eclipse... specially Ambers source... the original code I managed to compile and run once

i think iDEA only accepts 64bit OS tho
iamahh
 
Posts: 1810
Joined: Sat Dec 12, 2015 8:23 pm

Re: [Tutorial] Client Editing

Postby LostJustice » Wed Jan 17, 2018 7:23 pm

shubla wrote:I have a strong feeling that if someone is not able to set up the project himself, there is no chance that he could do any meaningful modifications.
Normally I would agree with you but being one of those people I struggled with Ant build files. It isn't because I wasn't able to, it just simply I never seen one or used one before and it took me several attempts to even notice it was an issue and then some time to learn them. Now I have a client with a lot of editions and I am just trying to save those people from that hassle I went through. Another villager I worked with had a client for automating farming which automated most of the village farming, he too said he had struggled with setting up. His hobby is Java programming, not his work or lifestyle. There is also just others that want to mess with source code regardless of what is added. This tutorial is for those type of people, otherwise I do agree there will be a large number who tried it and can't figure it out, but at least they got to try something.

iamahh wrote:will check this out later, ty

i usually just download the source Zip from github but struggle to setup everything on Eclipse... specially Ambers source... the original code I managed to compile and run once

i think iDEA only accepts 64bit OS tho


Your welcome. :) It accepts all formats, I can't remember exactly but it either auto configures or allows you to pick at start up of the installation.
Last edited by LostJustice on Thu Jan 18, 2018 12:18 am, edited 1 time in total.
Image
User avatar
LostJustice
 
Posts: 677
Joined: Sun Mar 25, 2012 3:57 am

Re: [Tutorial] Client Editing

Postby LostJustice » Wed Jan 17, 2018 11:06 pm

Added a discord link for people use in case they need further help or have questions or wish to help others. :)
Image
User avatar
LostJustice
 
Posts: 677
Joined: Sun Mar 25, 2012 3:57 am

Re: [Tutorial] Client Editing

Postby foomanchu » Thu Jan 18, 2018 5:10 pm

shubla wrote:I have a strong feeling that if someone is not able to set up the project himself, there is no chance that he could do any meaningful modifications.


not true.. i struggled in legacy and early hafen to get an ide to work.. fortunately in legacy, there were scripting clients and in hafen, i met a friend who was able to teach me how to get started with intellij. Now im sitting with bots / api's with a total of probably over 12k lines

+1 to LostJustice for educating the people (and +1 to stya for teaching me how to use intellij :D)
foomanchu
 
Posts: 121
Joined: Wed Jun 29, 2011 6:13 am

Re: [Tutorial] Client Editing

Postby loftar » Thu Jan 18, 2018 6:04 pm

shubla wrote:I have a strong feeling that if someone is not able to set up the project himself, there is no chance that he could do any meaningful modifications.

I'd like to agree, but doing any software development on Windows is such an ordeal that I too have given up at several occasions.

LostJustice wrote:Loftar's favorite programming language Java.

Image
"Object-oriented design is the roman numerals of computing." -- Rob Pike
User avatar
loftar
 
Posts: 8926
Joined: Fri Apr 03, 2009 7:05 am

Re: [Tutorial] Client Editing

Postby Forest » Thu Jan 18, 2018 7:29 pm

shubla wrote:I have a strong feeling that if someone is not able to set up the project himself, there is no chance that he could do any meaningful modifications.

Agree with you.
I have basic concepts about programming, in particular on java. (University non-main course.)
And i completed this quest to compile the amber client from the source code when I started playing H&H. But I did not have enough understanding of the principles of the client's work to make any useful changes. I found where the Amber stores its extensions, but I could not create my own.

The ideal continuation of this topic was a tutorial for creating such an extension. With detailed explanations. In any case, thanks for your efforts that you have invested in the popularization of this topic.
User avatar
Forest
 
Posts: 82
Joined: Wed Apr 13, 2011 8:51 pm

Re: [Tutorial] Client Editing

Postby LostJustice » Fri Jan 19, 2018 1:02 am

Forest wrote:
shubla wrote:I have a strong feeling that if someone is not able to set up the project himself, there is no chance that he could do any meaningful modifications.

Agree with you.
I have basic concepts about programming, in particular on java. (University non-main course.)
And i completed this quest to compile the amber client from the source code when I started playing H&H. But I did not have enough understanding of the principles of the client's work to make any useful changes. I found where the Amber stores its extensions, but I could not create my own.

The ideal continuation of this topic was a tutorial for creating such an extension. With detailed explanations. In any case, thanks for your efforts that you have invested in the popularization of this topic.


Tbh, I was thinking of explaining that too but that is mainly more along the lines of what the discord group is for. What shubla said is true, if you do not understand a lot of principles, it will be a long and heavy road for sure if your aiming for making something like a scripting client. However, if your into something like reskinning, changing settings, adding options to something like existing amber, (like making a noise when you spot an ant hill, and yes I have done this) then you will be able to with just understanding basic Java.

The only reason why I haven't approached this topic is because even in the village I was in, foo, stya, and I had three separate clients all with different ways of going about things. For me, I didn't want to touch Loftar's lovely Chain Saw code and used pure reflection in my client which honestly in my opinion is the best for going about keeping and maintaining a client with a lot of features. But the draw backs is that it takes a lot of time, fine tuning, and you can run into more issues while debugging so it much slower development to do this but much easier to update and maintain (almost zero maintenance). Stya's main thing was to produce a client that worked effectively so he would do the opposite and change source code. This is faster development but this meant a lot of Git merges and potentially odd stuff happening after updates, so the opposite side of the spectrum. Foo was kind of in the middle somewhere. So, really there could be a tutorial but there is no ideal way in actually making a tutorial for this and every change you make has it's trade off.

If I also get a general direction that people want to go in, like do people want to change skins, make new config options that do stuff, ect I can maybe make a tutorial about the process of how to do this, but would need to see what the majority of people want and are able to do.
Image
User avatar
LostJustice
 
Posts: 677
Joined: Sun Mar 25, 2012 3:57 am

Re: [Tutorial] Client Editing

Postby stya » Fri Jan 19, 2018 7:54 am

I do errors (break while merging™) and then use my minion testers to find them...

and then they say please halp it does not work!!!
Image
Image
User avatar
stya
 
Posts: 943
Joined: Wed May 21, 2014 3:13 pm

Next

Return to The Wizards' Tower

Who is online

Users browsing this forum: No registered users and 7 guests