Skip to content

Commit

Permalink
feat: Dynamic metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
SammyForReal committed Jul 8, 2023
1 parent beb477e commit e125fd7
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 100 deletions.
46 changes: 27 additions & 19 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -41,22 +41,22 @@ 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}"

// Woah, we don't do that here!
//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}")
Expand All @@ -79,7 +79,7 @@ processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
expand(project.properties)
}
}

Expand All @@ -88,22 +88,30 @@ 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 {
mavenJava(MavenPublication) {
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 { }
}
48 changes: 23 additions & 25 deletions fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
emi_version=0.6.1+1.19.2
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Integer> 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);
}
}

Expand Down
28 changes: 13 additions & 15 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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": "*"
}
}
}
11 changes: 10 additions & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,27 @@ 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([
"Specification-Title" : "cccbridge",
"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')
Expand Down
17 changes: 12 additions & 5 deletions forge/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Integer> 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);
}
}

Expand Down
30 changes: 15 additions & 15 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit e125fd7

Please sign in to comment.