1
Modding Resources / [GUIDE] Setting up Visual Studio Code to mod
« on: December 16, 2020, 02:29:57 AM »
Setting up VSCode for modding
There are a few guides here for intelliJ but I personally am a fan of VScode, I coded my first mod in NetBeans 10.0 but some of the features I'm used to in VSCode I just couldn't live without.
Also, if images aren't showing up when you click the spoilers, just reload the page, not sure what's going on there.
Anyways, here goes:
Now here's the very specific stuff for making this work for Starsector.
At the very bottom paste this in.
NOTE: This is for Windows setups, given that jdk1.7.0_80 was installed in it's default location (64 bit), If you grabbed the 32 Bit version, it will be in C:\\Program Files (x86)... instead
If you grabbed an OpenJDK version, or just downloaded a zip, you'll have to point it to the correct directory yourself. Also, the double "\\" is intended, it's escaping the backslash, which Windows won't let die.
Linux Users: Most likely location is: /usr/lib/jvm/...
On Linux, I personally had to download the Zip and unzip it to that location.
If by default something else was there (It might use any previously installed Jdk's or installed openJDK and populated this already), delete it and replace it with this.
Okay, that's sorted.
Now how do I use this?
And if you're familiar with Gradle and Git, I suggest you check out this template repo made by Jaghaimo here and use something like the Gradle Tasks extension in VScode.
There are a few guides here for intelliJ but I personally am a fan of VScode, I coded my first mod in NetBeans 10.0 but some of the features I'm used to in VSCode I just couldn't live without.
Also, if images aren't showing up when you click the spoilers, just reload the page, not sure what's going on there.
Anyways, here goes:
- You can get vscode directly from their website or use your given package manager to download it (apt, pacman, etc.)
- Once you have vscode installed, open it up and head over to the extensions tab SpoilerShould looks something like this[close]
- Once you're there, pick up these two extensions (If it asks you to reload, go ahead and reload) Spoiler[close]
- Now for the fun stuff: go ahead and hit Ctrl+Shift+P to bring up the command palette and type "Java", find "create Java project" it should look like this after you click it: Spoiler[close]
- Click "No Build Tools" to make this easier.
- Now select a parent folder to put your project in (hint: it's about to ask you for a project name, this creates a folder with that name)
- Name it whatever you want, it doesn't matter.
- It's going to auto generate a project for you now, you can delete the App.java, README, and lib folder (unless you want to use them)
Now here's the very specific stuff for making this work for Starsector.
- Starsector requires that you use Java 7 (aka jdk 1.7.0) when coding, so go pick that up from here
- Now to make sure that the project manager is going to use Jdk1.7.0_80 to compile the .Jar go ahead and bring up the command palette with Ctrl+Shift+P.
- Type "settings" and find "Preferences: Open Settings (JSON)"
At the very bottom paste this in.
Code
"java.configuration.runtimes": [
{
"name":"JavaSE-1.7",
"path":"C:\\Program Files\\Java\\jdk1.7.0_80",
"default":true
}
]
If you grabbed an OpenJDK version, or just downloaded a zip, you'll have to point it to the correct directory yourself. Also, the double "\\" is intended, it's escaping the backslash, which Windows won't let die.
Linux Users: Most likely location is: /usr/lib/jvm/...
On Linux, I personally had to download the Zip and unzip it to that location.
If by default something else was there (It might use any previously installed Jdk's or installed openJDK and populated this already), delete it and replace it with this.
Okay, that's sorted.
Now how do I use this?
- In the file explorer (Pages icon, top left), there should be a tab called "JAVA PROJECTS", open that up and make sure your project is expanded like so. Spoiler[close]
- If you want to add libraries (starfarer.api.jar for example) click the plus sign that pops up when you mouse-over "Referenced Libraries" and find the .Jar
- If you want to add a Class hit the plus sign that pops up next to "src." This supports names like "org.tuvox.TestMod" It will autocreate folders and the .java as well as include the correct package information in said file.
- To build your project, when you mouse-over that panel, you will see this up top Spoiler[close]
- Click it and uncheck everything except "bin" if you have dependencies (this ensures your dependencies don't get thrown into the compiled .Jar)
- The default behavior for this is to just spit out the jar in the project folder, if you'd like to change that behavior click the Settings Cog all the way in the bottom left
- Once there, type "Export Jar: Target Path" and you can change it. CAUTION: If User is selected in the top left, it will do this globally for EVERY project you work on, if you just want to change it for this Project, click Workspace.
And if you're familiar with Gradle and Git, I suggest you check out this template repo made by Jaghaimo here and use something like the Gradle Tasks extension in VScode.