Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added velocity hit feature #4878

Open
wants to merge 6 commits into
base: nextgen
Choose a base branch
from

Conversation

AlexanderDotH
Copy link

@AlexanderDotH AlexanderDotH commented Dec 13, 2024

Velocity hit feature for KillAura.

The feature

This feature grants an extra hit if the player is lagging while receiving a combo from an opponent.

@DataM0del
Copy link
Contributor

get detekted!!!

@AlexanderDotH
Copy link
Author

Actually no, load the default gomme config and enable this feature. Never got banned, just adjust the extended reach

@SuicidalEeper
Copy link

Did laugh

@AlexanderDotH
Copy link
Author

Do what you want I don't care at all

@1zun4
Copy link
Member

1zun4 commented Dec 14, 2024

Actually no, load the default gomme config and enable this feature. Never got banned, just adjust the extended reach

No what he means is the code quality tool "Detekt".

Copy link
Member

@1zun4 1zun4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job. I had a similar idea but didn't get to do it so far, but this looks promising. The code needs clean up though, formatting is quite off and a lot of useless semicolons and empty spaces.

@1zun4 1zun4 added this to the 0.22.0 milestone Dec 14, 2024
@AlexanderDotH
Copy link
Author

Thank you it's my first contribution in kotlin

Copy link
Contributor

@DataM0del DataM0del left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good To Me ™️, just fix the (unfunny joke start) "detektions" (unfunny joke end)

Copy link
Contributor

@DataM0del DataM0del left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes should fix the detekt errors:

@1zun4 1zun4 removed this from the 0.22.0 milestone Dec 16, 2024
@1zun4
Copy link
Member

1zun4 commented Dec 16, 2024

Can you show us a demo of how it works?

Co-authored-by: DataModel <183248792+DataM0del@users.noreply.github.com>
@AlexanderDotH
Copy link
Author

Can you show us a demo of how it works?

Yeah add me on discord: alexdoth

@1zun4
Copy link
Member

1zun4 commented Dec 19, 2024

Can you show us a demo of how it works?

Yeah add me on discord: alexdoth

Please send the video clip here, if you have one. Is it for 1.8 or 1.9 combat? Because I have tried it for 1.9 combat and it did not really do what I thought it does.

@AlexanderDotH
Copy link
Author

AlexanderDotH commented Dec 19, 2024

It's for 1.8 combat. The feature only extends the reach if the player is lagging or fake lagging. You can also disable this behavior by unchecking the "OnlyWhileLagging" option. In the video, I just set the range extension to 1 and enabled "OnlyWhileLagging". It's more like a legit feature since it only does something in a specific edge case where you are getting combos.

I just added the chat messages in the video to demonstrates at which specific time it worked and not. It will be removed in future PRs.

https://youtu.be/TxYWjrKViO8

@LTBlueLatios
Copy link
Contributor

I'd like to point out that this feature is already covered by Backtrack. If you want to nevertheless add this feature because the current Backtrack can't reliably trigger it, then I suggest adding it in Backtrack itself to prevent code pollution.

If anyone is confused, don't be afraid to ask.

@AlexanderDotH
Copy link
Author

I'm a bit confused, to be honest, because it modifies the behavior of the KillAura, not backtrack. The result would be the same (getting some extra hits on other players), but I think some users will be confused about why the KillAura is hitting further away than set, only to see that backtrack modifies the reach. This feature also works if there is no network "issue".

@LTBlueLatios
Copy link
Contributor

I'm a bit confused, to be honest, because it modifies the behavior of the KillAura, not backtrack. The result would be the same (getting some extra hits on other players), but I think some users will be confused about why the KillAura is hitting further away than set, only to see that backtrack modifies the reach. This feature also works if there is no network "issue".

Mb, I assumed most of the context from the description so I didn't look too much into the code.

@AlexanderDotH
Copy link
Author

@1zun4 will it be merged?

import net.ccbluex.liquidbounce.utils.client.PacketQueueManager
import net.minecraft.network.packet.s2c.play.*

object KillAuraVelocityHit : ToggleableConfigurable(ModuleKillAura, "VelocityHit", false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation! What does this feature do?

Copy link
Contributor

@superblaubeere27 superblaubeere27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting idea.

get() = super.running && isPossible

@Suppress("unused")
private val packetHandler = sequenceHandler<PacketEvent>(priority = 1) { event ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use one of the priority categories.

Comment on lines +19 to +22
private var considerVelocityHit = false
private var damageReceived = false
private var onGroundTicks = 0
private var isPossible = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation!

isPossible is not a very good name

private var isPossible = false

private var timer = Chronometer()
private var lastPacketTime = Lists.newLinkedList<Long>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are only a handful use cases for linked lists.

The ArrayDeque is the one that you are searching for. It is a ring buffer and has O(1) time complexity when inserting at/removing from the head and tail!

And documentation!

Comment on lines +41 to +46
packet is EntityDamageS2CPacket && packet.entityId == player.id -> {
damageReceived = true
}
packet is EntityVelocityUpdateS2CPacket && packet.entityId == player.id && damageReceived -> {
considerVelocityHit = true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have implemented a state machine, but you use two separate flags to keep track of what state the state machine is currently in.

I'd recommend using an enum for the states, for example:

enum PacketListenerState {
    IDLE,
    /**
     * The player received damage, but no velocity packet was received (yet)
     */
    DAMAGE_RECEIVED,
    /**
     * A hit with velocity was received.
     */
    VELOCITY_DAMAGE_RECEIVED
}

Comment on lines +57 to +61
var lagging = isLagging() || PacketQueueManager.isLagging

if (!whenLag) {
lagging = true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this code does what it should?

Suggested change
var lagging = isLagging() || PacketQueueManager.isLagging
if (!whenLag) {
lagging = true
}
var lagging = isLagging() || PacketQueueManager.isLagging || !whenLag

object KillAuraVelocityHit : ToggleableConfigurable(ModuleKillAura, "VelocityHit", false) {

val extendRange by float("ExtendRange", 1.0f, 0.1f..2.0f)
private val whenLag by boolean("OnlyWhileLagging", false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad name

Comment on lines +71 to +73
if ((player.isOnGround && isPossible) || (player.fallDistance > 0.3 && isPossible)) {
onGroundTicks++
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ((player.isOnGround && isPossible) || (player.fallDistance > 0.3 && isPossible)) {
onGroundTicks++
}
if (isPossible && (player.isOnGround || player.fallDistance > 0.3)) {
onGroundTicks++
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants