diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1d5b5b7..45e3496 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,4 +9,4 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "weekly" + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/ci_push.yml b/.github/workflows/build.yml similarity index 97% rename from .github/workflows/ci_push.yml rename to .github/workflows/build.yml index 8d1410b..7a6565a 100644 --- a/.github/workflows/ci_push.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: CI (Push) +name: Build on: push: @@ -31,7 +31,7 @@ jobs: run: chmod +x gradlew - name: Build and Test - run: ./gradlew build test + run: ./gradlew build test spotlessCheck publish: name: Publish @@ -84,7 +84,7 @@ jobs: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SECRET_KEY }} ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.PGP_KEY_ID }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PGP_KEY_PASSPHRASE }} - run: ./gradlew build :NeoForge:modrinth :NeoForge:modrinthSyncBody + run: ./gradlew build modrinth modrinthSyncBody - name: Publish to GitHub env: diff --git a/.github/workflows/pullrequest-build.yml b/.github/workflows/pullrequest-build.yml new file mode 100644 index 0000000..0604659 --- /dev/null +++ b/.github/workflows/pullrequest-build.yml @@ -0,0 +1,30 @@ +name: Build, Test, and Check (Pull Request) + +on: + pull_request: + +jobs: + build: + name: Build, Test, and Check + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Validate Wrapper + uses: gradle/actions/wrapper-validation@v3 + + - name: Set Gradle Wrapper Executable + run: chmod +x gradlew + + - name: Build, Test, and Check + run: ./gradlew build test spotlessCheck \ No newline at end of file diff --git a/.gitignore b/.gitignore index dd3b7dc..e91629a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,5 @@ -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ - -### IntelliJ IDEA ### +.gradle/ .idea/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store - -### Loader Runs ### -/NeoForge/runs/ -/Quilt/runs/ +.kotlin/ +build/ +runs/ diff --git a/Common/build.gradle.kts b/Common/build.gradle.kts deleted file mode 100644 index 65bdbe4..0000000 --- a/Common/build.gradle.kts +++ /dev/null @@ -1,12 +0,0 @@ -plugins { - alias(libs.plugins.dokka) - alias(libs.plugins.ml.common) -} - -dependencies { - implementation(libs.logging) -} - -kotlin { - explicitApi() -} diff --git a/Common/src/main/kotlin/ModRuntime.kt b/Common/src/main/kotlin/ModRuntime.kt deleted file mode 100644 index e332cd4..0000000 --- a/Common/src/main/kotlin/ModRuntime.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek - -import net.minecraft.core.BlockPos -import com.mojang.datafixers.types.Type as DFUType -import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.entity.BlockEntityType -import net.minecraft.world.level.block.state.BlockState -import java.util.* - -public interface ModRuntime { - public val runtimeName: String - public fun isModLoaded(modId: String): Boolean - public fun isDevEnv(): Boolean - - public fun createBlockEntityType( - vararg blocks: Block, - dfuType: DFUType<*>? = null, - factory: (BlockPos, BlockState) -> T - ): BlockEntityType - - public companion object { - public val instance: ModRuntime = - ServiceLoader.load(ModRuntime::class.java).stream().toList().firstOrNull()?.get() - ?: throw IllegalStateException("Could not find an implementation of ${ModRuntime::class.java.name}") - } -} diff --git a/Common/src/main/kotlin/PyTekCore.kt b/Common/src/main/kotlin/PyTekCore.kt deleted file mode 100644 index 7a59107..0000000 --- a/Common/src/main/kotlin/PyTekCore.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek - -import io.github.oshai.kotlinlogging.KLogger -import io.github.oshai.kotlinlogging.KotlinLogging -import kotlin.system.measureTimeMillis - -public val logger: KLogger = KotlinLogging.logger { } -public const val TAG: String = "[PyTek]" - -public object PyTekCore { - public fun init(block: () -> Unit) { - logger.info { "$TAG Initializing..." } - val initMs = measureTimeMillis { - logger.info { "$TAG Running on ${ModRuntime.instance.runtimeName} in ${if(ModRuntime.instance.isDevEnv()) "dev" else "prod"}" } - block() - } - logger.info { "$TAG Initialized. (Took ${initMs}ms)" } - } -} diff --git a/Common/src/main/kotlin/blocks/CableBlock.kt b/Common/src/main/kotlin/blocks/CableBlock.kt deleted file mode 100644 index b873676..0000000 --- a/Common/src/main/kotlin/blocks/CableBlock.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.blocks - -import gay.pyrrha.pytek.blocks.entity.CableBlockEntity -import net.minecraft.core.BlockPos -import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.Blocks -import net.minecraft.world.level.block.EntityBlock -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.state.BlockState - -public class CableBlock : Block(Properties.ofFullCopy(Blocks.IRON_BLOCK)), EntityBlock { - override fun newBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = CableBlockEntity(pos, state) -} diff --git a/Common/src/main/kotlin/blocks/ModBlocks.kt b/Common/src/main/kotlin/blocks/ModBlocks.kt deleted file mode 100644 index 14edd52..0000000 --- a/Common/src/main/kotlin/blocks/ModBlocks.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.blocks - -import gay.pyrrha.pytek.rl -import net.minecraft.core.registries.BuiltInRegistries -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.item.BlockItem -import net.minecraft.world.item.Item -import net.minecraft.world.level.block.Block - -public object ModBlocks { - public val REACTOR_CONTROLLER: ReactorControllerBlock by lazy { ReactorControllerBlock() } - public val CABLE: CableBlock by lazy { CableBlock() } - - public fun init(register: (rl: ResourceLocation, block: Block) -> Unit) { - register(rl("reactor_controller"), REACTOR_CONTROLLER) - register(rl("cable"), CABLE) - } - - public fun initBlockItems(register: (rl: ResourceLocation, item: Item) -> Unit) { - val defaultProps = Item.Properties() - - fun registerDefault(block: Block) = - register(BuiltInRegistries.BLOCK.getKey(block), BlockItem(block, defaultProps)) - - registerDefault(REACTOR_CONTROLLER) - registerDefault(CABLE) - } -} diff --git a/Common/src/main/kotlin/blocks/ReactorControllerBlock.kt b/Common/src/main/kotlin/blocks/ReactorControllerBlock.kt deleted file mode 100644 index 5758b4c..0000000 --- a/Common/src/main/kotlin/blocks/ReactorControllerBlock.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.blocks - -import com.mojang.serialization.MapCodec -import gay.pyrrha.pytek.blocks.entity.ReactorControllerBlockEntity -import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.Blocks -import net.minecraft.world.level.block.EntityBlock -import net.minecraft.world.level.block.HorizontalDirectionalBlock -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.state.BlockBehaviour -import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.block.state.properties.DirectionProperty - -public class ReactorControllerBlock : HorizontalDirectionalBlock( - Properties.ofFullCopy(Blocks.IRON_BLOCK) -), EntityBlock { - init { - registerDefaultState(stateDefinition.any().setValue(FACING, Direction.NORTH)) - } - - override fun createBlockStateDefinition(builder: StateDefinition.Builder) { - builder.add(FACING) - } - - override fun codec(): MapCodec = - MapCodec.unit(::ReactorControllerBlock) - - override fun newBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = - ReactorControllerBlockEntity(pos, state) - - public companion object { - public val FACING: DirectionProperty = HorizontalDirectionalBlock.FACING - - } -} diff --git a/Common/src/main/kotlin/blocks/entity/CableBlockEntity.kt b/Common/src/main/kotlin/blocks/entity/CableBlockEntity.kt deleted file mode 100644 index ffac0d4..0000000 --- a/Common/src/main/kotlin/blocks/entity/CableBlockEntity.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.blocks.entity - -import net.minecraft.core.BlockPos -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.state.BlockState - -public class CableBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(ModBlockEntities.CABLE, pos, state) { -} \ No newline at end of file diff --git a/Common/src/main/kotlin/blocks/entity/ModBlockEntities.kt b/Common/src/main/kotlin/blocks/entity/ModBlockEntities.kt deleted file mode 100644 index 68dd5c1..0000000 --- a/Common/src/main/kotlin/blocks/entity/ModBlockEntities.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.blocks.entity - -import gay.pyrrha.pytek.ModRuntime -import gay.pyrrha.pytek.blocks.ModBlocks -import gay.pyrrha.pytek.rl -import net.minecraft.core.BlockPos -import com.mojang.datafixers.types.Type as DFUType -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.entity.BlockEntityType -import net.minecraft.world.level.block.state.BlockState - -public object ModBlockEntities { - public val REACTOR_CONTROLLER: BlockEntityType by lazy { - create(ModBlocks.REACTOR_CONTROLLER, factory = ::ReactorControllerBlockEntity) - } - - public val CABLE: BlockEntityType by lazy { - create(ModBlocks.CABLE, factory = ::CableBlockEntity) - } - - private fun create( - vararg blocks: Block, - dfuType: DFUType<*>? = null, - factory: (BlockPos, BlockState) -> T - ): BlockEntityType = ModRuntime.instance.createBlockEntityType(*blocks, dfuType = dfuType, factory = factory) - - public fun init(register: (ResourceLocation, BlockEntityType<*>) -> Unit) { - register(rl("reactor_controller"), REACTOR_CONTROLLER) - register(rl("cable"), CABLE) - } -} diff --git a/Common/src/main/kotlin/blocks/entity/ReactorControllerBlockEntity.kt b/Common/src/main/kotlin/blocks/entity/ReactorControllerBlockEntity.kt deleted file mode 100644 index 70fce3d..0000000 --- a/Common/src/main/kotlin/blocks/entity/ReactorControllerBlockEntity.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.blocks.entity - -import net.minecraft.core.BlockPos -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.state.BlockState - -public class ReactorControllerBlockEntity( - pos: BlockPos, - state: BlockState -) : BlockEntity(ModBlockEntities.REACTOR_CONTROLLER, pos, state) { - -} \ No newline at end of file diff --git a/Common/src/main/kotlin/datagen/lang/CustomLanguageProvider.kt b/Common/src/main/kotlin/datagen/lang/CustomLanguageProvider.kt deleted file mode 100644 index 97610cf..0000000 --- a/Common/src/main/kotlin/datagen/lang/CustomLanguageProvider.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.datagen.lang - -import net.minecraft.tags.TagKey -import net.minecraft.world.effect.MobEffect -import net.minecraft.world.entity.EntityType -import net.minecraft.world.item.Item -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.enchantment.Enchantment -import net.minecraft.world.level.block.Block - -public typealias AddFunc = (T, String) -> Unit - -public interface CustomLanguageProvider { - public fun provide( - addBlock: AddFunc, - addItem: AddFunc, - addItemStack: AddFunc, - addEnchantment: AddFunc, - addEffect: AddFunc, - addEntity: AddFunc>, - addTag: AddFunc>, - addString: AddFunc - ) -} diff --git a/Common/src/main/kotlin/datagen/lang/EnUsLanguageProvider.kt b/Common/src/main/kotlin/datagen/lang/EnUsLanguageProvider.kt deleted file mode 100644 index d18df69..0000000 --- a/Common/src/main/kotlin/datagen/lang/EnUsLanguageProvider.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.datagen.lang - -import gay.pyrrha.pytek.MOD_ID -import gay.pyrrha.pytek.blocks.ModBlocks -import net.minecraft.tags.TagKey -import net.minecraft.world.effect.MobEffect -import net.minecraft.world.entity.EntityType -import net.minecraft.world.item.Item -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.enchantment.Enchantment -import net.minecraft.world.level.block.Block - -public object EnUsLanguageProvider : CustomLanguageProvider { - override fun provide( - addBlock: AddFunc, - addItem: AddFunc, - addItemStack: AddFunc, - addEnchantment: AddFunc, - addEffect: AddFunc, - addEntity: AddFunc>, - addTag: AddFunc>, - addString: AddFunc - ) { - // Blocks - addBlock(ModBlocks.REACTOR_CONTROLLER, "Reactor Controller") - addBlock(ModBlocks.CABLE, "Cable") - } -} diff --git a/Common/src/main/resources/assets/pytek/textures/block/cable.png b/Common/src/main/resources/assets/pytek/textures/block/cable.png deleted file mode 100644 index 7b876f0..0000000 Binary files a/Common/src/main/resources/assets/pytek/textures/block/cable.png and /dev/null differ diff --git a/Common/src/main/resources/assets/pytek/textures/block/reactor_controller_front.png b/Common/src/main/resources/assets/pytek/textures/block/reactor_controller_front.png deleted file mode 100644 index 3de938d..0000000 Binary files a/Common/src/main/resources/assets/pytek/textures/block/reactor_controller_front.png and /dev/null differ diff --git a/Common/src/main/resources/assets/pytek/textures/block/reactor_controller_side.png b/Common/src/main/resources/assets/pytek/textures/block/reactor_controller_side.png deleted file mode 100644 index 9aa92cc..0000000 Binary files a/Common/src/main/resources/assets/pytek/textures/block/reactor_controller_side.png and /dev/null differ diff --git a/Common/src/main/resources/assets/pytek/textures/block/reactor_controller_top.png b/Common/src/main/resources/assets/pytek/textures/block/reactor_controller_top.png deleted file mode 100644 index 4b7bcc9..0000000 Binary files a/Common/src/main/resources/assets/pytek/textures/block/reactor_controller_top.png and /dev/null differ diff --git a/Common/src/main/resources/pack.mcmeta b/Common/src/main/resources/pack.mcmeta deleted file mode 100644 index e8d45ba..0000000 --- a/Common/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "pack_format": 22, - "description": "PyTek" - } -} \ No newline at end of file diff --git a/Common/src/main/resources/pytek.png b/Common/src/main/resources/pytek.png deleted file mode 100644 index a8112e6..0000000 Binary files a/Common/src/main/resources/pytek.png and /dev/null differ diff --git a/HEADER b/HEADER index c9091ef..c024341 100644 --- a/HEADER +++ b/HEADER @@ -1,7 +1,7 @@ -Copyright (C) ${YEAR} Pyrrha Wills - All Rights Reserved - -This Source Code Form is subject to the terms of the Mozilla Public -License, v. 2.0. If a copy of the MPL was not distributed with this -file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#type YEAR YEAR_LENIENT_RANGE \ No newline at end of file +/* + * Copyright (C) $YEAR Pyrrha Wills - All Rights Reserved + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ \ No newline at end of file diff --git a/NeoForge/build.gradle.kts b/NeoForge/build.gradle.kts deleted file mode 100644 index 56230b2..0000000 --- a/NeoForge/build.gradle.kts +++ /dev/null @@ -1,125 +0,0 @@ -import gay.pyrrha.build.* -import org.jetbrains.changelog.Changelog - -plugins { - alias(libs.plugins.changelog) - alias(libs.plugins.dokka) - alias(libs.plugins.ml.runtime) - alias(libs.plugins.neoforge.userdev) - alias(libs.plugins.minotaur) - - id("gay.pyrrha.build.kotlin-forge-runtime-library") -} - -base.archivesName.set("PyTek-NeoForge") - -val modId = "pytek" -val generatedResourcesDir = "src/generated/resources" - -runs { - - configureEach { - // SCAN, REGISTRIES, REGISTRYDUMP - systemProperty("forge.logging.markers", "SCAN") - systemProperties("forge.logging.console.level", "debug") - - modSource(sourceSets.main.get()) - } - - val client by creating { - systemProperty("forge.enabledGameTestNamespaces", modId) - } - - val server by creating { - systemProperty("forge.enabledGameTestNamespaces", modId) - programArguments("--nogui") - } - - val gameTestServer by creating { - systemProperty("forge.enabledGameTestNamespaces", modId) - } - - val data by creating { - programArguments( - "--mod", modId, - "--all", - "--output", file(generatedResourcesDir).absolutePath, - "--existing", file(generatedResourcesDir).absolutePath - ) - } -} - -sourceSets { - main { - resources { - srcDir(generatedResourcesDir) - } - } -} - -repositories { - maven("https://thedarkcolour.github.io/KotlinForForge/") { - name = "KotlinForForge" - content { includeGroup("thedarkcolour") } - } -} - -jarJar.enable() -dependencies { - implementation(libs.neoforge) - implementation(libs.neoforge.kotlin) - - includeApi(libs.logging) -} - -fun DependencyHandlerScope.includeApi(dependency: Provider<*>) { - api(dependency) - jarJar(dependency) { isTransitive = false } - kotlinForgeRuntimeLibrary(dependency) -} - -kotlin { - explicitApi() -} - -tasks { - jarJar.configure { - archiveClassifier = "" - } - - jar { - archiveClassifier = "slim" - } - - assemble { - dependsOn(jarJar) - } -} - -modrinth { - token = System.getenv("MODRINTH_TOKEN") - debugMode = System.getenv("MODRINTH_DEBUG") == "1" - projectId = "pytek" - versionNumber = project.version.toString() - versionType = with(project.version.toString()) { - when { - contains("alpha") -> "alpha" - contains("beta") -> "beta" - else -> "release" - } - } - uploadFile.set(tasks.jarJar) - additionalFiles.set(listOf(tasks.sourcesJar)) - gameVersions = listOf(libs.versions.minecraft.get()) - dependencies { - required.project("kotlin-for-forge") - } - changelog = rootProject.changelog.renderItem( - rootProject.changelog - .getUnreleased() - .withEmptySections(false) - .withHeader(false), - Changelog.OutputType.MARKDOWN - ) - syncBodyFrom = rootProject.file("README.md").readText() -} diff --git a/NeoForge/src/generated/resources/.cache/9a6b12ec3a252ea4fb4c43de3137d9afd48c78f9 b/NeoForge/src/generated/resources/.cache/9a6b12ec3a252ea4fb4c43de3137d9afd48c78f9 deleted file mode 100644 index 7d4558d..0000000 --- a/NeoForge/src/generated/resources/.cache/9a6b12ec3a252ea4fb4c43de3137d9afd48c78f9 +++ /dev/null @@ -1,5 +0,0 @@ -// 1.20.6 2024-05-21T18:09:35.3845887 Block States: pytek -ee1bd483000211be364a9e018c7aa38feba51253 assets/pytek/blockstates/cable.json -97016aef4bb24b3a96e7e261a29c96aad174c232 assets/pytek/blockstates/reactor_controller.json -784e7e9571f8227d8fcbabf4450ed7b802a23938 assets/pytek/models/block/cable.json -f198943b56efb51eca77bb6c009198fbbec745ec assets/pytek/models/block/reactor_controller.json diff --git a/NeoForge/src/generated/resources/.cache/adb2ff1a95d6e97cd17a7fe1d53fecaad9477506 b/NeoForge/src/generated/resources/.cache/adb2ff1a95d6e97cd17a7fe1d53fecaad9477506 deleted file mode 100644 index bcd2fee..0000000 --- a/NeoForge/src/generated/resources/.cache/adb2ff1a95d6e97cd17a7fe1d53fecaad9477506 +++ /dev/null @@ -1,2 +0,0 @@ -// 1.20.6 2024-05-21T17:04:30.4732606 Languages: en_us for mod: pytek -298620d97229bcded922d1d12351bc83d29d59d9 assets/pytek/lang/en_us.json diff --git a/NeoForge/src/generated/resources/assets/pytek/blockstates/cable.json b/NeoForge/src/generated/resources/assets/pytek/blockstates/cable.json deleted file mode 100644 index 19f7173..0000000 --- a/NeoForge/src/generated/resources/assets/pytek/blockstates/cable.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "variants": { - "": { - "model": "pytek:block/cable" - } - } -} \ No newline at end of file diff --git a/NeoForge/src/generated/resources/assets/pytek/blockstates/reactor_controller.json b/NeoForge/src/generated/resources/assets/pytek/blockstates/reactor_controller.json deleted file mode 100644 index 72ef382..0000000 --- a/NeoForge/src/generated/resources/assets/pytek/blockstates/reactor_controller.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "variants": { - "facing=east": { - "model": "pytek:block/reactor_controller", - "y": 90 - }, - "facing=north": { - "model": "pytek:block/reactor_controller" - }, - "facing=south": { - "model": "pytek:block/reactor_controller", - "y": 180 - }, - "facing=west": { - "model": "pytek:block/reactor_controller", - "y": 270 - } - } -} \ No newline at end of file diff --git a/NeoForge/src/generated/resources/assets/pytek/lang/en_us.json b/NeoForge/src/generated/resources/assets/pytek/lang/en_us.json deleted file mode 100644 index 8c52191..0000000 --- a/NeoForge/src/generated/resources/assets/pytek/lang/en_us.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "block.pytek.cable": "Cable", - "block.pytek.reactor_controller": "Reactor Controller" -} \ No newline at end of file diff --git a/NeoForge/src/generated/resources/assets/pytek/models/block/cable.json b/NeoForge/src/generated/resources/assets/pytek/models/block/cable.json deleted file mode 100644 index 308f7fe..0000000 --- a/NeoForge/src/generated/resources/assets/pytek/models/block/cable.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:block/cube_all", - "textures": { - "all": "pytek:block/cable" - } -} \ No newline at end of file diff --git a/NeoForge/src/generated/resources/assets/pytek/models/block/reactor_controller.json b/NeoForge/src/generated/resources/assets/pytek/models/block/reactor_controller.json deleted file mode 100644 index a12e5cf..0000000 --- a/NeoForge/src/generated/resources/assets/pytek/models/block/reactor_controller.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "minecraft:block/orientable", - "textures": { - "front": "pytek:block/reactor_controller_front", - "side": "pytek:block/reactor_controller_side", - "top": "pytek:block/reactor_controller_top" - } -} \ No newline at end of file diff --git a/NeoForge/src/main/kotlin/ModRuntimeNeoForge.kt b/NeoForge/src/main/kotlin/ModRuntimeNeoForge.kt deleted file mode 100644 index c606a6a..0000000 --- a/NeoForge/src/main/kotlin/ModRuntimeNeoForge.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.neoforge - -import com.mojang.datafixers.types.Type -import gay.pyrrha.pytek.ModRuntime -import net.minecraft.core.BlockPos -import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.entity.BlockEntityType -import net.minecraft.world.level.block.state.BlockState -import net.neoforged.fml.ModList -import net.neoforged.fml.loading.FMLLoader - -public class ModRuntimeNeoForge : ModRuntime { - override val runtimeName: String - get() = "NeoForge" - - override fun isModLoaded(modId: String): Boolean = - ModList.get().isLoaded(modId) - - override fun isDevEnv(): Boolean = - FMLLoader.isProduction().not() - - override fun createBlockEntityType( - vararg blocks: Block, - dfuType: Type<*>?, - factory: (BlockPos, BlockState) -> T - ): BlockEntityType { - @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // for dfuType - return BlockEntityType.Builder.of(factory, *blocks).build(dfuType) - } -} diff --git a/NeoForge/src/main/kotlin/PyTekNeoForge.kt b/NeoForge/src/main/kotlin/PyTekNeoForge.kt deleted file mode 100644 index 81d8cbc..0000000 --- a/NeoForge/src/main/kotlin/PyTekNeoForge.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.neoforge - -import gay.pyrrha.pytek.MOD_ID -import gay.pyrrha.pytek.PyTekCore -import gay.pyrrha.pytek.blocks.ModBlocks -import gay.pyrrha.pytek.blocks.entity.ModBlockEntities -import net.minecraft.core.Registry -import net.minecraft.core.registries.Registries -import net.minecraft.resources.ResourceKey -import net.minecraft.resources.ResourceLocation -import net.neoforged.bus.api.IEventBus -import net.neoforged.fml.ModContainer -import net.neoforged.fml.common.Mod -import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent -import net.neoforged.neoforge.registries.RegisterEvent - -@Mod(MOD_ID) -public class PyTekNeoForge(private val modEventBus: IEventBus, modContainer: ModContainer) { - - private fun bindRegistry(registry: ResourceKey>, source: ((ResourceLocation, T) -> Unit) -> Unit) { - modEventBus.addListener { event -> - if (event.registryKey == registry) { - source { rl, t -> event.register(registry, rl) { t } } - } - } - } - - init { - registryInit() - modEventBus.addListener(::commonSetup) - } - - private fun registryInit() { - bindRegistry(Registries.BLOCK, ModBlocks::init) - bindRegistry( - Registries.ITEM, - ModBlocks::initBlockItems - ) // todo(py, 20/05/2024): Add BlockItems to a creative tab. - bindRegistry(Registries.BLOCK_ENTITY_TYPE, ModBlockEntities::init) - } - - private fun commonSetup(event: FMLCommonSetupEvent) { - PyTekCore.init { } - } -} diff --git a/NeoForge/src/main/kotlin/datagen/NeoBlockStateDataProvider.kt b/NeoForge/src/main/kotlin/datagen/NeoBlockStateDataProvider.kt deleted file mode 100644 index 3c0ecd1..0000000 --- a/NeoForge/src/main/kotlin/datagen/NeoBlockStateDataProvider.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.neoforge.datagen - -import gay.pyrrha.pytek.MOD_ID -import gay.pyrrha.pytek.blocks.ModBlocks -import gay.pyrrha.pytek.rl -import net.minecraft.data.PackOutput -import net.neoforged.neoforge.client.model.generators.BlockStateProvider -import net.neoforged.neoforge.common.data.ExistingFileHelper - -// todo(py, 21/05/2024): make this platform non-specific -public class NeoBlockStateDataProvider( - output: PackOutput, - exFileHelper: ExistingFileHelper -) : BlockStateProvider(output, MOD_ID, exFileHelper) { - override fun registerStatesAndModels() { - horizontalBlock( - ModBlocks.REACTOR_CONTROLLER, - rl("block/reactor_controller_side"), - rl("block/reactor_controller_front"), - rl("block/reactor_controller_top") - ) - - simpleBlock(ModBlocks.CABLE) - } -} diff --git a/NeoForge/src/main/kotlin/datagen/NeoForgeDataGenerator.kt b/NeoForge/src/main/kotlin/datagen/NeoForgeDataGenerator.kt deleted file mode 100644 index 9302457..0000000 --- a/NeoForge/src/main/kotlin/datagen/NeoForgeDataGenerator.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.neoforge.datagen - -import gay.pyrrha.pytek.MOD_ID -import net.neoforged.bus.api.SubscribeEvent -import net.neoforged.fml.common.EventBusSubscriber -import net.neoforged.neoforge.common.data.ExistingFileHelper -import net.neoforged.neoforge.data.event.GatherDataEvent - -@EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD) -public object NeoForgeDataGenerator { - @SubscribeEvent - private fun gatherData(event: GatherDataEvent) { - val generator = event.generator - val output = generator.packOutput - val disabledExistingFileHelper = ExistingFileHelper(emptyList(), emptySet(), false, null, null) - - generator.addProvider(event.includeServer(), NeoUSEnglishLanguageDataProvider(output)) - generator.addProvider(event.includeServer(), NeoBlockStateDataProvider(output, disabledExistingFileHelper)) - } -} diff --git a/NeoForge/src/main/kotlin/datagen/NeoUSEnglishLanguageDataProvider.kt b/NeoForge/src/main/kotlin/datagen/NeoUSEnglishLanguageDataProvider.kt deleted file mode 100644 index beabb9c..0000000 --- a/NeoForge/src/main/kotlin/datagen/NeoUSEnglishLanguageDataProvider.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package gay.pyrrha.pytek.neoforge.datagen - -import gay.pyrrha.pytek.MOD_ID -import gay.pyrrha.pytek.datagen.lang.EnUsLanguageProvider -import net.minecraft.data.PackOutput -import net.neoforged.neoforge.common.data.LanguageProvider - -public class NeoUSEnglishLanguageDataProvider(output: PackOutput) : LanguageProvider(output, MOD_ID, "en_us") { - override fun addTranslations() { - EnUsLanguageProvider.provide(::add, ::add, ::add, ::add, ::add, ::add, ::add, ::add) - } -} diff --git a/NeoForge/src/main/resources/META-INF/neoforge.mods.toml b/NeoForge/src/main/resources/META-INF/neoforge.mods.toml deleted file mode 100644 index 315189b..0000000 --- a/NeoForge/src/main/resources/META-INF/neoforge.mods.toml +++ /dev/null @@ -1,39 +0,0 @@ -modLoader="kotlinforforge" #mandatory -loaderVersion="[5.1,)" #mandatory -license="MPL-2.0" -issueTrackerURL="https://github.com/JustPyrrha/PyTek/issues" #optional - -[[mods]] #mandatory -modId="pytek" #mandatory -version="0.1.0-alpha.0" #mandatory -displayName="PyTek" #mandatory -updateJSONURL="https://api.modrinth.com/updates/pytek/forge_updates.json" #optional -displayURL="https://github.com/JustPyrrha/PyTek/" #optional -logoFile="pytek.png" #optional -#credits="" #optional -authors="JustPyrrha" #optional -description='''beep boop''' #mandatory -#displayTest="MATCH_VERSION" #optional - -#[[mixins]] -#config="pytek.mixins.json" - -#[[accessTransformers]] -#file="META-INF/accesstransformer.cfg" - -[[dependencies.pytek]] #optional -modId="neoforge" #mandatory -type="required" #mandatory -versionRange="[20.6,)" #mandatory -ordering="NONE" -side="BOTH" - -[[dependencies.pytek]] -modId="minecraft" -type="required" -versionRange="[1.20.6,1.21)" -ordering="NONE" -side="BOTH" - -#[features.pytek] -#openGLVersion="[3.2,)" diff --git a/NeoForge/src/main/resources/META-INF/services/gay.pyrrha.pytek.ModRuntime b/NeoForge/src/main/resources/META-INF/services/gay.pyrrha.pytek.ModRuntime deleted file mode 100644 index 99fc2b7..0000000 --- a/NeoForge/src/main/resources/META-INF/services/gay.pyrrha.pytek.ModRuntime +++ /dev/null @@ -1 +0,0 @@ -gay.pyrrha.pytek.neoforge.ModRuntimeNeoForge \ No newline at end of file diff --git a/README.md b/README.md index 01dbae1..fded2c4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- PyTek
+ PyTek
PyTek @@ -17,4 +17,5 @@

---- \ No newline at end of file +--- + diff --git a/artSrc/block/cable.aseprite b/artSrc/block/cable.aseprite deleted file mode 100644 index 092e22c..0000000 Binary files a/artSrc/block/cable.aseprite and /dev/null differ diff --git a/artSrc/block/reactor_controller/front.aseprite b/artSrc/block/reactor_controller/front.aseprite deleted file mode 100644 index 926a7b5..0000000 Binary files a/artSrc/block/reactor_controller/front.aseprite and /dev/null differ diff --git a/artSrc/block/reactor_controller/side.aseprite b/artSrc/block/reactor_controller/side.aseprite deleted file mode 100644 index ded4aaf..0000000 Binary files a/artSrc/block/reactor_controller/side.aseprite and /dev/null differ diff --git a/artSrc/block/reactor_controller/top.aseprite b/artSrc/block/reactor_controller/top.aseprite deleted file mode 100644 index 194ff02..0000000 Binary files a/artSrc/block/reactor_controller/top.aseprite and /dev/null differ diff --git a/build.gradle.kts b/build.gradle.kts index a1d8acd..fcb1525 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,5 @@ -import dev.yumi.gradle.licenser.YumiLicenserGradleExtension +import java.util.Base64 +import org.jetbrains.changelog.Changelog import org.jetbrains.changelog.ChangelogPluginConstants.SEM_VER_REGEX import org.jetbrains.changelog.date import org.jetbrains.dokka.base.DokkaBase @@ -7,25 +8,18 @@ import org.jetbrains.dokka.versioning.VersioningConfiguration import org.jetbrains.dokka.versioning.VersioningPlugin plugins { - alias(libs.plugins.changelog) - alias(libs.plugins.dokka) - alias(libs.plugins.githooks) - - alias(libs.plugins.idea.ext) apply false - alias(libs.plugins.kotlin.jvm) apply false - alias(libs.plugins.kotlin.serialization) apply false + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlin.serialization) - alias(libs.plugins.licenser) apply false - alias(libs.plugins.minotaur) apply false + alias(libs.plugins.loom) - alias(libs.plugins.neoforge.userdev) apply false - alias(libs.plugins.quilt.loom) apply false + alias(libs.plugins.dokka) + alias(libs.plugins.changelog) + alias(libs.plugins.minotaur) + alias(libs.plugins.spotless) - alias(libs.plugins.ml.internal.jvm) apply false - alias(libs.plugins.ml.internal.loom) apply false - alias(libs.plugins.ml.internal.mod) apply false - alias(libs.plugins.ml.common) apply false - alias(libs.plugins.ml.runtime) apply false + signing + `maven-publish` } buildscript { @@ -35,42 +29,44 @@ buildscript { } } -allprojects { - group = "gay.pyrrha" - version = "1.0.0-alpha.0+${rootProject.libs.versions.minecraft.get()}" - repositories { - mavenCentral() - } -} +group = "gay.pyrrha" -subprojects { - apply(plugin = rootProject.libs.plugins.licenser.get().pluginId) - extensions.configure { - rule(rootProject.file("HEADER")) - include("**/*.kt") - include("**/*.java") - } -} +version = "1.0.0-alpha.0+${libs.versions.minecraft.get()}" -changelog { - version = project.version.toString() - path = rootProject.file("CHANGELOG.md").canonicalPath - header = provider { "[${project.version}] - ${date()}" } - headerParserRegex = SEM_VER_REGEX - itemPrefix = "-" - keepUnreleasedSection = true - unreleasedTerm = "[Unreleased]" - groups = listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security") - lineSeparator = "\n" - combinePreReleases = true -} +repositories { mavenCentral() } + +dependencies { + minecraft(libs.minecraft) + mappings(variantOf(libs.fabric.mappings) { classifier("v2") }) + modImplementation(libs.fabric.loader) + modImplementation(libs.fabric.kotlin) + + include(libs.logging) + implementation(libs.logging) -gitHooks { - setHooks(mapOf("pre-commit" to "build test checkLicenses")) + testImplementation(kotlin("test")) } tasks { - dokkaHtmlMultiModule { + test { useJUnitPlatform() } + + signing { + sign(remapJar.get()) + isRequired = + hasProperty("signingKey") && + hasProperty("signingKeyId") && + hasProperty("signingPassword") + + if (isRequired) { + useInMemoryPgpKeys( + (property("signingKey") as String).base64Decode(), + (property("signingKeyId") as String).base64Decode(), + (property("signingPassword") as String).base64Decode(), + ) + } + } + + dokkaHtml { pluginConfiguration { customAssets = listOf(file("artSrc/logo-icon.svg")) footerMessage = "(c) 2024 Pyrrha Wills" @@ -91,4 +87,117 @@ tasks { currentDocsDir.resolve("older").deleteRecursively() } } + + processResources { + inputs.property("version", project.version.toString()) + filesMatching("fabric.mod.json") { + expand(mutableMapOf("version" to project.version.toString())) + } + } + + jar { from("LICENSE") { rename { "${it}_${project.base.archivesName.get()}" } } } +} + +changelog { + version = project.version.toString() + path = rootProject.file("CHANGELOG.md").canonicalPath + header = provider { "[${project.version}] - ${date()}" } + headerParserRegex = SEM_VER_REGEX + itemPrefix = "-" + keepUnreleasedSection = true + unreleasedTerm = "[Unreleased]" + groups = listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security") + lineSeparator = "\n" + combinePreReleases = true +} + +val enableEnhancedClassRedefinition: Boolean = + if (System.getProperty("java.vendor") == "JetBrains s.r.o.") { + println("JetBrains Runtime found, enabling Enhanced Class Redefinition (DCEVM)") + true + } else { + false + } + +fabricApi { configureDataGeneration() } + +loom { + splitEnvironmentSourceSets() + runs { + configureEach { + if (enableEnhancedClassRedefinition) { + vmArgs("-XX:+AllowEnhancedClassRedefinition") + } + runDir("runs/$name") + } + } + + mods { + val pytek by creating { + sourceSet(sourceSets.main.get()) + sourceSet(sourceSets.getByName("client")) + } + } +} + +spotless { + kotlin { + ktfmt().kotlinlangStyle() + licenseHeaderFile("$projectDir/HEADER") + } + kotlinGradle { ktfmt().kotlinlangStyle() } + java { + googleJavaFormat() + licenseHeaderFile("$projectDir/HEADER") + } +} + +kotlin { + jvmToolchain(21) + explicitApi() + sourceSets { + val client by getting { explicitApi() } + } +} + +java { + withSourcesJar() + targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_21 +} + +modrinth { + token = System.getenv("MODRINTH_TOKEN") + debugMode = System.getenv("MODRINTH_DEBUG") == "1" + projectId = "pytek" + versionNumber = project.version.toString() + versionType = + with(project.version.toString()) { + when { + contains("alpha") -> "alpha" + contains("beta") -> "beta" + else -> "release" + } + } + uploadFile.set(tasks.remapJar) + additionalFiles.set(listOf(tasks.remapSourcesJar)) + gameVersions = listOf(libs.versions.minecraft.get()) + dependencies { + required.project("fabric-api") + required.project("fabric-language-kotlin") + } + changelog = + rootProject.changelog.renderItem( + rootProject.changelog.getUnreleased().withEmptySections(false).withHeader(false), + Changelog.OutputType.MARKDOWN, + ) + syncBodyFrom = rootProject.file("README.md").readText() + + if ( + hasProperty("signingKey") && hasProperty("signingKeyId") && hasProperty("signingPassword") + ) { + additionalFiles.add(tasks.getByName("signRemapJar")) + } } + +fun String.base64Decode(): String = Base64.getDecoder().decode(this).decodeToString() diff --git a/buildLogic/build.gradle.kts b/buildLogic/build.gradle.kts deleted file mode 100644 index 521c9e2..0000000 --- a/buildLogic/build.gradle.kts +++ /dev/null @@ -1,63 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - `kotlin-dsl` -} - -repositories { - maven("https://maven.quiltmc.org/repository/release/") { name = "Quilt" } - maven("https://maven.fabricmc.net/") { name = "Fabric" } - mavenCentral() - gradlePluginPortal() -} - -dependencies { - compileOnly(libs.kotlin.gradlePlugin) - compileOnly(libs.quilt.loom.gradlePlugin) -} - -kotlin { - explicitApi() -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -tasks { - validatePlugins { - enableStricterValidation = true - failOnWarning = true - } - - withType().configureEach { - kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString() - } -} - -gradlePlugin { - plugins { - val jvmConventionPlugin by creating { - id = "ml.internal.jvm" - implementationClass = "ml.internal.JvmConventionPlugin" - } - val loomConventionPlugin by creating { - id = "ml.internal.loom" - implementationClass = "ml.internal.LoomConventionPlugin" - } - val modProjectConventionPlugin by creating { - id = "ml.internal.mod" - implementationClass = "ml.internal.ModConventionPlugin" - } - - val commonProjectConventionPlugin by creating { - id = "ml.common" - implementationClass = "ml.CommonProjectConventionPlugin" - } - val runtimeProjectConventionPlugin by creating { - id = "ml.runtime" - implementationClass = "ml.RuntimeProjectConventionPlugin" - } - } -} diff --git a/buildLogic/gradle.properties b/buildLogic/gradle.properties deleted file mode 100644 index c83986c..0000000 --- a/buildLogic/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.parallel=true -org.gradle.caching=true -kotlin.code.style=official \ No newline at end of file diff --git a/buildLogic/settings.gradle.kts b/buildLogic/settings.gradle.kts deleted file mode 100644 index cb6a232..0000000 --- a/buildLogic/settings.gradle.kts +++ /dev/null @@ -1,9 +0,0 @@ -rootProject.name = "buildLogic" - -dependencyResolutionManagement { - versionCatalogs { - val libs by creating { - from(files("../libs.versions.toml")) - } - } -} diff --git a/buildLogic/src/main/kotlin/gay/pyrrha/build/KotlinForgeRuntimeLibrary.kt b/buildLogic/src/main/kotlin/gay/pyrrha/build/KotlinForgeRuntimeLibrary.kt deleted file mode 100644 index 5ac5102..0000000 --- a/buildLogic/src/main/kotlin/gay/pyrrha/build/KotlinForgeRuntimeLibrary.kt +++ /dev/null @@ -1,16 +0,0 @@ -package gay.pyrrha.build - -import org.gradle.api.attributes.Attribute -import org.gradle.api.provider.Provider -import org.gradle.kotlin.dsl.DependencyHandlerScope - -public val patchedFMLModType: Attribute = Attribute.of("patchedFMLModType", Boolean::class.javaObjectType) - -public fun DependencyHandlerScope.kotlinForgeRuntimeLibrary(dependency: Provider<*>) { - "localRuntime"(dependency) { - isTransitive = false - attributes { - attribute(patchedFMLModType, true) - } - } -} diff --git a/buildLogic/src/main/kotlin/gay/pyrrha/build/ModKotlin.kt b/buildLogic/src/main/kotlin/gay/pyrrha/build/ModKotlin.kt deleted file mode 100644 index 6980dad..0000000 --- a/buildLogic/src/main/kotlin/gay/pyrrha/build/ModKotlin.kt +++ /dev/null @@ -1,28 +0,0 @@ -package gay.pyrrha.build - -import org.gradle.api.JavaVersion -import org.gradle.api.Project -import org.gradle.api.plugins.JavaPluginExtension -import org.gradle.api.tasks.bundling.AbstractArchiveTask -import org.gradle.jvm.toolchain.JavaLanguageVersion -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.withType -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -internal fun Project.configureKotlin() { - extensions.configure { - withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 - toolchain.languageVersion.set(JavaLanguageVersion.of(21)) - } - - tasks.withType().configureEach { - kotlinOptions.jvmTarget = JavaVersion.VERSION_21.toString() - } - - tasks.withType().configureEach { - isPreserveFileTimestamps = false - isReproducibleFileOrder = true - } -} diff --git a/buildLogic/src/main/kotlin/gay/pyrrha/build/ProjectExtensions.kt b/buildLogic/src/main/kotlin/gay/pyrrha/build/ProjectExtensions.kt deleted file mode 100644 index 9626876..0000000 --- a/buildLogic/src/main/kotlin/gay/pyrrha/build/ProjectExtensions.kt +++ /dev/null @@ -1,16 +0,0 @@ -package gay.pyrrha.build - -import net.fabricmc.loom.api.LoomGradleExtensionAPI -import org.gradle.api.Project -import org.gradle.api.artifacts.VersionCatalogsExtension -import org.gradle.kotlin.dsl.getByType -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetContainer - -internal val Project.libs - get() = extensions.getByType().named("libs") - -internal val Project.loom - get() = extensions.getByType() - -internal val Project.sourceSets - get() = extensions.getByType().sourceSets diff --git a/buildLogic/src/main/kotlin/gay/pyrrha/build/kotlin-forge-runtime-library.gradle.kts b/buildLogic/src/main/kotlin/gay/pyrrha/build/kotlin-forge-runtime-library.gradle.kts deleted file mode 100644 index 39931a4..0000000 --- a/buildLogic/src/main/kotlin/gay/pyrrha/build/kotlin-forge-runtime-library.gradle.kts +++ /dev/null @@ -1,66 +0,0 @@ -package gay.pyrrha.build - -import org.gradle.api.artifacts.transform.InputArtifact -import org.gradle.api.artifacts.transform.TransformAction -import org.gradle.api.artifacts.transform.TransformOutputs -import org.gradle.api.artifacts.transform.TransformParameters -import org.gradle.api.attributes.Attribute -import org.gradle.api.file.FileSystemLocation -import org.gradle.api.provider.Provider -import org.gradle.api.tasks.PathSensitive -import org.gradle.api.tasks.PathSensitivity -import java.nio.file.FileSystems -import kotlin.io.path.* - -// from https://github.com/object-Object/HexDebug/blob/598081124fcc0483ddfed5947ba5e8728a57fc9b/plugins/src/main/kotlin/hexdebug/utils/KotlinForgeRuntimeLibrary.kt -// ty <3 -public abstract class PatchFMLModType : TransformAction { - public interface Parameters : TransformParameters - - @get:PathSensitive(PathSensitivity.NAME_ONLY) - @get:InputArtifact - public abstract val inputArtifact: Provider - - override fun transform(outputs: TransformOutputs) { - val inputFile = inputArtifact.get().asFile - val inputPath = inputFile.toPath() - - val manifest = FileSystems.newFileSystem(inputPath).use { fs -> - fs.getPath("/META-INF/MANIFEST.MF").readText() - } - - if (manifest.contains("FMLModType")) { - inputFile.copyTo(outputs.file(inputPath.name)) - return - } - - val lf = System.lineSeparator() - val newManifest = manifest.trimEnd() + lf + "FMLModType: GAMELIBRARY" + lf - - val outputFile = outputs.file( - inputPath.run { "${nameWithoutExtension}-PatchedFMLModType.${extension}" }.trimEnd('.') - ) - - inputFile.copyTo(outputFile) - FileSystems.newFileSystem(outputFile.toPath()).use { fs -> - fs.getPath("/META-INF/MANIFEST.MF").writeText(newManifest) - } - } -} - -public val artifactType: Attribute = Attribute.of("artifactType", String::class.java) - -dependencies { - attributesSchema { - attribute(patchedFMLModType) - } - - artifactTypes.getByName("jar") { - attributes.attribute(patchedFMLModType, false) - } - - registerTransform(PatchFMLModType::class) { - from.attribute(patchedFMLModType, false).attribute(artifactType, "jar") - to.attribute(patchedFMLModType, true).attribute(artifactType, "jar") - } -} \ No newline at end of file diff --git a/buildLogic/src/main/kotlin/ml/CommonProjectConventionPlugin.kt b/buildLogic/src/main/kotlin/ml/CommonProjectConventionPlugin.kt deleted file mode 100644 index 5348f4d..0000000 --- a/buildLogic/src/main/kotlin/ml/CommonProjectConventionPlugin.kt +++ /dev/null @@ -1,36 +0,0 @@ -package ml - -import gay.pyrrha.build.sourceSets -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.kotlin.dsl.* - -public class CommonProjectConventionPlugin : Plugin { - override fun apply(project: Project) { - with(project) { - with(pluginManager) { - apply("ml.internal.loom") - apply("ml.internal.mod") - } - - val commonSource by configurations.registering { - isCanBeResolved = false - isCanBeConsumed = true - } - - val commonResources by configurations.registering { - isCanBeResolved = false - isCanBeConsumed = true - } - - artifacts { - val main by sourceSets.getting { - kotlin.sourceDirectories.forEach { - add("commonSource", it) - } - } - add("commonResources", main.resources.sourceDirectories.singleFile) - } - } - } -} diff --git a/buildLogic/src/main/kotlin/ml/RuntimeProjectConventionPlugin.kt b/buildLogic/src/main/kotlin/ml/RuntimeProjectConventionPlugin.kt deleted file mode 100644 index bebe082..0000000 --- a/buildLogic/src/main/kotlin/ml/RuntimeProjectConventionPlugin.kt +++ /dev/null @@ -1,55 +0,0 @@ -package ml - -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.jvm.tasks.Jar -import org.gradle.kotlin.dsl.* -import org.gradle.language.jvm.tasks.ProcessResources -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -public class RuntimeProjectConventionPlugin : Plugin { - override fun apply(project: Project) { - with(project) { - with(pluginManager) { - apply("ml.internal.jvm") - apply("ml.internal.mod") - } - - configurations.register("commonSource") { - isCanBeResolved = true - } - - configurations.register("commonResources") { - isCanBeResolved = true - } - - dependencies { - "compileOnly"(project(path = ":Common")) { - capabilities { - requireCapability("${rootProject.group}:${rootProject.name}:${rootProject.version}") - } - } - - "commonSource"(project(path = ":Common", configuration = "commonSource")) - "commonResources"(project(path = ":Common", configuration = "commonResources")) - } - - tasks.withType().configureEach { - dependsOn(configurations.named("commonSource")) - source(configurations.named("commonSource")) - } - - tasks.named("processResources", ProcessResources::class.java) { - dependsOn(configurations.named("commonResources")) - from(configurations.named("commonResources")) - } - - tasks.named("kotlinSourcesJar", Jar::class.java) { - dependsOn(configurations.named("commonSource")) - dependsOn(configurations.named("commonResources")) - from(configurations.named("commonSource")) - from(configurations.named("commonResources")) - } - } - } -} diff --git a/buildLogic/src/main/kotlin/ml/internal/JvmConventionPlugin.kt b/buildLogic/src/main/kotlin/ml/internal/JvmConventionPlugin.kt deleted file mode 100644 index 3c0dc82..0000000 --- a/buildLogic/src/main/kotlin/ml/internal/JvmConventionPlugin.kt +++ /dev/null @@ -1,17 +0,0 @@ -package ml.internal - -import gay.pyrrha.build.configureKotlin -import org.gradle.api.Plugin -import org.gradle.api.Project - -public class JvmConventionPlugin : Plugin { - override fun apply(project: Project) { - with(project) { - with(pluginManager) { - apply("org.jetbrains.kotlin.jvm") - } - - configureKotlin() - } - } -} diff --git a/buildLogic/src/main/kotlin/ml/internal/LoomConventionPlugin.kt b/buildLogic/src/main/kotlin/ml/internal/LoomConventionPlugin.kt deleted file mode 100644 index c017a4e..0000000 --- a/buildLogic/src/main/kotlin/ml/internal/LoomConventionPlugin.kt +++ /dev/null @@ -1,23 +0,0 @@ -package ml.internal - -import gay.pyrrha.build.libs -import gay.pyrrha.build.loom -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.kotlin.dsl.dependencies - -public class LoomConventionPlugin : Plugin { - override fun apply(project: Project) { - with(project) { - with(pluginManager) { - apply("ml.internal.jvm") - apply("org.quiltmc.loom") - } - - dependencies { - "minecraft"(libs.findLibrary("minecraft").get()) - "mappings"(loom.officialMojangMappings()) - } - } - } -} \ No newline at end of file diff --git a/buildLogic/src/main/kotlin/ml/internal/ModConventionPlugin.kt b/buildLogic/src/main/kotlin/ml/internal/ModConventionPlugin.kt deleted file mode 100644 index 0c02f39..0000000 --- a/buildLogic/src/main/kotlin/ml/internal/ModConventionPlugin.kt +++ /dev/null @@ -1,26 +0,0 @@ -package ml.internal - -import org.gradle.api.Plugin -import org.gradle.api.Project - -public class ModConventionPlugin : Plugin { - override fun apply(project: Project) { - with(project) { - with(pluginManager) { - apply("ml.internal.jvm") - } - - listOf( - "apiElements", - "runtimeElements", - "mainSourceElements" - ).forEach { - configurations.named(it).configure { - outgoing { - capability("${rootProject.group}:${rootProject.name}:${rootProject.version}") - } - } - } - } - } -} diff --git a/gradle.properties b/gradle.properties index 1b298d4..40e43aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,4 @@ org.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1G org.gradle.parallel=true org.gradle.caching=true -kotlin.code.style=official -fabric.multiProjectOptimizations=true \ No newline at end of file +kotlin.code.style=official \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3318e04..327a4f0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue May 14 16:55:53 NZST 2024 +#Thu Jul 18 16:02:53 NZST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/libs.versions.toml b/libs.versions.toml index fb1d147..a2aaf3e 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -1,45 +1,32 @@ [versions] -changelog = "2.2.0" # https://github.com/JetBrains/gradle-changelog-plugin/releases +changelog = "2.2.1" # https://github.com/JetBrains/gradle-changelog-plugin/releases dokka = "1.9.20" # https://github.com/Kotlin/dokka/releases -githooks = "0.0.2" # https://github.com/jakemarsden/git-hooks-gradle-plugin/releases -ideaExt = "1.1.8" # https://plugins.gradle.org/plugin/org.jetbrains.gradle.plugin.idea-ext +fabricApi = "0.100.7+1.21" # https://github.com/FabricMC/fabric/releases +fabricKotlin = "1.11.0+kotlin.2.0.0" # https://github.com/FabricMC/fabric-language-kotlin/releases +fabricLoader = "0.16.0" # https://github.com/FabricMC/fabric-loader/releases +fabricLoom = "1.7-SNAPSHOT" # https://github.com/FabricMC/fabric-loom/releases +fabricMappings = "1.21+build.9" # https://maven.fabricmc.net/net/fabricmc/yarn kotlin = "2.0.0" -licenser = "1.1.2" # https://github.com/YumiProject/yumi-gradle-licenser/tags -logging = "6.0.9" # https://github.com/oshai/kotlin-logging/releases -minecraft = "1.20.6" +logging = "7.0.0" # https://github.com/oshai/kotlin-logging/releases +minecraft = "1.21" minotaur = "2.8.7" # https://github.com/modrinth/minotaur/releases -neoforge = "20.6.70-beta" # https://maven.neoforged.net/#/releases/net/neoforged/neoforge -neoforgeKotlin = "5.1.0" # https://github.com/thedarkcolour/KotlinForForge/tree/site/thedarkcolour/kotlinforforge-neoforge -neoforgeUserDev = "7.0.129" # https://maven.neoforged.net/#/releases/net/neoforged/gradle/userdev -quiltLoom = "1.6.7" # https://maven.quiltmc.org/repository/release/org/quiltmc/loom/ +spotless = "7.0.0.BETA1" # https://github.com/diffplug/spotless/blob/main/plugin-gradle/CHANGES.md [libraries] dokka-pluginBase = { group = "org.jetbrains.dokka", name = "dokka-base", version.ref = "dokka" } dokka-pluginVersioning = { group = "org.jetbrains.dokka", name = "versioning-plugin", version.ref = "dokka" } +fabric-api = { group = "net.fabricmc", name = "fabric-api", version.ref = "fabricApi" } +fabric-kotlin = { group = "net.fabricmc", name = "fabric-language-kotlin", version.ref = "fabricKotlin" } +fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabricLoader" } +fabric-mappings = { group = "net.fabricmc", name = "yarn", version.ref = "fabricMappings" } logging = { group = "io.github.oshai", name = "kotlin-logging-jvm", version.ref = "logging" } minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" } -neoforge = { group = "net.neoforged", name = "neoforge", version.ref = "neoforge" } -neoforge-kotlin = { group = "thedarkcolour", name = "kotlinforforge-neoforge", version.ref = "neoforgeKotlin" } - -# for buildLogic -kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } -quilt-loom-gradlePlugin = { group = "org.quiltmc", name = "loom", version.ref = "quiltLoom" } [plugins] changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } -githooks = { id = "com.github.jakemarsden.git-hooks", version.ref = "githooks" } -idea-ext = { id = "org.jetbrains.gradle.plugin.idea-ext", version.ref = "ideaExt" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -licenser = { id = "dev.yumi.gradle.licenser", version.ref = "licenser" } +loom = { id = "fabric-loom", version.ref = "fabricLoom" } minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" } -neoforge-userdev = { id = "net.neoforged.gradle.userdev", version.ref = "neoforgeUserDev" } -quilt-loom = { id = "org.quiltmc.loom", version.ref = "quiltLoom" } - -# custom plugins from buildLogic -ml-internal-jvm = { id = "ml.internal.jvm", version = "unspecified" } -ml-internal-loom = { id = "ml.internal.loom", version = "unspecified" } -ml-internal-mod = { id = "ml.internal.mod", version = "unspecified" } -ml-common = { id = "ml.common", version = "unspecified" } -ml-runtime = { id = "ml.runtime", version = "unspecified" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } diff --git a/settings.gradle.kts b/settings.gradle.kts index d37a689..88d63a8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,12 +1,8 @@ rootProject.name = "PyTek" pluginManagement { - includeBuild("buildLogic") repositories { - maven("https://maven.neoforged.net/releases/") { name = "NeoForge" } - maven("https://maven.quiltmc.org/repository/release/") { name = "Quilt" } maven("https://maven.fabricmc.net/") { name = "Fabric" } - mavenCentral() gradlePluginPortal() } @@ -14,16 +10,6 @@ pluginManagement { dependencyResolutionManagement { versionCatalogs { - val libs by creating { - from(files("libs.versions.toml")) - } + val libs by creating { from(files("libs.versions.toml")) } } } - -enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") - -//todo(py, 22/05/2024): Replace multiple projects with multiplatform targets, requires KT-28194 -include( - "Common", - "NeoForge" -) diff --git a/src/client/kotlin/PyTekClient.kt b/src/client/kotlin/PyTekClient.kt new file mode 100644 index 0000000..40cba46 --- /dev/null +++ b/src/client/kotlin/PyTekClient.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +package gay.pyrrha.pytek.client + +import gay.pyrrha.pytek.TAG +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KotlinLogging +import kotlin.system.measureTimeMillis +import net.fabricmc.api.ClientModInitializer + +internal val LOGGER: KLogger = KotlinLogging.logger {} + +public object PyTekClient : ClientModInitializer { + override fun onInitializeClient() { + LOGGER.info { "$TAG Initializing client..." } + val initTimeMillis = measureTimeMillis {} + + LOGGER.info { "$TAG Initialized client. (Took ${initTimeMillis}ms)" } + } +} diff --git a/Common/src/main/kotlin/_Constants.kt b/src/main/kotlin/Constants.kt similarity index 50% rename from Common/src/main/kotlin/_Constants.kt rename to src/main/kotlin/Constants.kt index 0208b47..dcd0d52 100644 --- a/Common/src/main/kotlin/_Constants.kt +++ b/src/main/kotlin/Constants.kt @@ -5,10 +5,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - package gay.pyrrha.pytek -import net.minecraft.resources.ResourceLocation +import net.minecraft.network.packet.CustomPayload +import net.minecraft.util.Identifier public const val MOD_ID: String = "pytek" -public fun rl(path: String): ResourceLocation = ResourceLocation(MOD_ID, path) +public const val TAG: String = "[PyTek]" + +public fun ident(path: String): Identifier = Identifier.of(MOD_ID, path) + +@JvmName("identPayload") +public fun ident(path: String): CustomPayload.Id = + CustomPayload.Id(ident(path)) diff --git a/src/main/kotlin/PyTek.kt b/src/main/kotlin/PyTek.kt new file mode 100644 index 0000000..dd5dd95 --- /dev/null +++ b/src/main/kotlin/PyTek.kt @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2024 Pyrrha Wills - All Rights Reserved + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +package gay.pyrrha.pytek + +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KotlinLogging +import kotlin.system.measureTimeMillis +import net.fabricmc.api.ModInitializer + +internal val LOGGER: KLogger = KotlinLogging.logger {} + +public object PyTek : ModInitializer { + override fun onInitialize() { + LOGGER.info { "$TAG Initializing..." } + val initTimeMillis = measureTimeMillis {} + + LOGGER.info { "$TAG Initialized. (Took ${initTimeMillis}ms)" } + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..6b10daa --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,21 @@ +{ + "schemaVersion": 1, + "id": "pytek", + "version": "$version", + "name": "PyTek", + "environment": "*", + "entrypoints": { + "main": [ + { + "adapter": "kotlin", + "value": "gay.pyrrha.pytek.PyTek" + } + ], + "client": [ + { + "adapter": "kotlin", + "value": "gay.pyrrha.pytek.client.PyTekClient" + } + ] + } +} \ No newline at end of file