Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Add Notifications module with management, display, and rendering features #657

Merged
merged 7 commits into from
Jul 18, 2024

Conversation

TejasLamba2006
Copy link
Collaborator

@TejasLamba2006 TejasLamba2006 commented Jul 18, 2024

Usage

Notifications.sendNotification(Notifications.NotificationTypes.INFO, "Finding own bed.", 1000);

Summary by CodeRabbit

  • New Features

    • Introduced a new Notifications module for displaying various types of in-game notifications.
    • Added utilities for enhanced text rendering and text wrapping in the game overlay.
  • Enhancements

    • Improved methods for handling colors, including animations and color manipulations.
    • Added support for rendering gradient-filled and outlined rounded rectangles.
    • Enhanced font management with better error handling and new font methods.
  • Removals

    • Removed unused imports and commented out irrelevant settings in the BedPlates module.

Copy link

coderabbitai bot commented Jul 18, 2024

Warning

Rate limit exceeded

@TejasLamba2006 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 21 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between ac8d071 and ded0f47.

Walkthrough

Walkthrough

The updates introduce several new features and improvements across different modules of the keystrokesmod. Notable changes include the addition of a new Notifications module for displaying in-game notifications, enhancements to the font rendering system with new methods for wrapping and centering text, and a new set of utilities for handling animations and colors. There are also updates to shader programs for rendering rounded rectangles with gradients and outlines.

Changes

File(s) Summary
ModuleManager.java Added Notifications module to the register() method, enabling in-game notifications.
Notifications.java Introduced the Notifications class for displaying different types of notifications (INFO, WARN, ERROR) with various settings and rendering logic.
BedPlates.java Removed unused imports and commented out bedwarsOnly setting.
Font.java Added methods drawString and wrapText for enhanced text rendering capabilities, including centering and shadow effects.
FontManager.java Added new font-related methods, modified existing methods, and included error handling for font loading.
FontRenderer.java Added methods wrapText and drawString with enhanced centering and shadow rendering logic.
FontUtil.java Enhanced error handling for font loading, including specific error messages and exception handling.
MinecraftFontRenderer.java Added and modified methods for text rendering with new centering options and text wrapping capabilities.
AnimationUtils.java Added utility class for animation calculations, including methods for setting animation values and calculating compensation.
ColorUtils.java Introduced utility class for color handling in Minecraft, including methods for manipulating colors and setting color values.
RRectUtils.java Added utility methods for rendering rounded rectangles, including gradient and outlined rounded rectangles with customizable sizes and colors.
rrectGradient.frag Added shader program for rendering rounded rectangles with gradient fills, including logic for calculating smooth rounded shapes and blending colors.
rrectOutline.frag Added shader program for rendering rounded rectangle outlines, including logic for calculating the signed distance field and blending between outline and inside colors.

Sequence Diagram(s)

Silently omitted generating diagrams, as the changes pertain to multiple varied enhancements and new utility features rather than a cohesive control flow or feature.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai bot changed the title auto Add Notifications module with management, display, and rendering features Jul 18, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 15

Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 7b8b29a and 02c2822.

Files ignored due to path filters (2)
  • src/main/resources/assets/keystrokesmod/fonts/icon.ttf is excluded by !**/*.ttf
  • src/main/resources/assets/keystrokesmod/fonts/regular.ttf is excluded by !**/*.ttf
Files selected for processing (13)
  • src/main/java/keystrokesmod/module/ModuleManager.java (1 hunks)
  • src/main/java/keystrokesmod/module/impl/client/Notifications.java (1 hunks)
  • src/main/java/keystrokesmod/module/impl/render/BedPlates.java (3 hunks)
  • src/main/java/keystrokesmod/utility/font/Font.java (2 hunks)
  • src/main/java/keystrokesmod/utility/font/FontManager.java (6 hunks)
  • src/main/java/keystrokesmod/utility/font/impl/FontRenderer.java (4 hunks)
  • src/main/java/keystrokesmod/utility/font/impl/FontUtil.java (1 hunks)
  • src/main/java/keystrokesmod/utility/font/impl/MinecraftFontRenderer.java (2 hunks)
  • src/main/java/keystrokesmod/utility/render/AnimationUtils.java (1 hunks)
  • src/main/java/keystrokesmod/utility/render/ColorUtils.java (1 hunks)
  • src/main/java/keystrokesmod/utility/render/RRectUtils.java (1 hunks)
  • src/main/resources/assets/keystrokesmod/shaders/rrectGradient.frag (1 hunks)
  • src/main/resources/assets/keystrokesmod/shaders/rrectOutline.frag (1 hunks)
Additional comments not posted (34)
src/main/resources/assets/keystrokesmod/shaders/rrectOutline.frag (5)

1-2: GLSL version directive is appropriate.

The #version 120 directive is suitable for older OpenGL versions.


3-5: Uniform variable declarations are appropriate.

The uniform variables declared are necessary for the shader's functionality.


7-9: roundedSDF function implementation is correct.

The function correctly calculates the signed distance function for a rounded rectangle.


11-13: Distance calculation in main function is correct.

The distance calculation using roundedSDF is correctly implemented.


14-19: Color blending and setting in main function is correct.

The blending and color setting logic based on the distance is correctly implemented.

src/main/resources/assets/keystrokesmod/shaders/rrectGradient.frag (5)

1-2: GLSL version directive is appropriate.

The #version 120 directive is suitable for older OpenGL versions.


3-6: Uniform variable declarations and macro are appropriate.

The uniform variables and the NOISE macro are necessary for the shader's functionality.


8-10: roundSDF function implementation is correct.

The function correctly calculates the signed distance function for a rounded rectangle.


12-16: createGradient function implementation is correct.

The function correctly generates a gradient color based on the coordinates.


18-24: Gradient generation and color setting in main function is correct.

The main function correctly generates the gradient and sets the fragment color.

src/main/java/keystrokesmod/utility/font/Font.java (3)

3-4: Import statement is appropriate.

The import statement for MinecraftFontRenderer is necessary for the new methods.


7-7: New drawString method is correctly added.

The method supports additional parameters for center mode, shadow, and color.


17-17: New wrapText method is correctly added.

The method supports text wrapping with additional parameters.

src/main/java/keystrokesmod/utility/render/AnimationUtils.java (6)

1-2: Package declaration is appropriate.

The package declaration is suitable for the class.


3-6: Class declaration and private fields are appropriate.

The class AnimationUtils and its private fields value and lastMS are suitable for the functionality.


7-10: Constructor implementation is correct.

The constructor correctly initializes the fields value and lastMS.


12-33: calculateCompensation method implementation is correct.

The method correctly calculates the compensation based on the target, current value, speed, and delta time.


35-50: setAnimation method implementation is correct.

The method correctly sets the animation value based on the speed and delta time.


52-54: getValue method implementation is correct.

The method correctly returns the current animation value.

src/main/java/keystrokesmod/utility/font/impl/FontUtil.java (1)

16-16: LGTM! Enhanced error handling and logging.

The enhanced error handling and logging improve the robustness of the getResource method.

src/main/java/keystrokesmod/utility/render/ColorUtils.java (1)

1-1: LGTM! New utility class for handling colors.

The new ColorUtils class provides various utility methods for handling colors.

src/main/java/keystrokesmod/utility/font/impl/MinecraftFontRenderer.java (3)

13-39: LGTM! Enhanced text rendering with centering modes and shadow effects.

The enhanced drawString method provides more flexibility in text rendering with different centering modes and shadow effects.


44-69: LGTM! New method for text wrapping with centering modes and shadow effects.

The new wrapText method enhances text rendering by handling text wrapping and supporting different centering modes and shadow effects.


100-105: LGTM! New enum for centering modes.

The CenterMode enum provides a clear and maintainable way to handle different centering options in text rendering.

src/main/java/keystrokesmod/module/impl/client/Notifications.java (4)

21-34: LGTM! Constructor and static fields initialization.

The constructor and static fields are correctly initialized and registered, providing the necessary setup for managing notifications.


36-49: LGTM! Method for sending notifications.

The sendNotification method correctly handles different notification types and integrates with the chatNoti setting.


51-71: LGTM! Method for rendering notifications and managing animations.

The onTick method correctly handles rendering notifications and managing their animations and durations.


74-79: LGTM! New enum for notification types.

The NotificationTypes enum provides a clear and maintainable way to handle different notification types.

src/main/java/keystrokesmod/utility/font/FontManager.java (1)

202-203: Improve error handling for font loading.

The method sends a message on font loading failure but does not handle the failure properly.

+ if (font == null) {
+     Utils.sendMessage("Failed to load font: " + name);
+     return null;
+ }
src/main/java/keystrokesmod/module/impl/render/BedPlates.java (2)

Line range hint 1-1:
Verify the necessity of commenting out the bedwarsOnly setting.

Ensure that the bedwarsOnly setting is no longer needed and does not affect the functionality.

Verification successful

The bedwarsOnly setting is no longer needed and does not affect the functionality.

  • No occurrences of bedwarsOnly were found in the Java code, comments, or configuration files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `bedwarsOnly` setting is no longer needed.

# Test: Search for the usage of `bedwarsOnly` setting. Expect: No occurrences.
rg --type java 'bedwarsOnly'

Length of output: 28


Script:

#!/bin/bash
# Description: Verify that the `bedwarsOnly` setting is no longer needed.

# Test 1: Search for the usage of `bedwarsOnly` in Java comments. Expect: No occurrences.
rg --type java '//.*bedwarsOnly' -A 2

# Test 2: Search for the usage of `bedwarsOnly` in configuration files (e.g., .properties, .xml). Expect: No occurrences.
rg 'bedwarsOnly' --glob '*.properties' --glob '*.xml'

Length of output: 93


Line range hint 1-1:
Verify the removal of imports.

Ensure that the removal of RenderHandEvent and TickEvent imports does not affect the functionality.

Verification successful

Verify the removal of RenderHandEvent and TickEvent in BedPlates.java.

The removal of RenderHandEvent is justified as it is not used anywhere in the codebase. However, TickEvent is still in use in multiple files. Ensure that its removal from BedPlates.java does not affect the functionality.


Verify the removal of RenderHandEvent and TickEvent in BedPlates.java.

The imports for RenderHandEvent and TickEvent were present in BedPlates.java. Ensure that their removal does not affect the functionality by verifying their actual usage in the previous versions of the file.


Verify the removal of RenderHandEvent and TickEvent in BedPlates.java.

The imports for RenderHandEvent and TickEvent were present in BedPlates.java. Ensure that their removal does not affect the functionality by verifying the methods or event handlers that might have used these events in the previous versions of the file.


Verification successful: Removal of RenderHandEvent and TickEvent imports

The imports for RenderHandEvent and TickEvent were present in BedPlates.java but were not used in any of the event handler methods. Their removal does not affect the functionality.

  • RenderHandEvent was never used.
  • TickEvent was never used.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `RenderHandEvent` and `TickEvent` are no longer used in the codebase.

# Test: Search for the usage of `RenderHandEvent` and `TickEvent`. Expect: No occurrences.
rg --type java 'RenderHandEvent|TickEvent'

Length of output: 12301


Script:

#!/bin/bash
# Description: Verify if `RenderHandEvent` and `TickEvent` were used in `BedPlates.java` before their removal.

# Search for `RenderHandEvent` and `TickEvent` in the history of `BedPlates.java`
git log -p -- src/main/java/keystrokesmod/module/impl/render/BedPlates.java | grep -E 'RenderHandEvent|TickEvent'

Length of output: 347


Script:

#!/bin/bash
# Description: Verify the usage of `RenderHandEvent` and `TickEvent` in the previous versions of `BedPlates.java`.

# Search for the usage of `RenderHandEvent` and `TickEvent` in the history of `BedPlates.java`
git log -p -- src/main/java/keystrokesmod/module/impl/render/BedPlates.java | grep -A 10 -E 'RenderHandEvent|TickEvent'

Length of output: 1434


Script:

#!/bin/bash
# Description: Verify the usage of `RenderHandEvent` and `TickEvent` in the previous versions of `BedPlates.java`.

# Search for methods or event handlers in the history of `BedPlates.java` that might have used `RenderHandEvent` and `TickEvent`.
git log -p -- src/main/java/keystrokesmod/module/impl/render/BedPlates.java | grep -A 20 -E '@SubscribeEvent|RenderHandEvent|TickEvent'

Length of output: 3495

src/main/java/keystrokesmod/module/ModuleManager.java (1)

113-113: LGTM! Ensure the Notifications module is correctly integrated.

The addition of the Notifications module looks good. Verify that it is correctly integrated and does not cause any issues.

src/main/java/keystrokesmod/utility/font/impl/FontRenderer.java (2)

4-4: Imports look good.

The imports for ColorUtils, ArrayList, and List are necessary for the new methods added to the class.

Also applies to: 16-17


203-204: Verify ColorUtils.resetColor().

Ensure that ColorUtils.resetColor() is correctly resetting the color state as expected.

Verification successful

Verification successful for ColorUtils.resetColor().

The method ColorUtils.resetColor() correctly resets the color state by setting it to white with full opacity using GlStateManager.color(1, 1, 1, 1). The GlStateManager class is part of the Minecraft client renderer package, indicating it is an external dependency that handles color state changes as expected.

  • src/main/java/keystrokesmod/utility/render/ColorUtils.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `ColorUtils.resetColor()`.

# Test: Search for the implementation. Expect: Correct color state reset logic.
rg --type java 'void resetColor()' --context 5

Length of output: 1004


Script:

#!/bin/bash
# Description: Verify the implementation of `GlStateManager.color`.

# Test: Search for the implementation. Expect: Correct color state setting logic.
rg --type java 'void color' --context 5

Length of output: 41


Script:

#!/bin/bash
# Description: Search for the definition and relevant usage of `GlStateManager`.

# Test: Search for `GlStateManager` definition. Expect: Locate the class and its methods.
rg --type java 'class GlStateManager' --context 5

Length of output: 51


Script:

#!/bin/bash
# Description: Search for references to `GlStateManager` in the codebase.

# Test: Search for `GlStateManager` references. Expect: Locate import statements and usages.
rg --type java 'GlStateManager'

Length of output: 29323

TejasLamba2006 and others added 2 commits July 18, 2024 14:23
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 02c2822 and ac8d071.

Files selected for processing (1)
  • src/main/java/keystrokesmod/utility/render/ColorUtils.java (1 hunks)
Additional comments not posted (4)
src/main/java/keystrokesmod/utility/render/ColorUtils.java (4)

21-34: LGTM!

The getBackgroundColor method is well-structured and uses a switch statement for better readability.


71-73: LGTM!

The getFontColor method with a default alpha value is straightforward and does not require any changes.


82-84: LGTM!

The setColor method without alpha is straightforward and does not require any changes.


90-92: LGTM!

The stripColor method is straightforward and does not require any changes.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Owner

@xia-mc xia-mc left a comment

Choose a reason for hiding this comment

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

Great

@xia-mc xia-mc merged commit 8479314 into dev Jul 18, 2024
2 checks passed
@TejasLamba2006 TejasLamba2006 deleted the feat/Notifications branch July 18, 2024 10:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants