Skip to content

Commit 9e604c2

Browse files
Fabric support (#733)
Along with simply porting what was on my fork to the new project creator refactor, I decided to go a little further and add the following features which are not on my fork: * Bumped the TemplateMakerFabric dependency which fixes one or two bugs * Method entry points are now supported * Smarter entry point creation * Added the ability to choose the license of your mod and generate a license file with the template * Added some references to the fabric.mod.json, and basic fabric.mod.json validation Closes #663
1 parent 846c49f commit 9e604c2

File tree

83 files changed

+5764
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+5764
-146
lines changed

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ repositories {
7373
maven("https://repo.spongepowered.org/maven")
7474
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies")
7575
maven("https://repo.gradle.org/gradle/libs-releases-local/")
76+
maven("https://maven.extracraftx.com")
7677
}
7778

7879
dependencies {
@@ -86,6 +87,8 @@ dependencies {
8687
}
8788
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
8889

90+
implementation("com.extracraftx.minecraft:TemplateMakerFabric:0.3.0")
91+
8992
jflex("org.jetbrains.idea:jflex:1.7.0-b7f882a")
9093
jflexSkeleton("org.jetbrains.idea:jflex:1.7.0-c1fdf11:idea@skeleton")
9194
grammarKit("org.jetbrains.idea:grammar-kit:1.5.1")

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Supported Platforms
138138
- [![Bukkit Icon](src/main/resources/assets/icons/platform/Bukkit.png?raw=true) **Bukkit**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse) ([![Spigot Icon](src/main/resources/assets/icons/platform/Spigot.png?raw=true) Spigot](https://spigotmc.org/) and [![Paper Icon](src/main/resources/assets/icons/platform/Paper.png?raw=true) Paper](https://papermc.io/))
139139
- [![Sponge Icon](src/main/resources/assets/icons/platform/Sponge_dark.png?raw=true) **Sponge**](https://www.spongepowered.org/)
140140
- [![Forge Icon](src/main/resources/assets/icons/platform/Forge.png?raw=true) **Minecraft Forge**](http://minecraftforge.net/forum)
141+
- [![Fabric Icon](src/main/resources/assets/icons/platform/Fabric.png?raw=true) **Fabric**](https://fabricmc.net)
141142
- [![LiteLoader Icon](src/main/resources/assets/icons/platform/LiteLoader.png?raw=true) **LiteLoader**](http://www.liteloader.com/)
142143
- [![MCP Icon](src/main/resources/assets/icons/platform/MCP.png?raw=true) **MCP**](http://www.modcoderpack.com/)
143144
- [![Mixins Icon](src/main/resources/assets/icons/platform/Mixins_dark.png?raw=true) **Mixins**](https://github.com/SpongePowered/Mixin)

src/main/kotlin/com/demonwav/mcdev/asset/PlatformAssets.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ object PlatformAssets : Assets() {
2525
val FORGE_ICON = loadIcon("/assets/icons/platform/Forge.png")
2626
val FORGE_ICON_2X = loadIcon("/assets/icons/platform/Forge@2x.png")
2727

28+
val FABRIC_ICON = loadIcon("/assets/icons/platform/Fabric.png")
29+
val FABRIC_ICON_2X = loadIcon("/assets/icons/platform/Fabric@2x.png")
30+
2831
val SPONGE_ICON = loadIcon("/assets/icons/platform/Sponge.png")
2932
val SPONGE_ICON_2X = loadIcon("/assets/icons/platform/Sponge@2x.png")
3033
val SPONGE_ICON_DARK = loadIcon("/assets/icons/platform/Sponge_dark.png")

src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleBuilder.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.demonwav.mcdev.asset.PlatformAssets
1414
import com.demonwav.mcdev.platform.MinecraftModuleType
1515
import com.demonwav.mcdev.platform.bukkit.creator.BukkitProjectSettingsWizard
1616
import com.demonwav.mcdev.platform.bungeecord.creator.BungeeCordProjectSettingsWizard
17+
import com.demonwav.mcdev.platform.fabric.creator.FabricProjectSettingsWizard
1718
import com.demonwav.mcdev.platform.forge.creator.ForgeProjectSettingsWizard
1819
import com.demonwav.mcdev.platform.liteloader.creator.LiteLoaderProjectSettingsWizard
1920
import com.demonwav.mcdev.platform.sponge.creator.SpongeProjectSettingsWizard
@@ -107,6 +108,7 @@ class MinecraftModuleBuilder : JavaModuleBuilder() {
107108
BukkitProjectSettingsWizard(creator),
108109
SpongeProjectSettingsWizard(creator),
109110
ForgeProjectSettingsWizard(creator),
111+
FabricProjectSettingsWizard(creator),
110112
LiteLoaderProjectSettingsWizard(creator),
111113
VelocityProjectSettingsWizard(creator),
112114
BungeeCordProjectSettingsWizard(creator)

src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleWizardStep.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ package com.demonwav.mcdev.creator
1212

1313
import com.demonwav.mcdev.creator.buildsystem.BuildSystem
1414
import com.demonwav.mcdev.creator.exception.SetupException
15+
import com.demonwav.mcdev.util.toPackageName
1516
import com.intellij.ide.util.projectWizard.ModuleWizardStep
1617
import com.intellij.openapi.ui.MessageType
1718
import com.intellij.openapi.ui.popup.Balloon
@@ -48,8 +49,8 @@ abstract class MinecraftModuleWizardStep : ModuleWizardStep() {
4849
name: String,
4950
classNameModifier: (String) -> String = { it }
5051
): String {
51-
val packageNameStart = buildSystem.groupId.replace("-", "").toLowerCase()
52-
val packageNameEnd = buildSystem.artifactId.replace("-", "").toLowerCase()
52+
val packageNameStart = buildSystem.groupId.toPackageName()
53+
val packageNameEnd = buildSystem.artifactId.toPackageName()
5354
val className = classNameModifier(name.replace(" ", ""))
5455
return "$packageNameStart.$packageNameEnd.$className"
5556
}

src/main/kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class MinecraftProjectCreator {
101101
return
102102
}
103103
config.type.type.performCreationSettingSetup(module.project)
104+
CreatorStep.runAllReformats()
104105
} else {
105106
val types = configs.map { it.type }
106107
newLog(build.javaClass.name + "::multiModuleBaseSteps", workLog).let { log ->
@@ -109,6 +110,8 @@ class MinecraftProjectCreator {
109110
}
110111
}
111112

113+
val postMultiModuleAwares = mutableListOf<PostMultiModuleAware>()
114+
112115
for (config in configs) {
113116
val log = newLog(config, workLog)
114117

@@ -117,10 +120,14 @@ class MinecraftProjectCreator {
117120
val dir = Files.createDirectories(root.resolve(newArtifactId))
118121

119122
val newBuild = build.createSub(newArtifactId)
120-
if (!newBuild.buildCreator(config, dir, module).getMultiModuleSteps(root).run(indicator, log)) {
123+
val creator = newBuild.buildCreator(config, dir, module)
124+
if (!creator.getMultiModuleSteps(root).run(indicator, log)) {
121125
return
122126
}
123127
config.type.type.performCreationSettingSetup(module.project)
128+
if (creator is PostMultiModuleAware) {
129+
postMultiModuleAwares += creator
130+
}
124131
}
125132

126133
val commonArtifactId = "${build.artifactId}-common"
@@ -138,6 +145,13 @@ class MinecraftProjectCreator {
138145
newLog(build.javaClass.name + "::multiModuleBaseFinalizer", workLog).let { log ->
139146
build.multiModuleBaseFinalizer(module, root).run(indicator, log)
140147
}
148+
149+
for (postMultiModuleAware in postMultiModuleAwares) {
150+
val log = newLog(postMultiModuleAware, workLog)
151+
if (!postMultiModuleAware.getPostMultiModuleSteps(root).run(indicator, log)) {
152+
return
153+
}
154+
}
141155
}
142156

143157
// Tell IntelliJ about everything we've done

src/main/kotlin/com/demonwav/mcdev/creator/PlatformChooserWizardStep.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.demonwav.mcdev.creator.buildsystem.BuildSystemType
1515
import com.demonwav.mcdev.platform.PlatformType
1616
import com.demonwav.mcdev.platform.bukkit.creator.BukkitProjectConfig
1717
import com.demonwav.mcdev.platform.bungeecord.creator.BungeeCordProjectConfig
18+
import com.demonwav.mcdev.platform.fabric.creator.FabricProjectConfig
1819
import com.demonwav.mcdev.platform.forge.creator.ForgeProjectConfig
1920
import com.demonwav.mcdev.platform.liteloader.creator.LiteLoaderProjectConfig
2021
import com.demonwav.mcdev.platform.sponge.creator.SpongeProjectConfig
@@ -41,6 +42,7 @@ class PlatformChooserWizardStep(private val creator: MinecraftProjectCreator) :
4142
private lateinit var paperPluginCheckBox: JCheckBox
4243
private lateinit var spongePluginCheckBox: JCheckBox
4344
private lateinit var forgeModCheckBox: JCheckBox
45+
private lateinit var fabricModCheckBox: JCheckBox
4446
private lateinit var bungeeCordPluginCheckBox: JCheckBox
4547
private lateinit var waterfallPluginCheckBox: JCheckBox
4648
private lateinit var velocityPluginCheckBox: JCheckBox
@@ -117,6 +119,7 @@ class PlatformChooserWizardStep(private val creator: MinecraftProjectCreator) :
117119
paperPluginCheckBox.isSelected ||
118120
spongePluginCheckBox.isSelected ||
119121
forgeModCheckBox.isSelected ||
122+
fabricModCheckBox.isSelected ||
120123
liteLoaderModCheckBox.isSelected ||
121124
bungeeCordPluginCheckBox.isSelected ||
122125
waterfallPluginCheckBox.isSelected ||
@@ -145,6 +148,10 @@ class PlatformChooserWizardStep(private val creator: MinecraftProjectCreator) :
145148
result += ForgeProjectConfig()
146149
}
147150

151+
if (fabricModCheckBox.isSelected) {
152+
result += FabricProjectConfig()
153+
}
154+
148155
if (liteLoaderModCheckBox.isSelected) {
149156
result += LiteLoaderProjectConfig()
150157
}

src/main/kotlin/com/demonwav/mcdev/creator/ProjectChooserWizardStep.form

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<properties/>
2929
<border type="empty"/>
3030
<children>
31-
<grid id="c580e" binding="chooserPanel" layout-manager="GridLayoutManager" row-count="10" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="5">
31+
<grid id="c580e" binding="chooserPanel" layout-manager="GridLayoutManager" row-count="11" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="5">
3232
<margin top="2" left="10" bottom="10" right="10"/>
3333
<constraints/>
3434
<properties/>
@@ -90,7 +90,7 @@
9090
</component>
9191
<component id="ef19b" class="javax.swing.JLabel">
9292
<constraints>
93-
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
93+
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
9494
</constraints>
9595
<properties>
9696
<icon value="assets/icons/platform/BungeeCord@2x.png"/>
@@ -140,15 +140,15 @@
140140
</component>
141141
<component id="51426" class="javax.swing.JCheckBox" binding="bungeeCordPluginCheckBox">
142142
<constraints>
143-
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
143+
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
144144
</constraints>
145145
<properties>
146146
<text value="BungeeCord Plugin"/>
147147
</properties>
148148
</component>
149149
<component id="a965" class="javax.swing.JLabel">
150150
<constraints>
151-
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
151+
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
152152
</constraints>
153153
<properties>
154154
<icon value="assets/icons/platform/LiteLoader@2x.png"/>
@@ -157,15 +157,15 @@
157157
</component>
158158
<component id="5a8c1" class="javax.swing.JCheckBox" binding="liteLoaderModCheckBox" default-binding="true">
159159
<constraints>
160-
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
160+
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
161161
</constraints>
162162
<properties>
163163
<text value="LiteLoader Mod"/>
164164
</properties>
165165
</component>
166166
<component id="87b9d" class="javax.swing.JLabel">
167167
<constraints>
168-
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
168+
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
169169
</constraints>
170170
<properties>
171171
<enabled value="true"/>
@@ -176,7 +176,7 @@
176176
</component>
177177
<component id="405e" class="javax.swing.JLabel">
178178
<constraints>
179-
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
179+
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
180180
</constraints>
181181
<properties>
182182
<enabled value="true"/>
@@ -187,25 +187,42 @@
187187
</component>
188188
<component id="55507" class="javax.swing.JCheckBox" binding="waterfallPluginCheckBox">
189189
<constraints>
190-
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
190+
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
191191
</constraints>
192192
<properties>
193193
<text value="Waterfall Plugin"/>
194194
</properties>
195195
</component>
196196
<component id="93e0" class="javax.swing.JCheckBox" binding="velocityPluginCheckBox">
197197
<constraints>
198-
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
198+
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
199199
</constraints>
200200
<properties>
201201
<text value="Velocity Plugin"/>
202202
</properties>
203203
</component>
204204
<vspacer id="d9ec2">
205205
<constraints>
206-
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
206+
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
207207
</constraints>
208208
</vspacer>
209+
<component id="e8c19" class="javax.swing.JLabel">
210+
<constraints>
211+
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
212+
</constraints>
213+
<properties>
214+
<icon value="assets/icons/platform/Fabric@2x.png"/>
215+
<text value=""/>
216+
</properties>
217+
</component>
218+
<component id="40b19" class="javax.swing.JCheckBox" binding="fabricModCheckBox">
219+
<constraints>
220+
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
221+
</constraints>
222+
<properties>
223+
<text value="Fabric Mod"/>
224+
</properties>
225+
</component>
209226
</children>
210227
</grid>
211228
</children>

src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ abstract class BaseProjectCreator(
5353
protected val project
5454
get() = rootModule.project
5555

56-
protected fun createJavaClassStep(qualifiedClassName: String, mapper: JavaClassTextMapper): BasicJavaClassStep {
56+
protected fun createJavaClassStep(
57+
qualifiedClassName: String,
58+
mapper: JavaClassTextMapper
59+
): BasicJavaClassStep {
5760
val (packageName, className) = splitPackage(qualifiedClassName)
5861
val classText = mapper(packageName, className)
5962
return BasicJavaClassStep(project, buildSystem, qualifiedClassName, classText)
@@ -66,3 +69,16 @@ abstract class BaseProjectCreator(
6669
return packageName to className
6770
}
6871
}
72+
73+
/**
74+
* Implement this interface on your [ProjectCreator] if you need to do extra setup work after all modules are built
75+
* and the project is imported, e.g. if some of the creation needs to be done in smart mode. Only gets used in
76+
* multi-project builds; single-module builds are expected to run these tasks themselves in the correct order, such
77+
* that they happen after the project is imported.
78+
*
79+
* Note: just because this interface can be used to utilize smart mode, doesn't mean that the steps will be called in
80+
* smart mode. If a step needs smart mode, it should wait for it itself.
81+
*/
82+
interface PostMultiModuleAware {
83+
fun getPostMultiModuleSteps(projectBaseDir: Path): Iterable<CreatorStep>
84+
}

src/main/kotlin/com/demonwav/mcdev/creator/buildsystem/gradle/GradleBuildSystem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class GradleBuildSystem(
5454
val files = GradleFiles(buildText, propText, settingsText)
5555

5656
return listOf(
57-
BasicGradleStep(project, rootDirectory, this, files),
57+
GradleSetupStep(project, rootDirectory, this, files),
5858
GradleWrapperStep(project, rootDirectory, this)
5959
)
6060
}

0 commit comments

Comments
 (0)