Skip to content

feat: Add WeatherCommand for flexible weather control and persistence#1332

Open
vLuckyyy wants to merge 1 commit intomasterfrom
add-weather-command
Open

feat: Add WeatherCommand for flexible weather control and persistence#1332
vLuckyyy wants to merge 1 commit intomasterfrom
add-weather-command

Conversation

@vLuckyyy
Copy link
Copy Markdown
Member

@vLuckyyy vLuckyyy commented Apr 6, 2026

Added a new /weather command for simple world weather control.

Usage:

/weather <sun|rain|thunder> [world] [-p]
/weather clear [world]

Behavior:

  • Sets weather in the sender's current world or in a specified world.
  • -p makes the weather persistent by disabling the natural weather cycle.
  • clear re-enables the natural weather cycle for the target world.

* Introduced WeatherCommand to allow setting weather conditions with optional persistence.
* Implemented WeatherService to manage weather changes and persistence logic.
* Replaced SunCommand, RainCommand, and ThunderCommand logic with WeatherService integration.
* Enhanced weather-related notices to include persistence messages.
@vLuckyyy vLuckyyy requested a review from a team as a code owner April 6, 2026 17:02
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a WeatherService to centralize weather logic and adds a new /weather command that supports weather persistence by toggling the DO_WEATHER_CYCLE gamerule. Review feedback highlights a potential side effect where the gamerule is reset even when persistence isn't requested, suggests aligning /weather clear with vanilla behavior by setting the weather to sun, and notes localization issues caused by using enum names directly in messages.

Comment on lines +21 to +26
void setWeather(World world, WeatherType weatherType, boolean persistent) {
this.scheduler.run(() -> {
this.applyWeather(world, weatherType);
world.setGameRule(GameRule.DO_WEATHER_CYCLE, !persistent);
});
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The current implementation of setWeather always updates the DO_WEATHER_CYCLE gamerule. If persistent is false, it explicitly sets it to true. This can unintentionally overwrite a global server setting where an administrator has disabled the weather cycle for other reasons (e.g., a static clear-sky world). It is safer to only modify the gamerule when persistence is explicitly requested, and let the /weather clear command handle re-enabling the cycle.

Comment on lines +84 to +92
private void clearWeather(Viewer viewer, World world) {
this.weatherService.clearPersistentWeather(world);

this.noticeService.create()
.viewer(viewer)
.placeholder("{WORLD}", world.getName())
.notice(translation -> translation.timeAndWeather().weatherPersistenceDisabled())
.send();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The /weather clear command currently only re-enables the natural weather cycle but does not change the current weather state. In vanilla Minecraft, /weather clear is used to set the weather to sunny. This discrepancy might be confusing for players who expect the rain to stop immediately. Consider making this command also set the weather to SUN to align with vanilla expectations.

this.noticeService.create()
.viewer(viewer)
.placeholder("{WORLD}", world.getName())
.placeholder("{WEATHER}", weatherType.name().toLowerCase(Locale.ROOT))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using weatherType.name().toLowerCase(Locale.ROOT) for the {WEATHER} placeholder may lead to localization issues. In many languages (like Polish), the weather type needs to be a specific noun or adjective that agrees grammatically with the rest of the sentence (e.g., gender or case agreement). Hardcoding the enum name prevents proper translation of this part of the message.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c82544c4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

void setWeather(World world, WeatherType weatherType, boolean persistent) {
this.scheduler.run(() -> {
this.applyWeather(world, weatherType);
world.setGameRule(GameRule.DO_WEATHER_CYCLE, !persistent);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid forcing weather cycle on every non-persistent set

WeatherService#setWeather now always writes DO_WEATHER_CYCLE to true when persistent is false, and all legacy /sun, /rain, and /thunder commands call this path with false. That introduces a regression where using those commands silently re-enables the weather cycle in worlds that were intentionally locked (by config, gamerule, or a prior /weather -p), changing global world behavior beyond just setting the current weather. Consider only changing DO_WEATHER_CYCLE when the user explicitly requests persistence changes (-p or clear).

Useful? React with 👍 / 👎.

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.

1 participant