Galatia Academy

Creating custom Starsystem

This guide is work in progress, expect information to be changed and not always be correct.

TBD

  • All the code stuff

  • Getting code loaded in plugin

  • A lot of explanation of stuff

  • I soooo much like tomatopaste example starsysten so it going be based on it.

This guide will go in depth on how to create starsystem, make it generate in sector and also help you with setting up markets.

If you been refered to this page from somewhere online and don't know anything about modding starsector you should visit Welcome page to help you with getting started. When you finished with setting up mod folder and IDE you're welcome to continue with this guide.

Initial setup

For the start, we should go over file standard structure for adding start system for your mod.

Usually generation will be structured like this:

Your mod Plugin 
^^^
Generator Class Java File - Includes calls to starsystem and other things mod want to generate (faction relations, 
^^^
StarSystem Class Java File - Defines star system and almost everything within it

If you followed Getting Started you should have mod plugin already, that leaves us with need to create Generator Class and Starsystem Class. You don't strictly need to use generator class, but having function separeta helps to keeps mod plugin tidy and clearer and what each part does. Besides java files itself it would be useful to have dedicated Packages (folders) for new files. So lets start:

  1. Go in you side panel, find place you like your main generator directory to be and Right click it > New > Package > create new package by adding world after last dot.
  2. Go in you side panel, click place you like your starsystem code to be and Right click > New > Java Class. Name your file (for this guide example, I will use "MyMod_Gen".
  3. Go in you side panel, and Right click on world package> New > Package > create package starsystems
  4. Go in you side panel, find place you like your starsystem code to be and Right click > New > Java Class. Name your file (for this guide example, I will use "MyNewStarsystem".

Remember to keep your names useful, it will save your time in the future!

You should end up with something like (add image later):

  • /other/packages depends on where you created `world` package
    • world
      • starsystems
        • MyNewStarsystem
      • MyModId_Gen

You should now have two blank class files looking something like:

What we want now is to link all new files togeter with mod plugin. To do that we first need to have methods to actually ecxecute by call of our classes.

For now follow me and add inside the class

public void generate(SectorAPI sector) {

}

to both MyMod_Gen and MyNewStarsystem:

You will end up with something like:

Creating Star System and adding stars

After setting up file structure we can return to out actual star system code. You have your generate method and we can start working with first of all telling gane we want to create system by adding:

    StarSystemAPI system = sector.createStarSystem("New Starsystem");
    system.getLocation().set(3000, 10000); //position of the system on the map, if position not defined system will spawn on maps 0, 0 (

Beside creating system it also needs init (main) star.

Code to adding one will look something like:

        // create the star
        PlanetAPI star = system.initStar("modID_MyNewStarsystem_star", // unique id for this star
                "star_yellow", // id in planets.json
                900f, // radius (in pixels at default zoom)
                400); // corona radius, from star edge
        system.setLightColor(new Color(169, 177, 65)); // light color in entire system, affects all entities
        star.setDiscoverable(false);

All star systems need init (main) star. It not always an actual star (for example in nebulas there no central star) but an entity serving as center of the system.

Adding planets

        PlanetAPI planet1 = StarSystem.addPlanet("MyModId_planet1", //planet id - should be unique
                Star, //orbit focus
                "First planet", 
                Planets.PLANET_TERRAN, //Planet type 
                20, //angle
                130f, //radius
                4500f, //distance from star
                600f); //how many days to orbit
        planet1.setCustomDescriptionId("MyModId_planet1"); //for custom descriptions
        planet1.setDiscoverable(false);

You maybe noted what planet type was defined by Planets.PLANET_TERRAN. Planets is ID class inside Starsector API, it used to easily access and search value defined somewhere else. Planets class corresponds to planets inside planet_gen_data.csv. In this case Planets.PLANET_TERRAN equivalent to inputing "terran" in same place.

There are multiple ID classes in API, used for different things, you can find most of them in com.fs.starfarer.api.impl.campaign.ids.

Now what we added first actually orbiting entity (to note: planets are also entities in game engine), we can talk about orbit focus. In simple terms Orbit Focus is what (in this case) planet will orbit around. Our focus references Star, value of which we set when creating init star. Naturaly focus can be any entity (specifically SectorEntityToken which PlanetAPI extends of). Setting focus on different things can help create moons, multistar solar systems and so on.

Adding Custom Entities (Stations, stable points and so much more)

Custom entities cover most things in system what are not planets: station, gates, stable points, structures for stable points and so many more. Full list of available custom entities located in starsector-core/data/config/custom_entities.json. In this section I cover most used ones but adding any one of them should work similar.

Besides what available in vanilla you can create your own custom entity by creating custom_entities.json inside your mod data/config and following vanilla file json structure.

Now lets go over some most common entities you may want to add:

Adding stable points and stable point structures


        SectorEntityToken loc1 = StarSystem.addCustomEntity(null,
        null,
        "comm_relay", //id in custom_entities.json
        "faction_id"; //which faction own the entity
        loc1.getMemoryWithoutUpdate().set("$isotd_FIMBRelay", true);
        loc1.setCircularOrbitPointingDown(Star, 65, 9000, 170);

Adding other entities


Adding rings and asteroid belts


        system.addRingBand(star, //focus - what to orbit
        "misc", //categoty 
        "rings_asteroids0", 
        256f, 
        3, 
        Color.white, 
        256f, 
        7600, 
        110);

Asteroid belt is belt or ring of actual asteroids. They in fact are real entities, and what you get collision with when flying throught.

        system.addAsteroidBelt(planet3, 50, 850, 120, 90, 110, Terrain.ASTEROID_BELT, "Asteroid belt");

Creating markets

Adding Markets are bit more complex than just adding entities and planets to star system. Main complication is that there just so much market can do and be. While hard to cover everything tomatopaste example star system established quite popular and comfortable for basic market setup by using separate addMarketplace class

Bag of tricks

This section is for more miche short tips for stuff you can run into when bringing you ideas to life

Making Free market start fully active

You can get access to FreeMarket variable and just set days it was active

        FreeMarket.get(Revachol_Marketplace).setDaysActive(366);

If IDE complains about line above make sure you imported the class:

import com.fs.starfarer.api.impl.campaign.econ.FreeMarket;

Making system map available from start

System map is only available if system was visited by player, but it is in fact public variable, so you can just change it:

        system.setEnteredByPlayer(true);

"My markets have no people in comms"

If your markets get created after game does its economyLoad on initial new game creation, they will not get automatically populated. Luckly Alex added way to fix it.

        CoreLifecyclePluginImpl.createInitialPeople(planet1_Marketplace, new Random());

Example Code

If you want to copy example code, bellow is code for star system using every bit of code demonstated in the guide:

Don't forget to fix package to one for your mod. Intelij can help with it (it will show you error if package is wrong and offer to automatically redo it to file current package placement:

Last updated 7/8/2026, 6:12:17 PM by Vexlia Artemiss, Witch of Zeta · revision 14