Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Modding with just .java // without using a .jar  (Read 1988 times)

NoFoodAfterMidnight

  • Ensign
  • *
  • Posts: 39
    • View Profile
Modding with just .java // without using a .jar
« on: August 07, 2019, 10:44:49 PM »

So I've started diving into modding, and been trying to get further but hit a wall where I need to edit something found in the API, but can't get it to load. I'm not looking to set up an IDE to compile a .jar file, and I've seen references to placing .java files into the mod folder to have the game compile them at start but can't for the life of me actually find any documentation on it or figure out the file structure on my own. So what I'm trying to do is change two files: GraviticScanAbility.java and GraviticScanData.java, found in the API under \fs\starfarer\api\impl\campaign\abilities, where would I put them in a mods folder to get them to compile, and is a modplugin file still necessary if I'm just slightly altering existing files?

I'd appreciate any help!
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Modding with just .java // without using a .jar
« Reply #1 on: August 08, 2019, 04:34:41 AM »

Stuff in data/scripts (and subfolders) is compiled at run time using Janino. Bear in mind that this can't handle generics (e.g. the <String> in List<String>) and may have other limitations.

A mod plugin isn't required.
Logged

NoFoodAfterMidnight

  • Ensign
  • *
  • Posts: 39
    • View Profile
Re: Modding with just .java // without using a .jar
« Reply #2 on: August 08, 2019, 05:29:20 PM »

So just drop those two files directly into data/scripts/ with no subfolders? That doesn't seem to do anything at all. I can drop in two jarbled nothings that can't compile and get no compiling errors.

What is the quickest way to just alter some of the base game files? That's all I want to do.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Modding with just .java // without using a .jar
« Reply #3 on: August 09, 2019, 04:58:15 AM »

You'll also need to tell the game to actually reference the modified Java classes.

In this case: Include a copy of data/campaign/abilities.csv in your mod, removing all the rows except the header and the Neutrino Detector row (but include all its cells from the vanilla copy, not just the modified one). Change its plugin value to point to your modified GraviticScanAbility class.
(If you haven't done it already, the GraviticScanAbility java code should likewise be modified to use your modded GraviticScanData)
Logged