Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/main/kotlin/insight/generation/MinecraftClassCreateAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class MinecraftClassCreateAction :
val isForge = MinecraftFacet.getInstance(module, ForgeModuleType) != null
val isNeoForge = MinecraftFacet.getInstance(module, NeoForgeModuleType) != null
val isFabric = MinecraftFacet.getInstance(module, FabricModuleType) != null

val mcVersion = MinecraftFacet.getInstance(module, McpModuleType)?.getSettings()
?.minecraftVersion?.let(SemanticVersion::parse)

Expand All @@ -88,29 +89,39 @@ class MinecraftClassCreateAction :
builder.addKind("Packet", icon, MinecraftTemplates.FORGE_1_17_PACKET_TEMPLATE)
} else {
builder.addKind("Block", icon, MinecraftTemplates.FORGE_1_17_BLOCK_TEMPLATE)
builder.addKind("Enchantment", icon, MinecraftTemplates.FORGE_1_17_ENCHANTMENT_TEMPLATE)
builder.addKind("Item", icon, MinecraftTemplates.FORGE_1_17_ITEM_TEMPLATE)
builder.addKind("Mob effect", icon, MinecraftTemplates.FORGE_1_17_MOB_EFFECT_TEMPLATE)
builder.addKind("Packet", icon, MinecraftTemplates.FORGE_1_18_PACKET_TEMPLATE)
}
if (mcVersion < MinecraftVersions.MC1_21) {
builder.addKind("Enchantment", icon, MinecraftTemplates.FORGE_1_17_ENCHANTMENT_TEMPLATE)
}
}

if (isNeoForge) {
val icon = PlatformAssets.NEOFORGE_ICON
builder.addKind("Block", icon, MinecraftTemplates.NEOFORGE_BLOCK_TEMPLATE)
builder.addKind("Enchantment", icon, MinecraftTemplates.NEOFORGE_ENCHANTMENT_TEMPLATE)
builder.addKind("Item", icon, MinecraftTemplates.NEOFORGE_ITEM_TEMPLATE)
builder.addKind("Mob effect", icon, MinecraftTemplates.NEOFORGE_MOB_EFFECT_TEMPLATE)
builder.addKind("Packet", icon, MinecraftTemplates.NEOFORGE_PACKET_TEMPLATE)
if (mcVersion == null || mcVersion < MinecraftVersions.MC1_21)
builder.addKind("Enchantment", icon, MinecraftTemplates.NEOFORGE_ENCHANTMENT_TEMPLATE)
}

if (isFabric) {
val icon = PlatformAssets.FABRIC_ICON
if (mcVersion != null && mcVersion >= MinecraftVersions.MC26_1) {
builder.addKind("Block", icon, MinecraftTemplates.FABRIC_26_1_BLOCK_TEMPLATE)
builder.addKind("Item", icon, MinecraftTemplates.FABRIC_26_1_ITEM_TEMPLATE)
builder.addKind("Mob effect", icon, MinecraftTemplates.FABRIC_26_1_MOB_EFFECT_TEMPLATE)

builder.addKind("Block", icon, MinecraftTemplates.FABRIC_BLOCK_TEMPLATE)
builder.addKind("Enchantment", icon, MinecraftTemplates.FABRIC_ENCHANTMENT_TEMPLATE)
builder.addKind("Item", icon, MinecraftTemplates.FABRIC_ITEM_TEMPLATE)
builder.addKind("Status effect", icon, MinecraftTemplates.FABRIC_STATUS_EFFECT_TEMPLATE)
} else {
builder.addKind("Block", icon, MinecraftTemplates.FABRIC_1_21_11_BLOCK_TEMPLATE)
builder.addKind("Item", icon, MinecraftTemplates.FABRIC_1_21_11_ITEM_TEMPLATE)
builder.addKind("Status effect", icon, MinecraftTemplates.FABRIC_1_21_11_STATUS_EFFECT_TEMPLATE)
}
if (mcVersion != null && mcVersion < MinecraftVersions.MC1_21)
builder.addKind("Enchantment", icon, MinecraftTemplates.FABRIC_1_21_11_ENCHANTMENT_TEMPLATE)
}
}

Expand Down
27 changes: 18 additions & 9 deletions src/main/kotlin/util/MinecraftTemplates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,18 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory {
}
FileTemplateGroupDescriptor("Fabric", PlatformAssets.FABRIC_ICON).let { fabricSkeletonGroup ->
skeletonGroup.addTemplate(fabricSkeletonGroup)
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_BLOCK_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_ITEM_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_ENCHANTMENT_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_STATUS_EFFECT_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_1_21_11_BLOCK_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_1_21_11_ITEM_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_1_21_11_ENCHANTMENT_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_1_21_11_STATUS_EFFECT_TEMPLATE))

fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_26_1_BLOCK_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_26_1_ITEM_TEMPLATE))
fabricSkeletonGroup.addTemplate(FileTemplateDescriptor(FABRIC_26_1_MOB_EFFECT_TEMPLATE))

}
}

}
FileTemplateGroupDescriptor("Licenses", null).let { licenseGroup ->
group.addTemplate(licenseGroup)
enumEntries<License>().forEach { license ->
Expand Down Expand Up @@ -268,10 +273,14 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory {

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

const val FABRIC_BLOCK_TEMPLATE = "FabricBlock.java"
const val FABRIC_ITEM_TEMPLATE = "FabricItem.java"
const val FABRIC_ENCHANTMENT_TEMPLATE = "FabricEnchantment.java"
const val FABRIC_STATUS_EFFECT_TEMPLATE = "FabricStatusEffect.java"
const val FABRIC_1_21_11_BLOCK_TEMPLATE = "FabricBlock (1.21.11-).java"
const val FABRIC_1_21_11_ITEM_TEMPLATE = "FabricItem (1.21.11-).java"
const val FABRIC_1_21_11_ENCHANTMENT_TEMPLATE = "FabricEnchantment (1.21.11-).java"
const val FABRIC_1_21_11_STATUS_EFFECT_TEMPLATE = "FabricStatusEffect (1.21.11-).java"

const val FABRIC_26_1_BLOCK_TEMPLATE = "FabricBlock (26.1+).java"
const val FABRIC_26_1_ITEM_TEMPLATE = "FabricItem (26.1+).java"
const val FABRIC_26_1_MOB_EFFECT_TEMPLATE = "FabricMobEffect (26.1+).java"

const val NEOFORGE_MIXINS_JSON_TEMPLATE = "NeoForge Mixins Config.json"
const val NEOFORGE_MAIN_CLASS_TEMPLATE = "NeoForge Main Class.java"
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/util/MinecraftVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ object MinecraftVersions {
val MC1_21_1 = SemanticVersion.release(1, 21, 1)
val MC1_21_11 = SemanticVersion.release(1, 21, 11)
val MC26_1 = SemanticVersion.release(26, 1)
val MC26_2 = SemanticVersion.release(26, 2)

fun requiredJavaVersion(minecraftVersion: SemanticVersion) = when {
minecraftVersion <= MC1_16_5 -> JavaSdkVersion.JDK_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

<html>
<body>
A basic enchantment class for fabric.
A basic block class for fabric 1.21.11-.
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")

import net.minecraft.world.level.block.Block;

public class ${NAME} extends Block {
public ${NAME}(Properties properties) {
super(properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

<html>
<body>
A basic block class for fabric.
A basic block class for fabric 26.1+.
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Minecraft Development for IntelliJ

https://mcdev.io/

Copyright (C) 2025 minecraft-dev

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, version 3.0 only.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

<html>
<body>
A basic enchantment class for fabric 1.21.11-.
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

<html>
<body>
An empty Fabric item class.
An empty Fabric item class for 1.21.11-.
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")

import net.minecraft.world.item.Item;

public class ${NAME} extends Item {
public ${NAME}(Properties props) {
super(props);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

<html>
<body>
An empty Fabric status effect class.
An empty Fabric item class for 1.21.11-.
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")

import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
public class ${NAME} extends MobEffect {
public ${NAME}(MobEffectCategory mobEffectCategory, int color) {
super(mobEffectCategory, color);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Minecraft Development for IntelliJ

https://mcdev.io/

Copyright (C) 2025 minecraft-dev

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, version 3.0 only.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

<html>
<body>
An empty Fabric status effect class for 1.21.11- .
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Minecraft Development for IntelliJ

https://mcdev.io/

Copyright (C) 2025 minecraft-dev

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, version 3.0 only.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

<html>
<body>
An empty Fabric status effect class for 1.21.11- .
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import net.minecraft.world.item.enchantment.EnchantmentCategory;

public class ${NAME} extends Enchantment {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't delete this blank line

public ${NAME}(Rarity rarity, EnchantmentCategory category, EquipmentSlot[] slots) {
super(rarity, category, slots);
super(rarity, category, slots);
}
}