Improvement: rotation compatibility with other clients by beanbag44 · Pull Request #239 · lambda-client/lambda · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 36 additions & 57 deletions src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OutlineSettings(
vararg baseGroup: NamedEnum,
override val visibility: () -> Boolean = { true },
) : SettingGroup(c) {
val thicknessSetting by c.setting("${prefix}Line Width", 10, 1..100, 1, "The width of the outline", visibility = visibility).group(*baseGroup).index()
val thicknessSetting by c.setting("${prefix}Line Width", 40, 1..100, 1, "The width of the outline", visibility = visibility).group(*baseGroup).index()
val thickness get() = thicknessSetting * 0.00005f

val glowIntensitySetting by c.setting("${prefix}Glow Intensity", 50, 0..100, 1, "Intensity of the outline glow", visibility = visibility).group(*baseGroup).index()
Expand Down
12 changes: 1 addition & 11 deletions src/main/kotlin/com/lambda/event/events/PlayerPacketEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,11 @@ package com.lambda.event.events
import com.lambda.event.Event
import com.lambda.event.callback.Cancellable
import com.lambda.event.callback.ICancellable
import com.lambda.interaction.managers.rotating.Rotation
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket
import net.minecraft.util.math.Vec3d

sealed class PlayerPacketEvent {
data class Pre(
var position: Vec3d,
var rotation: Rotation,
var onGround: Boolean,
var isSprinting: Boolean,
var isCollidingHorizontally: Boolean,
) : Event

data class Send(
val packet: PlayerMoveC2SPacket,
var packet: PlayerMoveC2SPacket,
) : ICancellable by Cancellable()

class Post : Event
Expand Down
29 changes: 20 additions & 9 deletions src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ import com.lambda.module.tag.ModuleTag
import com.lambda.util.NamedEnum
import com.lambda.util.extension.isElytraFlying
import com.lambda.util.math.MathUtils.toInt
import com.lambda.util.math.minus
import com.lambda.util.player.MovementUtils.isInputting
import com.lambda.util.player.MovementUtils.motionY
import com.lambda.util.player.MovementUtils.setSpeed
import net.minecraft.block.Blocks
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.Full
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.PositionAndOnGround
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Vec3d
import net.minecraft.util.shape.VoxelShapes
Expand All @@ -54,6 +55,8 @@ object Jesus : Module(
private var goUp = true
private var swimmingTicks = 0

private var prevPos = Vec3d.ZERO

enum class Mode(override val displayName: String, val collision: Boolean) : NamedEnum {
Ncp("NCP", true),
NcpDolphin("NCP Dolphin", false),
Expand All @@ -63,22 +66,17 @@ object Jesus : Module(
private var shouldWork = false

init {
listen<PlayerPacketEvent.Pre> { event ->
listen<PlayerPacketEvent.Send> { event ->
if (!shouldWork || !waterAt(-0.0001)) return@listen
event.onGround = false

if (!player.isOnGround) return@listen

when (mode) {
Mode.Ncp -> {
val offset = if (player.age % 2 == 0) 0.001 else 0.002
event.position -= Vec3d(0.0, offset, 0.0)
event.lowerPosition(offset)
}

Mode.NcpNew -> {
event.position -= Vec3d(0.0, 0.02 + 0.0001 * swimmingTicks, 0.0)
}

Mode.NcpNew -> event.lowerPosition(0.02 + 0.0001 * swimmingTicks)
else -> {}
}
}
Expand Down Expand Up @@ -151,6 +149,19 @@ object Jesus : Module(
}
}

private fun PlayerPacketEvent.Send.lowerPosition(amount: Double) {
with(packet) {
val newPos = Vec3d(x, y - amount, z)
when(this) {
is Full -> packet = Full(newPos, yaw, pitch, isOnGround, horizontalCollision())
is PositionAndOnGround -> packet = PositionAndOnGround(newPos, isOnGround, horizontalCollision())
else -> if (newPos != prevPos) packet = PositionAndOnGround(newPos, isOnGround, horizontalCollision())
}

prevPos = newPos
}
}

private fun SafeContext.waterAt(yOffset: Double): Boolean {
val b = player.boundingBox
val y = b.minY + yOffset
Expand Down
10 changes: 6 additions & 4 deletions src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import com.lambda.util.math.distSq
import com.lambda.util.text.buildText
import com.lambda.util.text.color
import com.lambda.util.text.literal
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket
import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket
import net.minecraft.util.math.Vec3d
import java.awt.Color

// ToDo: Should also include last packet info as HUD element and connection state.
Expand All @@ -44,7 +46,7 @@ object Rubberband : Module(
private val showConnectionState by setting("Show Connection State", true)
private val showRubberbandInfo by setting("Show Rubberband Info", true)

val configurations = LimitedOrderedSet<PlayerPacketEvent.Pre>(100)
val configurations = LimitedOrderedSet<Vec3d>(100)

init {
listen<PacketEvent.Receive.Pre> { event ->
Expand All @@ -58,7 +60,7 @@ object Rubberband : Module(

val newPos = event.packet.change.position
val last = configurations.minBy {
it.position distSq newPos
it distSq newPos
}

this@Rubberband.warn(buildText {
Expand All @@ -68,12 +70,12 @@ object Rubberband : Module(
}
literal(" ticks (deviation: ")
color(Color.YELLOW) {
literal("%.3f".format(last.position dist newPos))
literal("%.3f".format(last dist newPos))
}
literal(")")
})
}

listen<PlayerPacketEvent.Pre> { configurations.add(it) }
listen<PlayerPacketEvent.Send> { configurations.add(with(it.packet) { Vec3d(x, y, z) }) }
}
}
5 changes: 5 additions & 0 deletions src/main/resources/lambda.accesswidener