Skip to content

Commit b8a594f

Browse files
Add Fabric 26.1+ class templates (Mojmap) (#2639)
* Added freemarker templates for 26.1+ fabric mods and renamed old versions in "NAME (1.21.11-).java.xyza", enchantment 26.1+ template is not changed yet for my information miss * Set FabricEnchantment (26.1+).java.ft content according to NeoForgeEnchantment.java.ft but both are not functionals in newer versions, also renamed FabricStatusEffect (26.1+).java.xyza to FabricMobEffect (26.1+).java.xyza for coherence * Added a Minecraft version parsing for fabric with method computeVersion in FabricModule.kt * Fixed typos * Added gradle variables support and minecraft version for neoforge for remove enchantment template in 1.21+ * Added new Json template for 1.21+ enchantments instead of unfunctional java classes with a new action for minecraft resources creation containing for now only enchantments templates (in a future pr i think that i'll expand it, changing from Minecraft Enchantment to Minecraft Json and adding blockstates, models, etc. templates) * Improved resource modid detection resource root's modid now detected scanning the path instead of choosing ever the first modid in project modids * Update action text for Minecraft Json creation * Clean up commented code in MinecraftResourceCreateAction Removed commented-out code related to module and Minecraft version checks. * Cleaned Code and Deleting Rendundant Version Detecting Code * Remove fabricMinecraftVersion from FabricModule Remove unused fabricMinecraftVersion property. * Removed Unused Imports and Deleted Json Template * Resolved unrelated formatting changes * Fix formatting of constructor in ForgeEnchantment template * Default to newest template if mcVersion is null --------- Co-authored-by: joe <burtonjae@hotmail.co.uk>
1 parent c6f0217 commit b8a594f

18 files changed

Lines changed: 146 additions & 20 deletions

src/main/kotlin/insight/generation/MinecraftClassCreateAction.kt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class MinecraftClassCreateAction :
6969
val isForge = MinecraftFacet.getInstance(module, ForgeModuleType) != null
7070
val isNeoForge = MinecraftFacet.getInstance(module, NeoForgeModuleType) != null
7171
val isFabric = MinecraftFacet.getInstance(module, FabricModuleType) != null
72+
7273
val mcVersion = MinecraftFacet.getInstance(module, McpModuleType)?.getSettings()
7374
?.minecraftVersion?.let(SemanticVersion::parse)
7475

@@ -88,29 +89,39 @@ class MinecraftClassCreateAction :
8889
builder.addKind("Packet", icon, MinecraftTemplates.FORGE_1_17_PACKET_TEMPLATE)
8990
} else {
9091
builder.addKind("Block", icon, MinecraftTemplates.FORGE_1_17_BLOCK_TEMPLATE)
91-
builder.addKind("Enchantment", icon, MinecraftTemplates.FORGE_1_17_ENCHANTMENT_TEMPLATE)
9292
builder.addKind("Item", icon, MinecraftTemplates.FORGE_1_17_ITEM_TEMPLATE)
9393
builder.addKind("Mob effect", icon, MinecraftTemplates.FORGE_1_17_MOB_EFFECT_TEMPLATE)
9494
builder.addKind("Packet", icon, MinecraftTemplates.FORGE_1_18_PACKET_TEMPLATE)
9595
}
96+
if (mcVersion < MinecraftVersions.MC1_21) {
97+
builder.addKind("Enchantment", icon, MinecraftTemplates.FORGE_1_17_ENCHANTMENT_TEMPLATE)
98+
}
9699
}
97100

98101
if (isNeoForge) {
99102
val icon = PlatformAssets.NEOFORGE_ICON
100103
builder.addKind("Block", icon, MinecraftTemplates.NEOFORGE_BLOCK_TEMPLATE)
101-
builder.addKind("Enchantment", icon, MinecraftTemplates.NEOFORGE_ENCHANTMENT_TEMPLATE)
102104
builder.addKind("Item", icon, MinecraftTemplates.NEOFORGE_ITEM_TEMPLATE)
103105
builder.addKind("Mob effect", icon, MinecraftTemplates.NEOFORGE_MOB_EFFECT_TEMPLATE)
104106
builder.addKind("Packet", icon, MinecraftTemplates.NEOFORGE_PACKET_TEMPLATE)
107+
if (mcVersion == null || mcVersion < MinecraftVersions.MC1_21)
108+
builder.addKind("Enchantment", icon, MinecraftTemplates.NEOFORGE_ENCHANTMENT_TEMPLATE)
105109
}
106110

107111
if (isFabric) {
108112
val icon = PlatformAssets.FABRIC_ICON
113+
if (mcVersion != null && mcVersion < MinecraftVersions.MC26_1) {
114+
builder.addKind("Block", icon, MinecraftTemplates.FABRIC_1_21_11_BLOCK_TEMPLATE)
115+
builder.addKind("Item", icon, MinecraftTemplates.FABRIC_1_21_11_ITEM_TEMPLATE)
116+
builder.addKind("Status effect", icon, MinecraftTemplates.FABRIC_1_21_11_STATUS_EFFECT_TEMPLATE)
117+
} else {
118+
builder.addKind("Block", icon, MinecraftTemplates.FABRIC_26_1_BLOCK_TEMPLATE)
119+
builder.addKind("Item", icon, MinecraftTemplates.FABRIC_26_1_ITEM_TEMPLATE)
120+
builder.addKind("Mob effect", icon, MinecraftTemplates.FABRIC_26_1_MOB_EFFECT_TEMPLATE)
109121

110-
builder.addKind("Block", icon, MinecraftTemplates.FABRIC_BLOCK_TEMPLATE)
111-
builder.addKind("Enchantment", icon, MinecraftTemplates.FABRIC_ENCHANTMENT_TEMPLATE)
112-
builder.addKind("Item", icon, MinecraftTemplates.FABRIC_ITEM_TEMPLATE)
113-
builder.addKind("Status effect", icon, MinecraftTemplates.FABRIC_STATUS_EFFECT_TEMPLATE)
122+
}
123+
if (mcVersion != null && mcVersion < MinecraftVersions.MC1_21)
124+
builder.addKind("Enchantment", icon, MinecraftTemplates.FABRIC_1_21_11_ENCHANTMENT_TEMPLATE)
114125
}
115126
}
116127

src/main/kotlin/util/MinecraftTemplates.kt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,18 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory {
161161
}
162162
FileTemplateGroupDescriptor("Fabric", PlatformAssets.FABRIC_ICON).let { fabricSkeletonGroup ->
163163
skeletonGroup.addTemplate(fabricSkeletonGroup)
164-
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_BLOCK_TEMPLATE))
165-
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_ITEM_TEMPLATE))
166-
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_ENCHANTMENT_TEMPLATE))
167-
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_STATUS_EFFECT_TEMPLATE))
164+
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_1_21_11_BLOCK_TEMPLATE))
165+
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_1_21_11_ITEM_TEMPLATE))
166+
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_1_21_11_ENCHANTMENT_TEMPLATE))
167+
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_1_21_11_STATUS_EFFECT_TEMPLATE))
168+
169+
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_26_1_BLOCK_TEMPLATE))
170+
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_26_1_ITEM_TEMPLATE))
171+
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_26_1_MOB_EFFECT_TEMPLATE))
172+
168173
}
169-
}
170174

175+
}
171176
FileTemplateGroupDescriptor("Licenses", null).let { licenseGroup ->
172177
group.addTemplate(licenseGroup)
173178
enumEntries<License>().forEach { license ->
@@ -268,10 +273,14 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory {
268273

269274
const val FORGE_1_18_PACKET_TEMPLATE = "ForgePacket (1.18+).java"
270275

271-
const val FABRIC_BLOCK_TEMPLATE = "FabricBlock.java"
272-
const val FABRIC_ITEM_TEMPLATE = "FabricItem.java"
273-
const val FABRIC_ENCHANTMENT_TEMPLATE = "FabricEnchantment.java"
274-
const val FABRIC_STATUS_EFFECT_TEMPLATE = "FabricStatusEffect.java"
276+
const val FABRIC_1_21_11_BLOCK_TEMPLATE = "FabricBlock (1.21.11-).java"
277+
const val FABRIC_1_21_11_ITEM_TEMPLATE = "FabricItem (1.21.11-).java"
278+
const val FABRIC_1_21_11_ENCHANTMENT_TEMPLATE = "FabricEnchantment (1.21.11-).java"
279+
const val FABRIC_1_21_11_STATUS_EFFECT_TEMPLATE = "FabricStatusEffect (1.21.11-).java"
280+
281+
const val FABRIC_26_1_BLOCK_TEMPLATE = "FabricBlock (26.1+).java"
282+
const val FABRIC_26_1_ITEM_TEMPLATE = "FabricItem (26.1+).java"
283+
const val FABRIC_26_1_MOB_EFFECT_TEMPLATE = "FabricMobEffect (26.1+).java"
275284

276285
const val NEOFORGE_MIXINS_JSON_TEMPLATE = "NeoForge Mixins Config.json"
277286
const val NEOFORGE_MAIN_CLASS_TEMPLATE = "NeoForge Main Class.java"

src/main/kotlin/util/MinecraftVersions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ object MinecraftVersions {
4848
val MC1_21_1 = SemanticVersion.release(1, 21, 1)
4949
val MC1_21_11 = SemanticVersion.release(1, 21, 11)
5050
val MC26_1 = SemanticVersion.release(26, 1)
51+
val MC26_2 = SemanticVersion.release(26, 2)
5152

5253
fun requiredJavaVersion(minecraftVersion: SemanticVersion) = when {
5354
minecraftVersion <= MC1_16_5 -> JavaSdkVersion.JDK_1_8

src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricBlock.java.ft renamed to src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricBlock (1.21.11-).java.ft

File renamed without changes.

src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricEnchantment.java.html renamed to src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricBlock (1.21.11-).java.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020

2121
<html>
2222
<body>
23-
A basic enchantment class for fabric.
23+
A basic block class for fabric 1.21.11-.
2424
</body>
2525
</html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
2+
#parse("File Header.java")
3+
4+
import net.minecraft.world.level.block.Block;
5+
6+
public class ${NAME} extends Block {
7+
public ${NAME}(Properties properties) {
8+
super(properties);
9+
}
10+
}

src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricBlock.java.html renamed to src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricBlock (26.1+).java.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020

2121
<html>
2222
<body>
23-
A basic block class for fabric.
23+
A basic block class for fabric 26.1+.
2424
</body>
2525
</html>

src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricEnchantment.java.ft renamed to src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricEnchantment (1.21.11-).java.ft

File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
Minecraft Development for IntelliJ
3+
4+
https://mcdev.io/
5+
6+
Copyright (C) 2025 minecraft-dev
7+
8+
This program is free software: you can redistribute it and/or modify
9+
it under the terms of the GNU Lesser General Public License as published
10+
by the Free Software Foundation, version 3.0 only.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
-->
20+
21+
<html>
22+
<body>
23+
A basic enchantment class for fabric 1.21.11-.
24+
</body>
25+
</html>

src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricItem.java.ft renamed to src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricItem (1.21.11-).java.ft

File renamed without changes.

0 commit comments

Comments
 (0)