-
Notifications
You must be signed in to change notification settings - Fork 52
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
Introduce Ambience
module
#80
Conversation
WalkthroughThe recent changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ModuleManager
participant Ambience
User->>ModuleManager: Start Application
ModuleManager->>Ambience: Initialize and Register Ambience Module
User->>Ambience: Adjust Time, Weather, Speed Settings
Ambience-->>User: Apply Ambience Settings
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/main/java/keystrokesmod/module/ModuleManager.java (2 hunks)
- src/main/java/keystrokesmod/module/impl/render/Ambience.java (1 hunks)
Additional comments not posted (9)
src/main/java/keystrokesmod/module/impl/render/Ambience.java (7)
14-14
: Initialization oftime
The
time
field is correctly initialized and registered.
15-15
: Initialization ofspeed
The
speed
field is correctly initialized and registered.
16-16
: Initialization ofweather
The
weather
field is correctly initialized and registered.
19-26
: Constructor ImplementationThe constructor correctly initializes the module and registers the settings.
29-36
: MethodonDisable
ImplementationThe
onDisable
method correctly resets the weather settings.
39-41
: Verify World Time Calculation inonRenderTick
The calculation of the world time might need clarification. Ensure that the formula correctly updates the world time based on the settings.
69-81
: MethodonReceivePacket
ImplementationThe
onReceivePacket
method correctly cancels the packet events based on their type and weather settings.src/main/java/keystrokesmod/module/ModuleManager.java (2)
95-95
: Addition ofAmbience
ModuleThe
Ambience
module has been correctly added as a public static instance.
218-218
: Registration ofAmbience
ModuleThe
Ambience
module has been correctly registered in theregister
method.
public void onPreMotion(PreMotionEvent event) { | ||
if (mc.thePlayer.ticksExisted % 20 == 0) { | ||
|
||
switch ((int) this.weather.getInput()) { | ||
case 1: { | ||
mc.theWorld.setRainStrength(0); | ||
mc.theWorld.getWorldInfo().setCleanWeatherTime(Integer.MAX_VALUE); | ||
mc.theWorld.getWorldInfo().setRainTime(0); | ||
mc.theWorld.getWorldInfo().setThunderTime(0); | ||
mc.theWorld.getWorldInfo().setRaining(false); | ||
mc.theWorld.getWorldInfo().setThundering(false); | ||
break; | ||
} | ||
case 2: | ||
mc.theWorld.setRainStrength(1); | ||
mc.theWorld.getWorldInfo().setCleanWeatherTime(0); | ||
mc.theWorld.getWorldInfo().setRainTime(Integer.MAX_VALUE); | ||
mc.theWorld.getWorldInfo().setThunderTime(Integer.MAX_VALUE); | ||
mc.theWorld.getWorldInfo().setRaining(true); | ||
mc.theWorld.getWorldInfo().setThundering(false); | ||
} | ||
} |
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.
Refactor onPreMotion
for Readability
The weather settings update logic can be refactored to improve readability.
- switch ((int) this.weather.getInput()) {
- case 1: {
- mc.theWorld.setRainStrength(0);
- mc.theWorld.getWorldInfo().setCleanWeatherTime(Integer.MAX_VALUE);
- mc.theWorld.getWorldInfo().setRainTime(0);
- mc.theWorld.getWorldInfo().setThunderTime(0);
- mc.theWorld.getWorldInfo().setRaining(false);
- mc.theWorld.getWorldInfo().setThundering(false);
- break;
- }
- case 2:
- mc.theWorld.setRainStrength(1);
- mc.theWorld.getWorldInfo().setCleanWeatherTime(0);
- mc.theWorld.getWorldInfo().setRainTime(Integer.MAX_VALUE);
- mc.theWorld.getWorldInfo().setThunderTime(Integer.MAX_VALUE);
- mc.theWorld.getWorldInfo().setRaining(true);
- mc.theWorld.getWorldInfo().setThundering(false);
- }
+ if (this.weather.getInput() == 1) {
+ setWeatherClear();
+ } else if (this.weather.getInput() == 2) {
+ setWeatherRain();
+ }
+
+ private void setWeatherClear() {
+ mc.theWorld.setRainStrength(0);
+ mc.theWorld.getWorldInfo().setCleanWeatherTime(Integer.MAX_VALUE);
+ mc.theWorld.getWorldInfo().setRainTime(0);
+ mc.theWorld.getWorldInfo().setThunderTime(0);
+ mc.theWorld.getWorldInfo().setRaining(false);
+ mc.theWorld.getWorldInfo().setThundering(false);
+ }
+
+ private void setWeatherRain() {
+ mc.theWorld.setRainStrength(1);
+ mc.theWorld.getWorldInfo().setCleanWeatherTime(0);
+ mc.theWorld.getWorldInfo().setRainTime(Integer.MAX_VALUE);
+ mc.theWorld.getWorldInfo().setThunderTime(Integer.MAX_VALUE);
+ mc.theWorld.getWorldInfo().setRaining(true);
+ mc.theWorld.getWorldInfo().setThundering(false);
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public void onPreMotion(PreMotionEvent event) { | |
if (mc.thePlayer.ticksExisted % 20 == 0) { | |
switch ((int) this.weather.getInput()) { | |
case 1: { | |
mc.theWorld.setRainStrength(0); | |
mc.theWorld.getWorldInfo().setCleanWeatherTime(Integer.MAX_VALUE); | |
mc.theWorld.getWorldInfo().setRainTime(0); | |
mc.theWorld.getWorldInfo().setThunderTime(0); | |
mc.theWorld.getWorldInfo().setRaining(false); | |
mc.theWorld.getWorldInfo().setThundering(false); | |
break; | |
} | |
case 2: | |
mc.theWorld.setRainStrength(1); | |
mc.theWorld.getWorldInfo().setCleanWeatherTime(0); | |
mc.theWorld.getWorldInfo().setRainTime(Integer.MAX_VALUE); | |
mc.theWorld.getWorldInfo().setThunderTime(Integer.MAX_VALUE); | |
mc.theWorld.getWorldInfo().setRaining(true); | |
mc.theWorld.getWorldInfo().setThundering(false); | |
} | |
} | |
public void onPreMotion(PreMotionEvent event) { | |
if (mc.thePlayer.ticksExisted % 20 == 0) { | |
if (this.weather.getInput() == 1) { | |
setWeatherClear(); | |
} else if (this.weather.getInput() == 2) { | |
setWeatherRain(); | |
} | |
} | |
} | |
private void setWeatherClear() { | |
mc.theWorld.setRainStrength(0); | |
mc.theWorld.getWorldInfo().setCleanWeatherTime(Integer.MAX_VALUE); | |
mc.theWorld.getWorldInfo().setRainTime(0); | |
mc.theWorld.getWorldInfo().setThunderTime(0); | |
mc.theWorld.getWorldInfo().setRaining(false); | |
mc.theWorld.getWorldInfo().setThundering(false); | |
} | |
private void setWeatherRain() { | |
mc.theWorld.setRainStrength(1); | |
mc.theWorld.getWorldInfo().setCleanWeatherTime(0); | |
mc.theWorld.getWorldInfo().setRainTime(Integer.MAX_VALUE); | |
mc.theWorld.getWorldInfo().setThunderTime(Integer.MAX_VALUE); | |
mc.theWorld.getWorldInfo().setRaining(true); | |
mc.theWorld.getWorldInfo().setThundering(false); | |
} |
Summary by CodeRabbit