diff --git a/.gitignore b/.gitignore index af3a5e4..6b7f99c 100644 --- a/.gitignore +++ b/.gitignore @@ -451,4 +451,5 @@ FodyWeavers.xsd *.msp # JetBrains Rider -*.sln.iml \ No newline at end of file +*.sln.iml +/.kotlin/ diff --git a/README.md b/README.md index 463fa1f..ae7d521 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,15 @@ -# Stonecutter template +# NeoComputers +A rewrite of OpenComputers for modern Minecraft, alongside our own additions. Based off of the https://github.com/JumperOnJava/Stonecutter-Arch-Template template. +### Project setup +This uses a combination of Architectury, Architectury API, Stonecutter, and Kotlin. Stonecutter is the most important one +to read about. Don't forget to Gradle -> Tasks -> stonecutter -> "Set active project to [version]-[loader]" before building/testing +the mod for that version! -If you have some issues with template ping me (@JavaJumper) in [Kiku's realm](https://discord.gg/TBgNUCfryS) or official fabric discord +Also, try reading about how stonecutter's conditional macros work (those can be seen as the `//?` statements in the code). +Stonecutter automatically comments and uncomments them when you switch between versions or loaders, you shouldn't do it yourself. -This template allows you create multiloader multversion mod using stonecutter and architectury +The minecraft version this mod is currently being developed on is 1.21.11 neoforge or fabric. Although the project stonecutter.gradle.kts +is currently using 1.21.9-fabric, you can easily change it with the gradle task. -It is based on my CustomCursor project - -## Setup - -To change versions check settings.gradle.kts -Currently default versions are these, -but you can easily add other versions if you need that -- 1.20.1, fabric, lexforge -- 1.20.4, fabric, neoforge -- 1.21.1, fabric, neoforge -- 1.21.3, fabric, neoforge -- 1.21.4, fabric, neoforge -- 1.21.5, fabric, neoforge -- 1.21.6, fabric, neoforge -- 1.21.7, fabric, neoforge -- 1.21.8, fabric, neoforge -- 1.21.9, fabric, neoforge -- 1.21.10, fabric, neoforge -- 1.21.11, fabric, neoforge - -You can use c# script to automatically change all template names. -Open RenameTemplate.cs, change names in replacements array and run "dotnet run" in this directory -I would highly recommend to do this before opening project in your IDE, and then remove all c# related files from project -(obj and bin folders, .csproj and script itself). Also you can remove c# stuff from .gitignore (there is comment for that) - - -## Build tools usage - -To start current active version use runActive task - -For testing all versions you can use chiseledRunAllClients, it runs all possible version and loader variants (in random(?) order) - -Also template had publishing set up, you need to specify project id for modrinth and curseforge in gradle.properties, and tokens for these sites in local.properties (it is gitignored, check local.properties.example). After that use chiseledPublishMods task - -## Template usage - -Template already has some code setup: -- common and platform specific entrypoints -- ModPlatform interface for platform specific code -- example config screen with mod menu integration -- example mixin (clientside) -- class for simple file IO -- common entrypoint with logger, modid, ModPlatform object instance -- en_us lang file +The recommended IDE for this is IntelliJ IDEA 2026.1, and the JDK used is Eclipse Temurin 25.0.2 (from Adoptium), although +you should be able to use any other build of OpenJDK 26. \ No newline at end of file diff --git a/RenameTemplate.cs b/RenameTemplate.cs deleted file mode 100644 index 69bedde..0000000 --- a/RenameTemplate.cs +++ /dev/null @@ -1,60 +0,0 @@ -List FindAllFiles(string directoryPath) -{ - return Directory.GetFiles(directoryPath, "*.*", SearchOption.AllDirectories) - .Select(file => Path.GetRelativePath(directoryPath, file)) - .ToList(); -} - -var replacements = new[] -{ - //ORDER MATTERS - new { Old = "com.example", New = "io.github.cooldev" }, //change mod package - new { Old = "template", New = "coolmod" }, //change modid - new { Old = "Template", New = "Cool Mod" }, //change mod display name - // ↕ <- Letter L is different case here - new { Old = "TempLate", New = "CoolMod" }, //change mod init class and other places where mod name is in PascalCase - new { Old = "AuthorExample", New = "CoolDev" } -}; - -var files = FindAllFiles(Directory.GetCurrentDirectory()); - -foreach (var file in files) -{ - var oldFile = file.Replace("\\", "/"); - var newFile = oldFile; - Console.WriteLine("checking: " + oldFile); - - if (oldFile.StartsWith(".")) - continue; - if (oldFile.Contains(".cs")) - continue; - if (oldFile.Contains(".git")) - continue; - if (oldFile.Contains(".gradle/")) - continue; - if (oldFile.Contains("build/")) - continue; - if (oldFile.Contains("LICENSE")) - continue; - if (oldFile.Contains("bin")) - continue; - if (oldFile.Contains("obj")) - continue; - - var fileContent = File.ReadAllText(oldFile); - - foreach (var replacement in replacements) - { - fileContent = fileContent.Replace(replacement.Old, replacement.New); - newFile = newFile.Replace(replacement.Old.Replace(".", "/"), replacement.New.Replace(".", "/")); - } - Console.WriteLine($"Moving \n\t< {oldFile} \n\t> {newFile}"); - File.Delete(oldFile); - try - { - Directory.CreateDirectory(Path.GetDirectoryName(newFile)); - } - catch { } - ; - File.WriteAllText(newFile, fileContent); -} \ No newline at end of file diff --git a/Stonecutter-Arch-Template.csproj b/Stonecutter-Arch-Template.csproj deleted file mode 100644 index abff4d8..0000000 --- a/Stonecutter-Arch-Template.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net9.0 - Stonecutter_Arch_Template - enable - enable - - - diff --git a/build.gradle.kts b/build.gradle.kts index cc10e97..7296096 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ import java.util.* plugins { + kotlin("jvm") version "2.3.20" id("dev.architectury.loom") id("architectury-plugin") id("me.modmuss50.mod-publish-plugin") @@ -27,26 +28,33 @@ repositories { maven("https://maven.terraformersmc.com/") //placeholder api (modmenu depencency) maven("https://maven.nucleoid.xyz/") + maven { + name = "Kotlin for Forge" + setUrl("https://thedarkcolour.github.io/KotlinForForge/") + } } dependencies { minecraft("com.mojang:minecraft:$minecraft") mappings(loom.officialMojangMappings()) + modApi("dev.architectury:architectury:${mod.dep("architectury_version")}") if (loader == "fabric") { modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}") // mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2") modImplementation("com.terraformersmc:modmenu:${mod.dep("modmenu_version")}") - //some features (like automatic resource loading from non vanilla namespaces) work only with fabric API installed //for example translations from assets/modid/lang/en_us.json won't be working, same stuff with textures //but we keep runtime only to not accidentally depend on fabric's api, because it doesn't exist in neo/forge modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:${mod.dep("fabric_version")}") - + modImplementation("net.fabricmc:fabric-language-kotlin:1.13.10+kotlin.2.3.20") + modApi("dev.architectury:architectury-fabric:${mod.dep("architectury_version")}") } if (loader == "forge") { "forge"("net.minecraftforge:forge:${minecraft}-${mod.dep("forge_loader")}") + //implementation("thedarkcolour:kotlinforforge:1.16.0") // mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2") + modApi("dev.architectury:architectury-forge:${mod.dep("architectury_version")}") "io.github.llamalad7:mixinextras-forge:${mod.dep("mixin_extras")}".let { implementation(it) include(it) @@ -61,11 +69,17 @@ dependencies { // } // }) + modApi("dev.architectury:architectury-forge:${mod.dep("architectury_version")}") + implementation("thedarkcolour:kotlinforforge-neoforge:6.0.0") + } +} +buildscript { + dependencies { + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0") } } - loom { - accessWidenerPath = rootProject.file("src/main/resources/template.accesswidener") + accessWidenerPath = rootProject.file("src/main/resources/neocomputers.accesswidener") decompilers { get("vineflower").apply { // Adds names to lambdas - useful for mixins @@ -74,13 +88,12 @@ loom { } if (loader == "forge") { forge.mixinConfigs( - "template-common.mixins.json", - "template-forge.mixins.json", + "neocomputers-common.mixins.json", + "neocomputers-forge.mixins.json", ) } } - val localProperties = Properties() val localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { @@ -108,8 +121,12 @@ publishMods { targets.forEach(minecraftVersions::add) if (loader == "fabric") { requires("fabric-api") + requires("fabric-language-kotlin") optional("modmenu") } + if (loader == "neoforge") { + requires("kotlinforforge-neoforge") + } } curseforge { @@ -118,8 +135,12 @@ publishMods { targets.forEach(minecraftVersions::add) if (loader == "fabric") { requires("fabric-api") + requires("fabric-language-kotlin") optional("modmenu") } + if (loader == "neoforge") { + requires("kotlinforforge-neoforge") + } } } @@ -130,6 +151,11 @@ java { sourceCompatibility = java } +kotlin { + val java = if (stonecutter.eval(minecraft, ">=1.20.5")) 21 else 17 + jvmToolchain(java) +} + val shadowBundle: Configuration by configurations.creating { isCanBeConsumed = false isCanBeResolved = true diff --git a/gradle.properties b/gradle.properties index 244c8f0..2e7a830 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,9 +8,9 @@ org.gradle.parallel=false # Mod properties mod.version=1.0.0 -mod.group=com.example -mod.id=template -mod.name=Template +mod.group=org.neoflock.neocomputers +mod.id=neocomputers +mod.name=NeoComputers # Used for the mod metadata mod.mc_dep_fabric=[VERSIONED] @@ -24,6 +24,7 @@ mod.mc_targets=[VERSIONED] deps.mixin_extras=0.4.1 deps.fabric_loader=0.18.3 deps.fabric_version=[VERSIONED] +deps.architectury_version=9.1.12 deps.forge_loader=[VERSIONED] deps.neoforge_loader=[VERSIONED] diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b498d24..757bb91 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/settings.gradle.kts b/settings.gradle.kts index c6ae54b..dbdc55d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,13 +21,15 @@ stonecutter { fun mc(loader: String, vararg versions: String) { for (version in versions) vers("$version-$loader", version) } - //i would recommend to use neoforge for mc > 1.20.1, i haven't tested template for forge on versions higher than that - mc("fabric","1.20.1","1.20.4", "1.21.1", "1.21.3", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8", "1.21.9", "1.21.10", "1.21.11") - mc("forge","1.20.1") + //i would recommend to use neoforge for mc > 1.20.1, i haven't tested neocomputers for forge on versions higher than that + //mc("fabric","1.20.1","1.20.4", "1.21.1", "1.21.3", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8", "1.21.9", "1.21.10", "1.21.11") + mc("fabric", "1.20.1", "1.20.4", "1.21.9", "1.21.11") + mc("forge", "1.20.1") //WARNING: neoforge uses mods.toml instead of neoforge.mods.toml for versions 1.20.4 (?) and earlier - mc("neoforge", "1.20.4", "1.21.1", "1.21.3", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8", "1.21.9", "1.21.10", "1.21.11") + //mc("neoforge", "1.20.4", "1.21.1", "1.21.3", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8", "1.21.9", "1.21.10", "1.21.11") + mc("neoforge", "1.20.4", "1.21.9", "1.21.11") } create(rootProject) } -rootProject.name = "TempLate" \ No newline at end of file +rootProject.name = "NeoComputers" \ No newline at end of file diff --git a/src/main/java/com/example/template/TempLateInit.java b/src/main/java/com/example/template/TempLateInit.java deleted file mode 100644 index d2a11ef..0000000 --- a/src/main/java/com/example/template/TempLateInit.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example.template; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TempLateInit -{ - public static final String MODID = "template"; - public static final Logger LOGGER = LoggerFactory.getLogger("Template"); - public static ModPlatform PLATFORM = null; - - public static void entrypoint(ModPlatform platform) { - TempLateInit.PLATFORM = platform; - LOGGER.info("Started mod in %s loader".formatted(TempLateInit.PLATFORM.getModloader())); - } -} \ No newline at end of file diff --git a/src/main/java/com/example/template/ConfigScreen.java b/src/main/java/org/neoflock/neocomputers/ConfigScreen.java similarity index 95% rename from src/main/java/com/example/template/ConfigScreen.java rename to src/main/java/org/neoflock/neocomputers/ConfigScreen.java index 6e63ab5..a915df9 100644 --- a/src/main/java/com/example/template/ConfigScreen.java +++ b/src/main/java/org/neoflock/neocomputers/ConfigScreen.java @@ -1,4 +1,4 @@ -package com.example.template; +package org.neoflock.neocomputers; import net.minecraft.client.gui.GuiGraphics; diff --git a/src/main/java/com/example/template/ModPlatform.java b/src/main/java/org/neoflock/neocomputers/ModPlatform.java similarity index 84% rename from src/main/java/com/example/template/ModPlatform.java rename to src/main/java/org/neoflock/neocomputers/ModPlatform.java index 01a4649..26dc1ca 100644 --- a/src/main/java/com/example/template/ModPlatform.java +++ b/src/main/java/org/neoflock/neocomputers/ModPlatform.java @@ -1,4 +1,4 @@ -package com.example.template; +package org.neoflock.neocomputers; /** diff --git a/src/main/java/org/neoflock/neocomputers/NeoComputersInit.java b/src/main/java/org/neoflock/neocomputers/NeoComputersInit.java new file mode 100644 index 0000000..8cad8ca --- /dev/null +++ b/src/main/java/org/neoflock/neocomputers/NeoComputersInit.java @@ -0,0 +1,19 @@ +package org.neoflock.neocomputers; + +import org.neoflock.neocomputers.platforms.fabric.NeoComputersFabric; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/*public class NeoComputersInit +{ + public static final String MODID = "neocomputers"; + public static final Logger LOGGER = LoggerFactory.getLogger("NeoComputers"); + public static ModPlatform PLATFORM = null; + + public static void entrypoint(ModPlatform platform) { + NeoComputersInit.PLATFORM = platform; + LOGGER.info("Started mod in %s loader".formatted(NeoComputersInit.PLATFORM.getModloader())); + LOGGER.info("Kotlin: %s".formatted(NeoComputers.INSTANCE.hello())); + + } +}*/ \ No newline at end of file diff --git a/src/main/java/com/example/template/mixin/ExampleMixin.java b/src/main/java/org/neoflock/neocomputers/mixin/ExampleMixin.java similarity index 63% rename from src/main/java/com/example/template/mixin/ExampleMixin.java rename to src/main/java/org/neoflock/neocomputers/mixin/ExampleMixin.java index fa177eb..73c879b 100644 --- a/src/main/java/com/example/template/mixin/ExampleMixin.java +++ b/src/main/java/org/neoflock/neocomputers/mixin/ExampleMixin.java @@ -1,6 +1,6 @@ -package com.example.template.mixin; +package org.neoflock.neocomputers.mixin; -import com.example.template.TempLateInit; +import org.neoflock.neocomputers.NeoComputers; import net.minecraft.client.gui.screens.TitleScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -12,7 +12,7 @@ public class ExampleMixin { @Inject(method = "init",at=@At("HEAD")) void init(CallbackInfo ci){ - TempLateInit.LOGGER.info("Stonecutter example mixin init in %s".formatted(TempLateInit.PLATFORM.getModloader())); + NeoComputers.INSTANCE.getLOGGER().info("Stonecutter example mixin init in %s".formatted(NeoComputers.INSTANCE.getPLATFORM().getModloader())); } } diff --git a/src/main/java/com/example/template/platforms/fabric/ModMenuIntegration.java b/src/main/java/org/neoflock/neocomputers/platforms/fabric/ModMenuIntegration.java similarity index 74% rename from src/main/java/com/example/template/platforms/fabric/ModMenuIntegration.java rename to src/main/java/org/neoflock/neocomputers/platforms/fabric/ModMenuIntegration.java index c1d52d7..7c7a5d6 100644 --- a/src/main/java/com/example/template/platforms/fabric/ModMenuIntegration.java +++ b/src/main/java/org/neoflock/neocomputers/platforms/fabric/ModMenuIntegration.java @@ -1,13 +1,13 @@ //? if fabric { -/*package com.example.template.platforms.fabric; +package org.neoflock.neocomputers.platforms.fabric; import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; -import com.example.template.ConfigScreen; +import org.neoflock.neocomputers.ConfigScreen; public class ModMenuIntegration implements ModMenuApi { public ConfigScreenFactory getModConfigScreenFactory() { return ConfigScreen::createConfigScreen; } } -*///?} +//?} diff --git a/src/main/java/com/example/template/platforms/fabric/TempLateFabric.java b/src/main/java/org/neoflock/neocomputers/platforms/fabric/NeoComputersFabric.java similarity index 60% rename from src/main/java/com/example/template/platforms/fabric/TempLateFabric.java rename to src/main/java/org/neoflock/neocomputers/platforms/fabric/NeoComputersFabric.java index 0cff1ca..5503c9b 100644 --- a/src/main/java/com/example/template/platforms/fabric/TempLateFabric.java +++ b/src/main/java/org/neoflock/neocomputers/platforms/fabric/NeoComputersFabric.java @@ -1,15 +1,15 @@ //? if fabric { -/*package com.example.template.platforms.fabric; +package org.neoflock.neocomputers.platforms.fabric; -import com.example.template.ModPlatform; +import org.neoflock.neocomputers.ModPlatform; import net.fabricmc.api.ModInitializer; -import com.example.template.TempLateInit; +import org.neoflock.neocomputers.NeoComputers; import net.fabricmc.loader.api.FabricLoader; -public class TempLateFabric implements ModInitializer { +public class NeoComputersFabric implements ModInitializer { @Override public void onInitialize() { - TempLateInit.entrypoint(new FabricPlatform()); + NeoComputers.INSTANCE.entrypoint(new FabricPlatform()); } public static class FabricPlatform implements ModPlatform{ @@ -24,4 +24,4 @@ public class TempLateFabric implements ModInitializer { } } } -*///?} \ No newline at end of file +//?} \ No newline at end of file diff --git a/src/main/java/com/example/template/platforms/forge/TempLateForge.java b/src/main/java/org/neoflock/neocomputers/platforms/forge/NeoComputersForge.java similarity index 54% rename from src/main/java/com/example/template/platforms/forge/TempLateForge.java rename to src/main/java/org/neoflock/neocomputers/platforms/forge/NeoComputersForge.java index 79f799c..acd94a9 100644 --- a/src/main/java/com/example/template/platforms/forge/TempLateForge.java +++ b/src/main/java/org/neoflock/neocomputers/platforms/forge/NeoComputersForge.java @@ -1,17 +1,18 @@ //? if forge { -/*package com.example.template.platforms.forge; +/*package org.neoflock.neocomputers.neocomputers.platforms.forge; -import com.example.template.ConfigScreen; -import com.example.template.TempLateInit; -import com.example.template.ModPlatform; +import org.neoflock.neocomputers.ConfigScreen; +import org.neoflock.neocomputers.NeoComputersInit; +import org.neoflock.neocomputers.ModPlatform; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; +import org.neoflock.neocomputers.NeoComputers; -@Mod("template") -public class TempLateForge { - public TempLateForge() { - TempLateInit.entrypoint(new ForgePlatform()); +@Mod("neocomputers") +public class NeoComputersForge { + public NeoComputersForge() { + NeoComputers.INSTANCE.entrypoint(new ForgePlatform()); MinecraftForge.registerConfigScreen(ConfigScreen::createConfigScreen); } public static class ForgePlatform implements ModPlatform { diff --git a/src/main/java/com/example/template/platforms/neoforge/TempLateNeoForge.java b/src/main/java/org/neoflock/neocomputers/platforms/neoforge/NeoComputersNeoForge.java similarity index 61% rename from src/main/java/com/example/template/platforms/neoforge/TempLateNeoForge.java rename to src/main/java/org/neoflock/neocomputers/platforms/neoforge/NeoComputersNeoForge.java index f9ed3a1..385a7c6 100644 --- a/src/main/java/com/example/template/platforms/neoforge/TempLateNeoForge.java +++ b/src/main/java/org/neoflock/neocomputers/platforms/neoforge/NeoComputersNeoForge.java @@ -1,28 +1,29 @@ //? if neoforge { -package com.example.template.platforms.neoforge; +/*package org.neoflock.neocomputers.neocomputers.platforms.neoforge; -import com.example.template.ConfigScreen; -import com.example.template.TempLateInit; -import com.example.template.ModPlatform; +import org.neoflock.neocomputers.ConfigScreen; +import org.neoflock.neocomputers.NeoComputersInit; +import org.neoflock.neocomputers.ModPlatform; import net.neoforged.fml.ModList; import net.neoforged.fml.ModLoadingContext; import net.neoforged.fml.common.Mod; +import org.neoflock.neocomputers.NeoComputers; //? if <1.21 { -/*import net.neoforged.neoforge.client.ConfigScreenHandler; -*///?} else { +/^import net.neoforged.neoforge.client.ConfigScreenHandler; +^///?} else { import net.neoforged.neoforge.client.gui.IConfigScreenFactory; //?} -@Mod("template") -public class TempLateNeoForge { - public TempLateNeoForge() { - TempLateInit.entrypoint(new NeoForgePlatform()); +@Mod("neocomputers") +public class NeoComputersNeoForge { + public NeoComputersNeoForge() { + NeoComputers.INSTANCE.entrypoint(new NeoForgePlatform()); ModLoadingContext.get().registerExtensionPoint( //? if <1.21 { - /*ConfigScreenHandler.ConfigScreenFactory.class, + /^ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory( ((client, parent) -> ConfigScreen.createConfigScreen(parent)) ) - *///?} else { + ^///?} else { IConfigScreenFactory.class, () -> (client, parent) -> ConfigScreen.createConfigScreen(parent) //?} @@ -40,4 +41,4 @@ public class TempLateNeoForge { } } } -//?} \ No newline at end of file +*///?} \ No newline at end of file diff --git a/src/main/java/com/example/template/util/FileReadWrite.java b/src/main/java/org/neoflock/neocomputers/util/FileReadWrite.java similarity index 96% rename from src/main/java/com/example/template/util/FileReadWrite.java rename to src/main/java/org/neoflock/neocomputers/util/FileReadWrite.java index 3b0fa8e..463ea27 100644 --- a/src/main/java/com/example/template/util/FileReadWrite.java +++ b/src/main/java/org/neoflock/neocomputers/util/FileReadWrite.java @@ -1,4 +1,4 @@ -package com.example.template.util; +package org.neoflock.neocomputers.util; import java.io.File; import java.io.FileOutputStream; diff --git a/src/main/kotlin/org/neoflock/neocomputers/NeoComputers.kt b/src/main/kotlin/org/neoflock/neocomputers/NeoComputers.kt new file mode 100644 index 0000000..9abefdd --- /dev/null +++ b/src/main/kotlin/org/neoflock/neocomputers/NeoComputers.kt @@ -0,0 +1,19 @@ +package org.neoflock.neocomputers + +import org.slf4j.Logger +import org.slf4j.LoggerFactory + + +object NeoComputers { + const val MODID: String = "neocomputers" + val LOGGER: Logger = LoggerFactory.getLogger("NeoComputers") + var PLATFORM: ModPlatform? = null + + fun entrypoint(platform: ModPlatform?) { + PLATFORM = platform + //LOGGER.info("Started mod in %s loader".formatted(NeoComputersInit.PLATFORM.getModloader())) + //LOGGER.info("Kotlin: %s".formatted(NeoComputers.hello())) + LOGGER.info("Started mod in ${NeoComputers.PLATFORM?.modloader} loader") + LOGGER.info("Hello from kotlin!") + } +} \ No newline at end of file diff --git a/src/main/kotlin/org/neoflock/neocomputers/block/BaseBlock.kt b/src/main/kotlin/org/neoflock/neocomputers/block/BaseBlock.kt new file mode 100644 index 0000000..044edd2 --- /dev/null +++ b/src/main/kotlin/org/neoflock/neocomputers/block/BaseBlock.kt @@ -0,0 +1,14 @@ +package org.neoflock.neocomputers.block + +import net.minecraft.world.level.block.Block + +class BaseBlock : Block { + protected val tier: Int + constructor(tier: Int): super(Properties.of()) { + this.tier = tier + } + + public fun getTier(): Int { + return tier + } +} \ No newline at end of file diff --git a/src/main/kotlin/org/neoflock/neocomputers/block/Blocks.kt b/src/main/kotlin/org/neoflock/neocomputers/block/Blocks.kt new file mode 100644 index 0000000..bbcd831 --- /dev/null +++ b/src/main/kotlin/org/neoflock/neocomputers/block/Blocks.kt @@ -0,0 +1,50 @@ +package org.libreflock.neocomputers.block + +import dev.architectury.registry.registries.DeferredRegister +import dev.architectury.registry.registries.RegistrySupplier +import net.minecraft.core.registries.Registries +import net.minecraft.world.item.BlockItem +import net.minecraft.world.item.Item +import net.minecraft.world.level.block.Block +import org.libreflock.neocomputers.item.Items +import org.libreflock.neocomputers.item.Tabs +import org.neoflock.neocomputers.NeoComputers +import org.neoflock.neocomputers.block.BaseBlock +import java.util.function.Consumer +import java.util.function.Supplier + +object Blocks { + val BLOCKS: DeferredRegister = DeferredRegister.create(NeoComputers.MODID, Registries.BLOCK) + + + val CASE: MutableList?>? = + BaseBlock.register(intArrayOf(0, 1, 2), "case", { tier -> CaseBlock(tier) }) + + // public static final RegistrySupplier CASE0 = BLOCKS.register("case0", () -> new CaseBlock(0)); + // public static final RegistrySupplier CASE1 = BLOCKS.register("case1", () -> new CaseBlock(1)); + // public static final RegistrySupplier CASE2 = BLOCKS.register("case2", () -> new CaseBlock(2)); + // public static final RegistrySupplier CABLE = BLOCKS.register("cable", () -> new CableBlock()); + val SCREEN: RegistrySupplier? = BLOCKS.register("screen", Supplier { ScreenBlock() }) + val CABLE: RegistrySupplier? = BLOCKS.register("cable", Supplier { CableBlock() }) + + fun registerBlockItems() { + BLOCKS.forEach(Consumer { sup: RegistrySupplier? -> + // sup.pre + // sup.((blk) -> { + // NeoComputers.LOGGER.info(blk.getDescriptionId()); + // if (blk instanceof BaseBlock) { + // Items.ITEMS.register(sup.getId().getPath(), () -> new BaseBlock.BaseBlockItem(blk, new Item.Properties().arch$tab(Tabs.TAB))); + // } else { + // Items.ITEMS.register(sup.getId().getPath(), () -> new BlockItem(blk, new Item.Properties().arch$tab(Tabs.TAB))); + // } + // }); + Items.ITEMS.register(sup!!.getId().getPath(), { + if (sup.get() is BaseBlock) { + return@register BaseBlockItem(sup.get(), Item.Properties().`arch$tab`(Tabs.TAB)) + } else { + return@register BlockItem(sup.get(), Item.Properties().`arch$tab`(Tabs.TAB)) + } + }) + }) + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 594fbf8..44ca026 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,19 +1,19 @@ modLoader = "javafml" loaderVersion = "*" license = "LGPLv3" -issueTrackerURL="https://AuthorExample/TempLate/issues" +issueTrackerURL="https://github.com/NeoFlock/NeoComputers/issues" [[mods]] -modId = "template" +modId = "neocomputers" version = "${version}" displayName = "${name}" -authors = "AuthorExample" +authors = "NeoFlock Team" description = "" -logoFile = "assets/template/icon.png" +logoFile = "assets/neocomputers/icon.png" logoBlur = false [[mixins]] -config = "template-common.mixins.json" +config = "neocomputers-common.mixins.json" [[mixins]] -config = "template-neoforge.mixins.json" \ No newline at end of file +config = "neocomputers-neoforge.mixins.json" \ No newline at end of file diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index 594fbf8..44ca026 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -1,19 +1,19 @@ modLoader = "javafml" loaderVersion = "*" license = "LGPLv3" -issueTrackerURL="https://AuthorExample/TempLate/issues" +issueTrackerURL="https://github.com/NeoFlock/NeoComputers/issues" [[mods]] -modId = "template" +modId = "neocomputers" version = "${version}" displayName = "${name}" -authors = "AuthorExample" +authors = "NeoFlock Team" description = "" -logoFile = "assets/template/icon.png" +logoFile = "assets/neocomputers/icon.png" logoBlur = false [[mixins]] -config = "template-common.mixins.json" +config = "neocomputers-common.mixins.json" [[mixins]] -config = "template-neoforge.mixins.json" \ No newline at end of file +config = "neocomputers-neoforge.mixins.json" \ No newline at end of file diff --git a/src/main/resources/architectury.common.json b/src/main/resources/architectury.common.json index fb02a15..f9c7b9b 100644 --- a/src/main/resources/architectury.common.json +++ b/src/main/resources/architectury.common.json @@ -1,3 +1,3 @@ { - "accessWidener": "template.accesswidener" + "accessWidener": "neocomputers.accesswidener" } \ No newline at end of file diff --git a/src/main/resources/assets/neocomputers/lang/en_us.json b/src/main/resources/assets/neocomputers/lang/en_us.json new file mode 100644 index 0000000..42ba6b1 --- /dev/null +++ b/src/main/resources/assets/neocomputers/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "neocomputers.confirm": "Confirm", + "neocomputers.cancel": "Cancel" +} \ No newline at end of file diff --git a/src/main/resources/assets/template/lang/en_us.json b/src/main/resources/assets/template/lang/en_us.json deleted file mode 100644 index 9521656..0000000 --- a/src/main/resources/assets/template/lang/en_us.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "template.confirm": "Confirm", - "template.cancel": "Cancel" -} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3d4bfdc..ef52a50 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -5,7 +5,7 @@ "name": "${name}", "description": "", "authors": [ - "AuthorExample" + "NeoFlock Team" ], "contact": { }, @@ -14,18 +14,19 @@ "environment": "*", "entrypoints": { "main": [ - "com.example.template.platforms.fabric.TempLateFabric" + "org.neoflock.neocomputers.platforms.fabric.NeoComputersFabric" ], "modmenu": [ - "com.example.template.platforms.fabric.ModMenuIntegration" + "org.neoflock.neocomputers.platforms.fabric.ModMenuIntegration" ] }, "mixins": [ - "template-common.mixins.json", - "template-fabric.mixins.json" + "neocomputers-common.mixins.json", + "neocomputers-fabric.mixins.json" ], "depends": { "fabricloader": ">=0.15", - "minecraft": "${minecraft}" + "minecraft": "${minecraft}", + "fabric-language-kotlin": ">=1.13.10+kotlin.2.3.20" } } \ No newline at end of file diff --git a/src/main/resources/template-common.mixins.json b/src/main/resources/neocomputers-common.mixins.json similarity index 76% rename from src/main/resources/template-common.mixins.json rename to src/main/resources/neocomputers-common.mixins.json index 3151072..5a9e264 100644 --- a/src/main/resources/template-common.mixins.json +++ b/src/main/resources/neocomputers-common.mixins.json @@ -1,6 +1,6 @@ { "required": true, - "package": "com.example.template.mixin", + "package": "org.neoflock.neocomputers.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ ], diff --git a/src/main/resources/template-neoforge.mixins.json b/src/main/resources/neocomputers-fabric.mixins.json similarity index 65% rename from src/main/resources/template-neoforge.mixins.json rename to src/main/resources/neocomputers-fabric.mixins.json index 0737e54..7429092 100644 --- a/src/main/resources/template-neoforge.mixins.json +++ b/src/main/resources/neocomputers-fabric.mixins.json @@ -1,6 +1,6 @@ { "required": true, - "package": "com.example.template.platforms.neoforge.mixin", + "package": "org.neoflock.neocomputers.platforms.fabric.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ ], diff --git a/src/main/resources/template-fabric.mixins.json b/src/main/resources/neocomputers-forge.mixins.json similarity index 65% rename from src/main/resources/template-fabric.mixins.json rename to src/main/resources/neocomputers-forge.mixins.json index 826a776..1d3ec20 100644 --- a/src/main/resources/template-fabric.mixins.json +++ b/src/main/resources/neocomputers-forge.mixins.json @@ -1,6 +1,6 @@ { "required": true, - "package": "com.example.template.platforms.fabric.mixin", + "package": "org.neoflock.neocomputers.platforms.forge.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ ], diff --git a/src/main/resources/template-forge.mixins.json b/src/main/resources/neocomputers-neoforge.mixins.json similarity index 64% rename from src/main/resources/template-forge.mixins.json rename to src/main/resources/neocomputers-neoforge.mixins.json index 589b22e..3f49d19 100644 --- a/src/main/resources/template-forge.mixins.json +++ b/src/main/resources/neocomputers-neoforge.mixins.json @@ -1,6 +1,6 @@ { "required": true, - "package": "com.example.template.platforms.forge.mixin", + "package": "org.neoflock.neocomputers.platforms.neoforge.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ ], diff --git a/src/main/resources/template.accesswidener b/src/main/resources/neocomputers.accesswidener similarity index 100% rename from src/main/resources/template.accesswidener rename to src/main/resources/neocomputers.accesswidener diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts index 503f51a..5eb2f92 100644 --- a/stonecutter.gradle.kts +++ b/stonecutter.gradle.kts @@ -5,7 +5,7 @@ plugins { id("com.gradleup.shadow") version "9.3.0" apply false id("me.modmuss50.mod-publish-plugin") version "0.8.4" apply false } -stonecutter active "1.21.9-neoforge" /* [SC] DO NOT EDIT */ +stonecutter active "1.21.9-fabric" /* [SC] DO NOT EDIT */ stonecutter.automaticPlatformConstants = true // Builds every version into `build/libs/{mod.version}/{loader}`