-
Notifications
You must be signed in to change notification settings - Fork 18
Feat: Add click packet limit to PacketLimiter #122
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
Conversation
| 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) | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| 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() | ||
| } |
There was a problem hiding this comment.
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#
There was a problem hiding this comment.
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
| fun canSendClickPackets(packets: Int) = clickPacketQueue.size + packets < clickPacketsWindowAmount() | ||
| fun clickPacketsRemaining() = clickPacketsWindowAmount() - clickPacketQueue.size | ||
|
|
||
| private fun clickPacketsWindowAmount() = limitClickWindowSize * limitClickRate |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
| /* | ||
| * @author IceTank | ||
| * @since 21.05.2025 | ||
| */ |
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File was removed
|
@Edouard127 pls review |
Avanatiker
left a comment
There was a problem hiding this 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?
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. |
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