diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt new file mode 100644 index 000000000..3929388df --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.android.feature + +import net.minecraft.world.entity.ai.attributes.AttributeModifier +import net.minecraftforge.common.ForgeMod +import ru.dbotthepony.mc.otm.android.AndroidFeature +import ru.dbotthepony.mc.otm.capability.android.AndroidCapability +import ru.dbotthepony.mc.otm.registry.AndroidFeatures +import java.util.* + +class StepAssistFeature(android: AndroidCapability) : AndroidFeature(AndroidFeatures.EXTENDED_REACH, android) { + override fun applyModifiers() { + if (!ForgeMod.STEP_HEIGHT_ADDITION.isPresent) + return + + val reach = entity.getAttribute(ForgeMod.STEP_HEIGHT_ADDITION.get()) ?: return + + reach.removePermanentModifier(MODIFIER_ID) + reach.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), level + 1.0, AttributeModifier.Operation.ADDITION)) + } + + override fun removeModifiers() { + if (!ForgeMod.STEP_HEIGHT_ADDITION.isPresent) + return + + entity.getAttribute(ForgeMod.STEP_HEIGHT_ADDITION.get())?.removePermanentModifier(MODIFIER_ID) + } + + companion object { + private val MODIFIER_ID = UUID.fromString("4a3fae46-47a8-a03f-857d-f5c2b2c8f2f4") + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt index c83013a33..b3baa0a42 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt @@ -5,15 +5,13 @@ import net.minecraftforge.registries.DeferredRegister import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeatureType import ru.dbotthepony.mc.otm.android.DummyAndroidFeature -import ru.dbotthepony.mc.otm.android.feature.ExtendedReach -import ru.dbotthepony.mc.otm.android.feature.LimbOverclocking -import ru.dbotthepony.mc.otm.android.feature.NanobotsArmor -import ru.dbotthepony.mc.otm.android.feature.NanobotsRegeneration +import ru.dbotthepony.mc.otm.android.feature.* object AndroidFeatures { private val registry = DeferredRegister.create(AndroidFeatureType::class.java, OverdriveThatMatters.MOD_ID) val AIR_BAGS: AndroidFeatureType<*> by registry.register(MNames.AIR_BAGS) { AndroidFeatureType(::DummyAndroidFeature) } + val STEP_ASSIST: AndroidFeatureType<*> by registry.register(MNames.STEP_ASSIST) { AndroidFeatureType(::StepAssistFeature) } val LIMB_OVERCLOCKING: AndroidFeatureType<*> by registry.register(MNames.LIMB_OVERCLOCKING) { AndroidFeatureType(::LimbOverclocking) } val NANOBOTS_REGENERATION: AndroidFeatureType<*> by registry.register(MNames.NANOBOTS_REGENERATION) { AndroidFeatureType(::NanobotsRegeneration) } val NANOBOTS_ARMOR: AndroidFeatureType<*> by registry.register(MNames.NANOBOTS_ARMOR) { AndroidFeatureType(::NanobotsArmor) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidResearch.kt index d4588665e..a3d558b5a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidResearch.kt @@ -89,6 +89,15 @@ object AndroidResearch { .build() } + val STEP_ASSIST: AndroidResearchType<*> by registry.register(MNames.STEP_ASSIST) { + AndroidResearchBuilder() + .withExperience(24) + .addFeatureResult(AndroidFeatures.STEP_ASSIST) + .withDescription() + .withIcon(ICON_STEP_ASSIST) + .build() + } + val EXTENDED_REACH: AndroidResearchType<*> by registry.register(MNames.EXTENDED_REACH) { AndroidResearchBuilder() .withExperience(40) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 11587e8bf..75c94ad29 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -154,6 +154,7 @@ object MNames { // android features and research const val AIR_BAGS = "air_bags" + const val STEP_ASSIST = "step_assist" const val LIMB_OVERCLOCKING = "limb_overclocking" const val LIMB_OVERCLOCKING_1 = "limb_overclocking_1"