From 158992731e4d9de62415ba4f8b1092aadead6b9a Mon Sep 17 00:00:00 2001 From: Niklas Widmann Date: Tue, 27 Feb 2024 15:42:20 +0100 Subject: [PATCH 1/3] make elytra boost amount configurable --- gradle.properties | 2 +- .../create_jetpack/config/ServerConfig.kt | 8 ++++---- .../create_jetpack/config/SyncConfigMessage.kt | 4 ++-- .../possible_triangle/create_jetpack/item/JetpackItem.kt | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index f47c053..93b2e3e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ jei_version=11.6.0.1015 emi_version=1.0.2+1.19.2 create_version=0.5.1-c-build.1160+mc1.19.2 night_config_version=3.6.3 -flightlib_version=1.1.2 +flightlib_version=1.2.0 kotlin_fabric_version=1.9.1+kotlin.1.8.10 trinkets_version=3.4.1 cca_version=5.2.0 diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/config/ServerConfig.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/config/ServerConfig.kt index a89e4f1..2ecba30 100644 --- a/src/main/kotlin/com/possible_triangle/create_jetpack/config/ServerConfig.kt +++ b/src/main/kotlin/com/possible_triangle/create_jetpack/config/ServerConfig.kt @@ -10,7 +10,7 @@ interface IServerConfig { val acceleration: Double val hoverSpeed: Double val swimModifier: Double - val elytraBoostEnabled: Boolean + val elytraBoost: Double } data class SyncedConfig( @@ -21,7 +21,7 @@ data class SyncedConfig( override val acceleration: Double, override val hoverSpeed: Double, override val swimModifier: Double, - override val elytraBoostEnabled: Boolean, + override val elytraBoost: Double, ) : IServerConfig class ServerConfig(builder: ForgeConfigSpec.Builder) : IServerConfig { @@ -48,7 +48,7 @@ class ServerConfig(builder: ForgeConfigSpec.Builder) : IServerConfig { private val swimModifierValue = builder.defineInRange("speed.swim_modifier", 1.8, 0.0, 100.0) override val swimModifier get() = swimModifierValue.get()!! - private val elytraBoostEnabledValue = builder.define("features.elytra_boost", true) - override val elytraBoostEnabled get() = elytraBoostEnabledValue.get()!! + private val elytraBoostValue = builder.defineInRange("features.elytra_boost", 1.25, 1.0, 100.0) + override val elytraBoost get() = elytraBoostValue.get()!! } \ No newline at end of file diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/config/SyncConfigMessage.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/config/SyncConfigMessage.kt index 1e2fa3d..8a4ed4b 100644 --- a/src/main/kotlin/com/possible_triangle/create_jetpack/config/SyncConfigMessage.kt +++ b/src/main/kotlin/com/possible_triangle/create_jetpack/config/SyncConfigMessage.kt @@ -16,7 +16,7 @@ class SyncConfigMessage(private val config: IServerConfig) { acceleration = buf.readDouble(), hoverSpeed = buf.readDouble(), swimModifier = buf.readDouble(), - elytraBoostEnabled = buf.readBoolean(), + elytraBoost = buf.readDouble(), ) return SyncConfigMessage(config) } @@ -30,7 +30,7 @@ class SyncConfigMessage(private val config: IServerConfig) { buf.writeDouble(config.acceleration) buf.writeDouble(config.hoverSpeed) buf.writeDouble(config.swimModifier) - buf.writeBoolean(config.elytraBoostEnabled) + buf.writeDouble(config.elytraBoost) } fun handle() { diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/item/JetpackItem.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/item/JetpackItem.kt index c9ab74d..90ced91 100644 --- a/src/main/kotlin/com/possible_triangle/create_jetpack/item/JetpackItem.kt +++ b/src/main/kotlin/com/possible_triangle/create_jetpack/item/JetpackItem.kt @@ -62,8 +62,8 @@ open class JetpackItem( return Configs.SERVER.swimModifier } - override fun boostsElytra(): Boolean { - return Configs.SERVER.elytraBoostEnabled + override fun elytraBoost(): Double { + return Configs.SERVER.elytraBoost } private val thrusters = listOf(-0.35, 0.35).map { offset -> From 86a86a7b7feafd51ba0c2447fcec9fbdb6f3bb69 Mon Sep 17 00:00:00 2001 From: Niklas Widmann Date: Tue, 27 Feb 2024 16:32:33 +0100 Subject: [PATCH 2/3] overwrite netherite lava diving predicate & fix trinket support --- build.gradle.kts | 1 + .../mixin/NetheriteDivingHandlerMixin.java | 26 +++++++++++++++++++ .../create_jetpack/item/JetpackItem.kt | 4 +-- src/main/resources/create_jetpack.mixins.json | 11 ++++++++ src/main/resources/fabric.mod.json | 3 +++ 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/possible_triangle/create_jetpack/mixin/NetheriteDivingHandlerMixin.java create mode 100644 src/main/resources/create_jetpack.mixins.json diff --git a/build.gradle.kts b/build.gradle.kts index b34c516..2491f47 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,6 +21,7 @@ withKotlin() fabric { dataGen() + enableMixins() includesMod("com.possible-triangle:flightlib-fabric:${flightlib_version}") } diff --git a/src/main/java/com/possible_triangle/create_jetpack/mixin/NetheriteDivingHandlerMixin.java b/src/main/java/com/possible_triangle/create_jetpack/mixin/NetheriteDivingHandlerMixin.java new file mode 100644 index 0000000..d1c18ef --- /dev/null +++ b/src/main/java/com/possible_triangle/create_jetpack/mixin/NetheriteDivingHandlerMixin.java @@ -0,0 +1,26 @@ +package com.possible_triangle.create_jetpack.mixin; + +import com.simibubi.create.content.equipment.armor.NetheriteDivingHandler; +import com.tterrag.registrate.util.entry.ItemEntry; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ArmorMaterials; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(NetheriteDivingHandler.class) +public class NetheriteDivingHandlerMixin { + + @Redirect( + method = "onLivingEquipmentChange(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/entity/EquipmentSlot;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V", + at = @At( + value = "INVOKE", + target = "Lcom/tterrag/registrate/util/entry/ItemEntry;isIn(Lnet/minecraft/world/item/ItemStack;)Z" + ) + ) + private static boolean modifyNetheritePredicate(ItemEntry instance, ItemStack stack) { + return stack.getItem() instanceof ArmorItem armor && armor.getMaterial() == ArmorMaterials.NETHERITE; + } + +} diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/item/JetpackItem.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/item/JetpackItem.kt index 90ced91..13b15b6 100644 --- a/src/main/kotlin/com/possible_triangle/create_jetpack/item/JetpackItem.kt +++ b/src/main/kotlin/com/possible_triangle/create_jetpack/item/JetpackItem.kt @@ -4,8 +4,8 @@ import com.possible_triangle.create_jetpack.config.Configs import com.possible_triangle.flightlib.api.ControlType import com.possible_triangle.flightlib.api.IJetpack import com.possible_triangle.flightlib.api.IJetpack.Context -import com.possible_triangle.flightlib.api.sources.CuriosSource import com.possible_triangle.flightlib.api.sources.EquipmentSource +import com.possible_triangle.flightlib.api.sources.TrinketsSource import com.simibubi.create.content.equipment.armor.BacktankItem import com.simibubi.create.content.equipment.armor.BacktankUtil import com.simibubi.create.foundation.item.LayeredArmorItem @@ -84,7 +84,7 @@ open class JetpackItem( override fun isValid(context: Context): Boolean { return when (val source = context.source) { is EquipmentSource -> source.slot == EquipmentSlot.CHEST - is CuriosSource -> true + is TrinketsSource -> true else -> false } } diff --git a/src/main/resources/create_jetpack.mixins.json b/src/main/resources/create_jetpack.mixins.json new file mode 100644 index 0000000..85d451d --- /dev/null +++ b/src/main/resources/create_jetpack.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.possible_triangle.create_jetpack.mixin", + "compatibilityLevel": "JAVA_17", + "refmap": "${mod_id}.refmap.json", + "mixins": ["NetheriteDivingHandlerMixin"], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ab943e1..fb6cc8b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,6 +24,9 @@ "com.possible_triangle.create_jetpack.CreateJetpackMod" ] }, + "mixins": [ + "${mod_id}.mixins.json" + ], "depends": { "fabricloader": ">=0.14", "fabric": "*", From 805ed69e8b53a7d8282c0fe2ce9d4d7cb2bde2af Mon Sep 17 00:00:00 2001 From: Niklas Widmann Date: Tue, 27 Feb 2024 16:38:01 +0100 Subject: [PATCH 3/3] only target backtank predicate --- .../create_jetpack/mixin/NetheriteDivingHandlerMixin.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/possible_triangle/create_jetpack/mixin/NetheriteDivingHandlerMixin.java b/src/main/java/com/possible_triangle/create_jetpack/mixin/NetheriteDivingHandlerMixin.java index d1c18ef..1f90a0f 100644 --- a/src/main/java/com/possible_triangle/create_jetpack/mixin/NetheriteDivingHandlerMixin.java +++ b/src/main/java/com/possible_triangle/create_jetpack/mixin/NetheriteDivingHandlerMixin.java @@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.Slice; @Mixin(NetheriteDivingHandler.class) public class NetheriteDivingHandlerMixin { @@ -17,6 +18,13 @@ public class NetheriteDivingHandlerMixin { at = @At( value = "INVOKE", target = "Lcom/tterrag/registrate/util/entry/ItemEntry;isIn(Lnet/minecraft/world/item/ItemStack;)Z" + ), + slice = @Slice( + from = @At( + value = "FIELD", + target = "Lnet/minecraft/world/entity/EquipmentSlot;CHEST:Lnet/minecraft/world/entity/EquipmentSlot;" + ), + to = @At("TAIL") ) ) private static boolean modifyNetheritePredicate(ItemEntry instance, ItemStack stack) {