From c0cb3b970c48ae9f8884edc399f1744786b529ac Mon Sep 17 00:00:00 2001 From: Niklas Widmann Date: Wed, 30 Aug 2023 13:43:09 +0200 Subject: [PATCH] add trinkets as air source (#4) --- build.gradle.kts | 16 +++++++++++++- gradle.properties | 2 ++ .../create_jetpack/CreateJetpackMod.java | 6 ++++++ .../create_jetpack/compat/TrinketsCompat.kt | 21 +++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/com/possible_triangle/create_jetpack/compat/TrinketsCompat.kt diff --git a/build.gradle.kts b/build.gradle.kts index 88f6cd2..97871a1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,9 +10,11 @@ val caelus_version: String by extra val jei_version: String by extra val emi_version: String by extra val night_config_version: String by extra +val trinkets_version: String by extra +val cca_version: String by extra plugins { - id("com.possible-triangle.gradle") version("0.1.0") + id("com.possible-triangle.gradle") version ("0.1.0") } withKotlin() @@ -49,10 +51,22 @@ repositories { includeGroup("com.possible_triangle") } } + + maven { + url = uri("https://maven.ladysnake.org/releases") + content { + includeGroup("dev.onyxstudios.cardinal-components-api") + } + } } dependencies { modApi("com.simibubi.create:create-fabric-${mc_version}:${create_version}") + modApi("dev.emi:trinkets:${trinkets_version}") + + // Should be included with trinkets but is not available at runtime somehow + modCompileOnly("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${cca_version}") + modCompileOnly("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${cca_version}") if (!env.isCI) { modRuntimeOnly("mezz.jei:jei-${mc_version}-fabric:${jei_version}") diff --git a/gradle.properties b/gradle.properties index 7786236..2af075c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,6 +19,8 @@ create_version=0.5.1-d-build.1161+mc1.20.1 night_config_version=3.6.7 flightlib_version=2.0.0 kotlin_fabric_version=1.9.6+kotlin.1.8.22 +trinkets_version=3.7.1 +cca_version=5.2.0 repository=pssbletrngle/createjetpack-fabric modrinth_project_id=UbFnAd4l diff --git a/src/main/java/com/possible_triangle/create_jetpack/CreateJetpackMod.java b/src/main/java/com/possible_triangle/create_jetpack/CreateJetpackMod.java index 10a0e6a..fdadedc 100644 --- a/src/main/java/com/possible_triangle/create_jetpack/CreateJetpackMod.java +++ b/src/main/java/com/possible_triangle/create_jetpack/CreateJetpackMod.java @@ -1,9 +1,11 @@ package com.possible_triangle.create_jetpack; +import com.possible_triangle.create_jetpack.compat.TrinketsCompat; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.loader.api.FabricLoader; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,6 +17,10 @@ public class CreateJetpackMod implements ModInitializer, ClientModInitializer, D @Override public void onInitialize() { Content.INSTANCE.register(); + + if(FabricLoader.getInstance().isModLoaded("trinkets")) { + TrinketsCompat.INSTANCE.register(); + } } @Override diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/compat/TrinketsCompat.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/compat/TrinketsCompat.kt new file mode 100644 index 0000000..df38a51 --- /dev/null +++ b/src/main/kotlin/com/possible_triangle/create_jetpack/compat/TrinketsCompat.kt @@ -0,0 +1,21 @@ +package com.possible_triangle.create_jetpack.compat + +import com.simibubi.create.AllTags.AllItemTags.PRESSURIZED_AIR_SOURCES +import com.simibubi.create.content.equipment.armor.BacktankUtil +import dev.emi.trinkets.api.TrinketsApi +import kotlin.jvm.optionals.getOrNull + +object TrinketsCompat { + + fun register() { + BacktankUtil.addBacktankSupplier { entity -> + val trinkets = TrinketsApi.getTrinketComponent(entity).getOrNull() + + trinkets?.allEquipped + ?.map { tuple -> tuple.b } + ?.filter { PRESSURIZED_AIR_SOURCES.matches(it) } + ?: emptyList() + } + } + +} \ No newline at end of file