Skip to content

Conversation

@IceTank
Copy link
Contributor

@IceTank IceTank commented May 21, 2025

Description

This feature adds a packet limit tracker for click packets using a sliding window rate limit model. When configured, inventory click actions exceeding the limit are canceled. The feature has options in the module to enable, disable and change feature parameters.

Why this feature matters

This module helps you prevent getting kicked on 2b by canceling inventory click actions that would get you kicked for click packet spam.

Checklist

  • All tests pass
  • This feature is very good
  • Code quality is probably ok idk how kotlin works
  • pls merge

@github-actions github-actions bot added triage Requires labelling or review feature Suggests or adds a new feature labels May 21, 2025
Comment on lines 45 to 47
class Container(val genericContainerScreen: GenericContainerScreen, val drawContext: DrawContext, val mouseX: Int, val mouseY: Int, val delta: Float) : GUI(1.0) {
val mouse = Vec2d(mouseX, mouseY)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We already have container events and mouse events, this is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need access to HandledScreen render methods which I did not find any existing mixins for. x y and background width don't exist on Screen.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment goes alongside the module's event review

Comment on lines 104 to 115
listen<RenderEvent.GUI.Container> {
if (!limitClickRender) return@listen
val renderScreen: HandledScreen<*> = it.genericContainerScreen
val context: DrawContext = it.drawContext
val x = renderScreen.x
val y = renderScreen.y

RenderSystem.disableDepthTest()
val remainingText = "Clicks Remaining: " + clickPacketsRemaining().toInt().toString()
context.drawText(renderScreen.textRenderer, Text.literal(remainingText), x + renderScreen.backgroundWidth, y, 4210752, false)
RenderSystem.enableDepthTest()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be replaced by RenderEvent.GUI.Scaled and then use FontRenderer to build the string information that will then be dispatched to opengl

You should also get the current screen with the global context mc property of the SafeContext class, every extensions of that class has access to its properties and other extensions
This allows for a safe access of the game's content with the expectation of these properties to not be null

You can read more about that at https://kotlinlang.org/docs/extensions.html#

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can look into that

Comment on lines 118 to 121
fun canSendClickPackets(packets: Int) = clickPacketQueue.size + packets < clickPacketsWindowAmount()
fun clickPacketsRemaining() = clickPacketsWindowAmount() - clickPacketQueue.size

private fun clickPacketsWindowAmount() = limitClickWindowSize * limitClickRate
Copy link
Collaborator

Choose a reason for hiding this comment

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

Simple methods returning values should be replaced by properties with getters

https://kotlinlang.org/docs/coding-conventions.html#properties

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

Comment on lines 29 to 32
/*
* @author IceTank
* @since 21.05.2025
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have git blame in intellij 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove the author templates. I took this idea from the baritone project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

File was removed

@IceTank IceTank requested a review from emyfops May 24, 2025 13:54
@IceTank
Copy link
Contributor Author

IceTank commented May 24, 2025

@Edouard127 pls review

Copy link
Member

@Avanatiker Avanatiker left a comment

Choose a reason for hiding this comment

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

Thanks for your first contribution! :) for me the click counter does not show ingame. so we need to rework this. does it work for you guys?

@IceTank
Copy link
Contributor Author

IceTank commented Jun 25, 2025

Thanks for your first contribution! :) for me the click counter does not show ingame. so we need to rework this. does it work for you guys?

I just tested it, and it shows up for me. There is a setting in the module to disable it showing in guis. It should be at the top of chests.

@Avanatiker Avanatiker changed the base branch from master to 1.21.5 August 9, 2025 18:18
@Avanatiker Avanatiker closed this Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Suggests or adds a new feature triage Requires labelling or review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants