Sign in to follow this  
Grubok

Need Mod Creation Tutorial with Ago's

Recommended Posts

Long time no talk on the wurm forums. Anyway straight to the point. As the title suggests I'm looking for some sort of mod creation tutorial. Preferably using a free IDE like intellij which i've been using. I am not particular which one as long as it's free :D

I've managed to make a number of server side changes myself to a server I'm running. I just wish there was a way to share some of them.

 

I've made modifications to various things from terraforming multiplier changes to the repropsect code to include ada and glimmer when ran. However these were changes to Server.jar.  I've got a few projects in the works and would like to know how to turn them into shareable mods. This is especially with one project I'm thinking of undertaking, adding herb gardens for many of the forages. I rooted well enough around in the code to determine farms can't be changed without a major overhaul. With a project that size and seemingly wanted by many I'd want to share it.

 

If anyone knows a good tutorial available for making one that works with Ago's that would be great. If not could someone put one together. The fact There isn't one stickied anywhere probably stops a lot of would be modders. 

Edited by Grubok

Share this post


Link to post
Share on other sites

The tutorial is very basic. The wiki for modloader, imho, is enough to cover the ago's modlauncher functionality. You have to find your class you want to modify, find the methods, load it with HookManager and well, overwrite it by your own code. I'm not sure that any tutorial better then wiki can be written. 

Share this post


Link to post
Share on other sites

Modloader wiki?do you mind sharing the link i can' find it.

Share this post


Link to post
Share on other sites

Okay bumping because the wiki although is a bit detailed IS not that helpful in a very key area for someone who never took any courses for java programming... Most of my real world programming has dealt with industrial automation. I have managed a number of stable direct server code changes to my server, and even made changes to jonneh's mapviewer as you can see here, I had made changes to another one that used google maps api but never published that as I like Jonneh's better as the other required a 2nd program and took forever to run generating Thousands of files.   However, when it comes to modding I often hit a road block.  I've tried a few avenues but i know there is just something I'm not getting/seeing.. 

 

Probably my biggest concern has been the "Proper" way to set up the Project(IntelliJ) or Workspace(Eclipse) that I wont have to spend 10-15 minutes brutally copy, pasting, and renaming things any time i think of starting on a mod.

 

My current attempts to play with things are Barbaric to say the least. Any time I've decided to start on one I go through the barbaric steps and start working on one. I get part way done with a mod, then I get sidetracked. I decide to attempt again to find the proper way to set things up. Upon getting sidetracked with this I will spend a few hours tinkering with different methods, get frustrated, then completely give up on the project. 

 

So like I said before my biggest personal hangup is having a "Proper" project setup. 

 

Edited by Grubok

Share this post


Link to post
Share on other sites

for intellij look up artifact building. google search > intellij artifact creation

A mod's jar file is an artifact. 

 

* Options from the properties file go under "configure()" which is implemented with Configurable.

* Reflection code generally goes under "onServerStarted()" which is implemented with ServerStartedListener..

* Bytecode changes generally goes under "init()" or "Preinit()" and is implemented with Initable.

 

I haven't used the InvocationHandler much explained on Ago's project wiki: https://github.com/ago1024/WurmServerModLauncher/wiki/GettingStarted

 

 

 

Here is a Class line from what I'm doing now:

public class WurminianPacifistMod implements WurmServerMod, Initable, Configurable, ServerStartedListener, ItemTemplatesCreatedListener {

 

Share this post


Link to post
Share on other sites

Well I finally got around to finishing and testing my first mod, I had imported Ago's src and used it as a basis of building my mod as another internal maven project copying his format,

 

To generate the files in IntelliJ how I did it is by opening the maven tab and going to my mod name> Lifecycle > Package  

 

Having copied Ago's setup I get a zip file with everything ready to go for extraction and placing into the server directory.

 

The one I just released (Forum posting ) involved bytecode manipulation as I was changing things inside methods. Essentially changing a number of  BIPUSHs relative to a number in the config.  I haven't really bothered with invocationHandler yet. My mod may not the cleanest thing to look at but it does work, Although it feels much more Surgical than other methods.  

 

OH one interesting thing I figured out with IntelliJ was getting a javap output in the run console tab.  It involves having the targeted class not being in a jar, but easy enough to pull out and place somewhere. There may be a better way but for me it's rather quick and handy... Go to File > Settings, In the new window Tools> External Tools, click on the green  "+"  give it a name (i just named it javap), and in the Program field, put the full path for the javap.exe  like this example

D:\Program Files\Java\jdk1.8.0_91\bin\javap.exe 

in Parameters: 

-c $FileNameWithoutExtension$ 

in Working directory:

$FileDir$

Then click through all the OKs and Applys, then look at your project tree on the left and right click on a class file. You should have a Selection for "External Tools" > "The name you set". As I stated earlier it doesn't seem to work on class files inside a jar; but, outside it works just fine. I'm not sure if that'll be handy to you but whomever else reads this it might.

Edited by Grubok

Share this post


Link to post
Share on other sites

I made a batch file to run javap.exe. I change a couple variables in it and run the .bat to print a WU class.

 

CD C:\Program Files (x86)\Steam\SteamApps\common\Wurm Unlimited Dedicated Server\byte code prints
SET "name=Action"
SET path=com.wurmonline.server.behaviours.Action
"C:\Program Files\Java\jdk1.8.0_77\bin\javap.exe" -c -s -verbose -private -classpath "C:\Program Files (x86)\Steam\steamapps\common\Wurm Unlimited Dedicated Server\server.jar" %path% > %name%" bytecode disassemble.txt" 2>&1

I have no idea if there is a better way. I got this to work and stopped looking for alternatives.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this