diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 4dc0f280d..abd0135b5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -468,6 +468,7 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { add(AndroidFeatures.NIGHT_VISION, "Night Vision") add(AndroidFeatures.NANOBOTS_ARMOR, "Nanobots Armor") add(AndroidFeatures.ITEM_MAGNET, "Item Magnet") + add(AndroidFeatures.STEP_ASSIST, "Step Assist") } } 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 index 4c0f837b2..de268499c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt @@ -1,15 +1,18 @@ package ru.dbotthepony.mc.otm.android.feature +import com.mojang.blaze3d.vertex.PoseStack 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.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.registry.AndroidFeatures import java.util.* -class StepAssistFeature(android: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.EXTENDED_REACH, android) { +class StepAssistFeature(android: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.STEP_ASSIST, android) { override fun applyModifiers() { - if (!ForgeMod.STEP_HEIGHT_ADDITION.isPresent) + if (!ForgeMod.STEP_HEIGHT_ADDITION.isPresent || !isActive) return val reach = ply.getAttribute(ForgeMod.STEP_HEIGHT_ADDITION.get()) ?: return @@ -25,6 +28,36 @@ class StepAssistFeature(android: MatteryPlayerCapability) : AndroidFeature(Andro ply.getAttribute(ForgeMod.STEP_HEIGHT_ADDITION.get())?.removePermanentModifier(MODIFIER_ID) } + private var isSteppingCarefully = false + + private fun sharedTick() { + if (isActive) { + if (isSteppingCarefully != ply.isSteppingCarefully) { + isSteppingCarefully = ply.isSteppingCarefully + + if (isSteppingCarefully) { + removeModifiers() + } else { + applyModifiers() + } + } + } + } + + override fun tickClient() { + super.tickClient() + sharedTick() + } + + override fun tickServer() { + super.tickServer() + sharedTick() + } + + override fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) { + ResearchIcons.ICON_STEP_ASSIST.render(stack, x, y, width, height) + } + companion object { private val MODIFIER_ID = UUID.fromString("4a3fae46-47a8-a03f-857d-f5c2b2c8f2f4") }