52 lines
1.8 KiB
Kotlin
52 lines
1.8 KiB
Kotlin
package codes.som.hibiscus.features.combat
|
|
|
|
import codes.som.hibiscus.api.feature.Feature
|
|
import codes.som.hibiscus.api.feature.FeatureCategory
|
|
import codes.som.hibiscus.events.SendPacketEvent
|
|
import codes.som.hibiscus.mixins.MixinExtPlayerInteractEntityC2SPacket
|
|
import codes.som.hibiscus.player
|
|
import codes.som.hibiscus.util.ext.requireExtension
|
|
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket
|
|
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket
|
|
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket
|
|
|
|
class Criticals : Feature("Criticals", FeatureCategory.COMBAT) {
|
|
init {
|
|
on { event: SendPacketEvent ->
|
|
val (packet) = event
|
|
if (packet is PlayerInteractEntityC2SPacket) {
|
|
requireExtension<MixinExtPlayerInteractEntityC2SPacket>(packet)
|
|
|
|
if (packet.typeHandler.type != PlayerInteractEntityC2SPacket.InteractType.ATTACK)
|
|
return@on
|
|
|
|
player.isSprinting = false
|
|
player.networkHandler.sendPacket(
|
|
ClientCommandC2SPacket(
|
|
player,
|
|
ClientCommandC2SPacket.Mode.STOP_SPRINTING
|
|
)
|
|
)
|
|
|
|
player.networkHandler.sendPacket(
|
|
PlayerMoveC2SPacket.PositionAndOnGround(
|
|
player.x,
|
|
player.y + 0.0625,
|
|
player.z,
|
|
false
|
|
)
|
|
)
|
|
|
|
player.networkHandler.sendPacket(
|
|
PlayerMoveC2SPacket.PositionAndOnGround(
|
|
player.x,
|
|
player.y,
|
|
player.z,
|
|
false
|
|
)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|