From e125fd7d1c2db876fa81e178e4d712d96677c559 Mon Sep 17 00:00:00 2001 From: Sammy Date: Sat, 8 Jul 2023 16:29:29 +0200 Subject: [PATCH] feat: Dynamic metadata --- fabric/build.gradle | 46 ++++++++++-------- fabric/gradle.properties | 48 +++++++++---------- .../blockEntity/RedRouterBlockEntity.java | 11 ++--- fabric/src/main/resources/fabric.mod.json | 28 +++++------ forge/build.gradle | 11 ++++- forge/gradle.properties | 17 +++++-- .../tweaked_programs/cccbridge/CCCBridge.java | 4 -- .../blockEntity/RedRouterBlockEntity.java | 11 ++--- forge/src/main/resources/META-INF/mods.toml | 30 ++++++------ 9 files changed, 106 insertions(+), 100 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 73275b9..eb0556b 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -7,8 +7,8 @@ plugins { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 -archivesBaseName = project.archives_base_name -version = project.mod_version +archivesBaseName = "${archives_base_name}-mc${mc_version}-${modloader}" +version = "v${mod_version}" group = project.maven_group repositories { @@ -41,10 +41,10 @@ repositories { } dependencies { - minecraft "com.mojang:minecraft:${project.minecraft_version}" + minecraft "com.mojang:minecraft:${project.mc_version}" mappings loom.layered() { officialMojangMappings() - parchment("org.parchmentmc.data:parchment-${project.minecraft_version}:${project.parchment_version}@zip") + parchment("org.parchmentmc.data:parchment-${project.mc_version}:${project.parchment_version}@zip") } modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" @@ -52,11 +52,11 @@ dependencies { //modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}+${minecraft_version}") // Create - modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}+mc${minecraft_version}") + modImplementation("com.simibubi.create:create-fabric-${mc_version}:${create_version}+mc${mc_version}") // CC:R - modImplementation("com.github.cc-tweaked:cc-restitched:${project.cc_version}") - modApi "com.github.cc-tweaked:cc-restitched:${project.cc_version}" + modImplementation("com.github.cc-tweaked:cc-restitched:v${cc_mc_version}-${project.cc_version}-ccr") + modApi "com.github.cc-tweaked:cc-restitched:v${cc_mc_version}-${project.cc_version}-ccr" // dev qol modLocalRuntime("maven.modrinth:lazydfu:${lazydfu_version}") @@ -79,7 +79,7 @@ processResources { inputs.property "version", project.version filesMatching("fabric.mod.json") { - expand "version": project.version + expand(project.properties) } } @@ -88,9 +88,24 @@ tasks.withType(JavaCompile).configureEach { options.compilerArgs <<"-Xlint:deprecation" } -java { withSourcesJar() } - -jar { from("LICENSE") { rename { "${it}_${project.archivesBaseName}"} } } +jar { + from("LICENSE") { + rename { + "${it}_${project.archivesBaseName}" + } + } + manifest { + attributes([ + "Specification-Title" : "${project.archives_base_name}", + "Specification-Vendor" : "${project.maven_group}", + "Specification-Version" : "1", + "Implementation-Title" : project.name, + "Implementation-Version" : project.mod_version, + "Implementation-Vendor" : "${project.maven_group}", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } +} publishing { publications { @@ -98,12 +113,5 @@ publishing { from components.java } } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. - } + repositories { } } diff --git a/fabric/gradle.properties b/fabric/gradle.properties index faa074b..fdd2c6b 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,40 +1,38 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx2G -# Mod Properties -mod_version = 1.5.0 -maven_group = cc.tweaked_programs -archives_base_name = cccbridge -parchment_version = 2022.08.10 +# Description +copyright_year=2023 +license=Apache-2.0 +modloader=fabric # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.19.2 -loader_version=0.14. +mc_version=1.19.2 +loader_version=0.14.8 + +# Mod Properties +mod_version=1.5.0 +maven_group=cc.tweaked_programs +archives_base_name=cccbridge +parchment_version=2022.08.10 # Dependencies fabric_version=0.73.0 -cc_version=v1.19.1-1.101.2-ccr -create_version = 0.5.1-b-build.1079 +cc_mc_version=1.19.1 +cc_version=1.101.2 +create_version=0.5.1-b-build.1079 +create_version_production=0.5.1-b -# Mappings -yarn_mappings=1.19.2+build.28 -# https://lambdaurora.dev/tools/import_quilt.html -# qm_version = 21 -# https://parchmentmc.org/docs/getting-started -# parchment_version = 2022.11.27 +# Mod Menu - https://modrinth.com/mod/modmenu/versions +modmenu_version=4.1.2 +# LazyDFU - https://modrinth.com/mod/lazydfu/versions +lazydfu_version=0.1.3 -# Development QOL # Recipe viewer: [ EMI | REI | disabled ] # DON'T USE REI, for some reason it is broken... -# Also for some reason if you hit a entity THE GAME CRASHES???? Its creates fault btw. -recipe_viewer = emi +recipe_viewer=emi # REI - https://modrinth.com/mod/roughly-enough-items/versions -rei_version = 9.1.580 +rei_version=9.1.580 # EMI - https://modrinth.com/mod/emi/versions -emi_version = 0.6.1+1.19.2 - -# Mod Menu - https://modrinth.com/mod/modmenu/versions -modmenu_version = 4.1.2 -# LazyDFU - https://modrinth.com/mod/lazydfu/versions -lazydfu_version = 0.1.3 \ No newline at end of file +emi_version=0.6.1+1.19.2 \ No newline at end of file diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/blockEntity/RedRouterBlockEntity.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/blockEntity/RedRouterBlockEntity.java index d07bb90..583c2aa 100644 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/blockEntity/RedRouterBlockEntity.java +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/blockEntity/RedRouterBlockEntity.java @@ -70,17 +70,12 @@ public static void tick(Level world, BlockPos blockPos, BlockState state, BlockE public static void updateInputs(Level world, BlockPos blockPos, RedRouterBlockEntity redrouter) { for (Map.Entry entry : redrouter.inputDir.entrySet()) { String side = entry.getKey(); - Direction dir = Objects.requireNonNull(Direction.byName(side)).getOpposite(); + Direction dir = Direction.byName(side).getOpposite(); BlockPos offsetPos = blockPos.relative(dir); BlockState block = world.getBlockState(offsetPos); - if (block.getBlock() instanceof RedRouterBlock) { - int power = block.getBlock().getSignal(block, world, offsetPos, dir); - - if (redrouter.inputDir.get(side) != power) - redrouter.newInputs = true; - redrouter.inputDir.put(side, power); - } + int power = block.getBlock().getSignal(block, world, offsetPos, dir); + redrouter.inputDir.put(side, power); } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 422d698..dd9a9b3 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -1,21 +1,22 @@ { "schemaVersion": 1, - "id": "cccbridge", - "version": "${version}", + "id": "${archives_base_name}", + "version": "${version}-${modloader}", "name": "CC:C Bridge", - "description": "Adds compatibility between the ComputerCraft and Create mod!\n\nCopyright 2022 Sammy L. Koch\nLicensed under the Apache License, Version 2.0 ", + "description": "This mod adds compatibility between the ComputerCraft and Create mod!\n\nCopyright ${copyright_year} Sammy L. Koch", "authors": [ "Sammy L. Koch", "Luke A. Hanssen" ], "contact": { - "homepage": "https://tweaked-programs.cc/tag/cccbridge/", - "sources": "https://github.com/tweaked-programs/cccbridge" + "homepage": "https://tweaked-programs.cc/", + "sources": "https://github.com/tweaked-programs/cccbridge", + "issues": "https://github.com/tweaked-programs/cccbridge/issues" }, - "license": "Apache-2.0", - "icon": "icon.png", + "license": "${license}", + "icon": "iconHD.png", "environment": "*", "entrypoints": { @@ -31,13 +32,10 @@ ], "depends": { - "create": "*", - "computercraft": ">=1.100.7", - "fabricloader": ">=0.14.6", - "minecraft": "~1.19.2", + "create": ">=${create_version_production}", + "computercraft": ">=${cc_version}", + "fabricloader": ">=${loader_version}", + "minecraft": "~${mc_version}", "java": ">=17" - }, - "suggests": { - "another-mod": "*" } -} +} \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle index 730c4a4..4fca565 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -127,6 +127,14 @@ dependencies { implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}") } +processResources { + inputs.property "version", project.version + + filesMatching("META-INF/mods.toml") { + expand(project.properties) + } +} + jar { manifest { attributes([ @@ -134,11 +142,12 @@ jar { "Specification-Vendor" : "cccbridgesareus", "Specification-Version" : "1", "Implementation-Title" : project.name, - "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Version" : project.mod_version, "Implementation-Vendor" : "cccbridgesareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } + archiveName = "${archives_base_name}-mc${mc_version}-${modloader}-v${mod_version}.${jar.getArchiveExtension().get()}" } jar.finalizedBy('reobfJar') diff --git a/forge/gradle.properties b/forge/gradle.properties index 226d6fe..bcac67e 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -1,6 +1,12 @@ org.gradle.jvmargs=-Xmx2G org.gradle.daemon=false +# Description +copyright_year=2023 +license=Apache-2.0 +archives_base_name=cccbridge +modloader=forge + # Properties mc_version=1.19.2 forge_version=43.2.3 @@ -11,11 +17,12 @@ cc_version=1.101.2 librarian_version = 1.+ parchment_version = 2022.08.10 -create_minecraft_version = 1.19.2 -create_version = 0.5.1.b-30 -registrate_version = MC1.19-1.1.5 -flywheel_minecraft_version = 1.19.2 -flywheel_version = 0.6.8.a-14 +create_minecraft_version=1.19.2 +create_version=0.5.1.b-30 +create_version_production=0.5.1.b +registrate_version=MC1.19-1.1.5 +flywheel_minecraft_version=1.19.2 +flywheel_version=0.6.8.a-14 # Runtime only jei_version=11.5.0.297 \ No newline at end of file diff --git a/forge/src/main/java/cc/tweaked_programs/cccbridge/CCCBridge.java b/forge/src/main/java/cc/tweaked_programs/cccbridge/CCCBridge.java index f0fc2d1..0fa69b1 100644 --- a/forge/src/main/java/cc/tweaked_programs/cccbridge/CCCBridge.java +++ b/forge/src/main/java/cc/tweaked_programs/cccbridge/CCCBridge.java @@ -33,10 +33,6 @@ public static void complete(FMLLoadCompleteEvent event) { AllDisplayBehaviours.assignBlockEntity(AllDisplayBehaviours.register(new ResourceLocation(MOD_ID, "source_block_display_source"), new SourceBlockDisplaySource()), CCCRegister.SOURCE_BLOCK_ENTITY.get()); AllDisplayBehaviours.assignBlockEntity(AllDisplayBehaviours.register(new ResourceLocation(MOD_ID, "target_block_display_target"), new TargetBlockDisplayTarget()), CCCRegister.TARGET_BLOCK_ENTITY.get()); - ForgeComputerCraftAPI.registerPeripheralProvider((world, pos, side) -> world.getBlockEntity(pos, CCCRegister.SOURCE_BLOCK_ENTITY.get()).map(be -> be.getPeripheral(side)).map(val -> LazyOptional.of(() -> val)).orElse(LazyOptional.empty())); - ForgeComputerCraftAPI.registerPeripheralProvider((world, pos, side) -> world.getBlockEntity(pos, CCCRegister.TARGET_BLOCK_ENTITY.get()).map(be -> be.getPeripheral(side)).map(val -> LazyOptional.of(() -> val)).orElse(LazyOptional.empty())); - ForgeComputerCraftAPI.registerPeripheralProvider((world, pos, side) -> world.getBlockEntity(pos, CCCRegister.REDROUTER_BLOCK_ENTITY.get()).map(be -> be.getPeripheral(side)).map(val -> LazyOptional.of(() -> val)).orElse(LazyOptional.empty())); - ForgeComputerCraftAPI.registerPeripheralProvider((world, pos, side) -> world.getBlockEntity(pos, CCCRegister.SCROLLER_BLOCK_ENTITY.get()).map(be -> be.getPeripheral(side)).map(val -> LazyOptional.of(() -> val)).orElse(LazyOptional.empty())); ForgeComputerCraftAPI.registerPeripheralProvider(new PeripheralProvider()); }); } diff --git a/forge/src/main/java/cc/tweaked_programs/cccbridge/blockEntity/RedRouterBlockEntity.java b/forge/src/main/java/cc/tweaked_programs/cccbridge/blockEntity/RedRouterBlockEntity.java index cbcc954..9a46025 100644 --- a/forge/src/main/java/cc/tweaked_programs/cccbridge/blockEntity/RedRouterBlockEntity.java +++ b/forge/src/main/java/cc/tweaked_programs/cccbridge/blockEntity/RedRouterBlockEntity.java @@ -70,17 +70,12 @@ public static void tick(Level world, BlockPos blockPos, BlockState state, BlockE public static void updateInputs(Level world, BlockPos blockPos, RedRouterBlockEntity redrouter) { for (Map.Entry entry : redrouter.inputDir.entrySet()) { String side = entry.getKey(); - Direction dir = Objects.requireNonNull(Direction.byName(side)).getOpposite(); + Direction dir = Direction.byName(side).getOpposite(); BlockPos offsetPos = blockPos.relative(dir); BlockState block = world.getBlockState(offsetPos); - if (block.getBlock() instanceof RedRouterBlock) { - int power = block.getBlock().getSignal(block, world, offsetPos, dir); - - if (redrouter.inputDir.get(side) != power) - redrouter.newInputs = true; - redrouter.inputDir.put(side, power); - } + int power = block.getBlock().getSignal(block, world, offsetPos, dir); + redrouter.inputDir.put(side, power); } } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 4ae2eeb..ca13b1e 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,42 +1,42 @@ modLoader="javafml" loaderVersion="[40,)" -license="Apache-2.0" +license="${license}" issueTrackerURL="https://github.com/tweaked-programs/cccbridge/issues/" [[mods]] -modId="cccbridge" -version="1.5.0" +modId="${archives_base_name}" +version="${version}-${modloader}" displayName="CC:C Bridge" -updateJSONURL="" +updateJSONURL="https://api.modrinth.com/updates/${archives_base_name}/forge_updates.json" displayURL="https://tweaked-programs.cc/" -logoFile= "icon.png" -credits="Thanks for this mod goes out to agnor99, who understands modding much better!" +logoFile= "iconHD.png" +credits="Thanks to agnor99, who understands modding much better!" authors="Sammy L. Koch & Luke A. Hanssen" description='''This mod adds compatibility between the ComputerCraft and Create mod! -Copyright 2023 Sammy L. Koch''' +Copyright ${copyright_year} Sammy L. Koch''' -[[dependencies.cccbridge]] +[[dependencies.${archives_base_name}]] modId="forge" mandatory=true - versionRange="[43,)" + versionRange="[${forge_version},)" ordering="NONE" # NONE; BEFORE; AFTER side="BOTH" -[[dependencies.cccbridge]] +[[dependencies.${archives_base_name}]] modId="minecraft" mandatory=true - versionRange="[1.19.2,)" + versionRange="[${mc_version},)" ordering="NONE" side="BOTH" -[[dependencies.cccbridge]] +[[dependencies.${archives_base_name}]] modId="create" mandatory=true - versionRange="[0.5.1.b,)" + versionRange="[${create_version_production},)" ordering="NONE" side="BOTH" -[[dependencies.cccbridge]] +[[dependencies.${archives_base_name}]] modId="computercraft" mandatory=true - versionRange="[1.101.2,)" + versionRange="[${cc_version},)" ordering="NONE" side="BOTH"