28 Commits

Author SHA1 Message Date
cdf5cd5d95 Version 1.3.0-beta1 (Fabric) (#17)
* [1.3.0-beta1] Update to 1.21.11

* Fix deploy workflow
2025-12-10 18:21:53 +13:00
80d34ab146 Update README (#16)
* Update README

* Remove new release

* 1.21.0 => 1.21

* Improve wording
2025-12-10 11:13:01 +13:00
0e4c5e1036 Fix issue with refmap naming (#14)
* Fix issue with refmap naming

* Update README
2025-06-20 14:42:20 +12:00
99f504b9ca docs: fix release tag link for v1.2.1 2024-12-16 13:40:40 +13:00
ac040b84cd fix: update to loom 1.7 to fix forge crashing on launch (#12)
This commit also releases Weather Changer v1.2.1
2024-12-16 13:28:39 +13:00
37645401e3 docs: add version 1.2.0 to README 2024-10-21 19:28:44 +13:00
8c344ec47d fix: client allowing trident use while server weather not thundering
This change fixes some issues where when using weather changer and setting your client weather to thunder trident usage would be allowed even when the server weather was not thundering, also fixes an issue where on single player mobs would spawn when client weather was set to rain or thunder

This commit also releases version 1.2.0
2024-10-21 19:05:51 +13:00
Amirhan-Taipovjan-Greatest-I
2dc3d64ca1 Actualized Tatar and Russian Translations! (#9)
* Actualized Vanilla-ish Tatar Translation!

* Updated ≈Vanilla-ish Russian Translation!
2024-08-18 14:00:50 +12:00
Thierry Schmid
c5f5a278e3 Timer functionality as suggested a month ago (#7)
* first implementation of timer

* first implementation of timer

* String message turned to a translatable text
2024-08-10 22:34:26 +12:00
4ee3169caa fix: java 21 on release ci 2024-08-09 14:50:40 +12:00
0f7343078b Merge branch 'refs/heads/develop'
# Conflicts:
#	.github/workflows/release.yml
2024-08-09 14:48:43 +12:00
6f0d8d11f6 ci: fix release workflow 2024-08-09 14:47:00 +12:00
e1566f6c5b 1.21 Fabric (#8)
Prep for release of version 1.1.0 (MC 1.21 for Fabric only)
2024-08-09 14:24:09 +12:00
338aeeca56 docs: remove outdated link 2024-08-09 14:18:07 +12:00
4e53b55b1e Java 21 2024-08-09 14:16:32 +12:00
73fbd40685 1.21 Fabric 2024-08-09 14:13:55 +12:00
9390eb3881 [skip ci] docs: confirm 1.20.6 support add 1.0.1 version to README 2024-05-01 15:05:31 +12:00
67524f1cb8 Merge pull request #5 from Lucaslah/develop
feat: make text translatable + bump to version 1.0.1
2024-04-30 23:06:47 +12:00
184ce53df8 Merge pull request #6 from Amirhan-Taipovjan-Greatest-I/patch-1
Vanilla-ish Tatar Translation and ≈Vanilla-ish Russian Translation.
2024-04-30 23:01:36 +12:00
Amirhan-Taipovjan-Greatest-I
4dbfe76b45 Updated ModMenu Metadata Translation. 2024-04-30 13:55:55 +03:00
Amirhan-Taipovjan-Greatest-I
145c638746 Russian Translation.
It is not quite Vanilla-ish, but I tried to do My best.
2024-04-30 13:53:04 +03:00
Amirhan-Taipovjan-Greatest-I
22372cdd63 Vanilla-ish Tatar Translation. 2024-04-30 13:49:26 +03:00
604d98ac13 fix: update architectury + add base archive name to build
- [bug] add base archive name to build artifacts
- [deps] update architectury loom from 1.4-SNAPSHOT -> 1.5
- [deps] update architectury plugin to non snapshot build
- [bug] fixes an unchecked cast warning during the build
2024-04-30 12:01:12 +12:00
4c046a3828 fix: make keys press text translatable 2024-04-30 11:00:27 +12:00
274c6bb035 Merge branch 'main' into develop 2024-04-29 19:14:11 +12:00
ff08c6ee77 feat: make text translatable + bump to version 1.0.1 2024-04-29 19:10:49 +12:00
cc5d9d2d51 [skip ci] auto deploy website on push 2024-04-04 21:37:06 +13:00
7aedf2fd4a [skip ci] add website deployment 2024-04-04 21:19:15 +13:00
28 changed files with 336 additions and 198 deletions

View File

@@ -2,8 +2,7 @@ name: Build
on:
push:
branches-ignore:
- main
pull_request:
jobs:
build:
@@ -11,11 +10,11 @@ jobs:
env:
CI_DEV_BUILD: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Setup build number
run: echo "BUILD_NUMBER=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
@@ -26,7 +25,7 @@ jobs:
with:
arguments: build
- name: Upload Build Results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: weather-changer-build
path: |

View File

@@ -2,18 +2,19 @@ name: Release
on:
push:
branches:
- main
tags:
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Make gradlew executable
run: chmod +x ./gradlew
@@ -22,7 +23,7 @@ jobs:
with:
arguments: build
- name: Upload Build Results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build
path: |
@@ -37,13 +38,13 @@ jobs:
GH_TOKEN: ${{ github.token }}
needs: [build]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Create Release
run: |
mkdir dist
mv build/fabric/build/libs/*.jar dist
mv build/forge/build/libs/*.jar dist
shopt -s nullglob
mv build/{fabric,forge}/build/libs/*.jar dist/
pushd dist
shasum -a 256 * > checksums.txt
@@ -58,4 +59,8 @@ jobs:
--generate-notes
)
if [[ "$channel" == "alpha" || "$channel" == "beta" ]]; then
release_args+=( --prerelease )
fi
gh release create "${release_args[@]}" ./dist/*

41
.github/workflows/website.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: Deploy Website
on:
workflow_dispatch:
push:
branches:
- gh-pages
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
deploy-website:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

View File

View File

@@ -1,3 +1,5 @@
<!-- modrinth_exclude.start -->
<!--suppress HtmlDeprecatedAttribute -->
<p align="center" style="display: block;margin-left: auto;margin-right: auto;margin-bottom: 0">
<img src="assets/logo-242x242.png" alt="Weather Changer Logo"/>
@@ -13,6 +15,8 @@
<img src="assets/banner.png" alt="Weather Changer Banner"/>
</p>
<!-- modrinth_exclude.end -->
## Overview
Changes the weather on client side (only visible to you) to clear, rain, or thunder, this mod does not affect the server or send any packets to the server.
@@ -24,55 +28,38 @@ Supports forge and fabric, requires the [Fabric API](https://modrinth.com/mod/P7
The command alias `/cweather` may also be used as a shortcut.
### Keybindings
To set the keybindings you can do so in the minecraft keybinding settings.
If you would like to set the keybindings, you can do so in the minecraft keybinding settings.
| Description | Default |
|----------------------------------------------------------------------------------|---------|
| Disable the client weather (weather will display the server weather like normal) | Unbound |
| Set the client weather mod to clear | Unbound |
| Set the client weather mod to rain | Unbound |
| Set the client weather mod to thunder | Unbound |
For supported mod loaders and minecraft versions see [release history](#release-history)
| Set the client weather mod to thunder | Unbound |
<!-- modrinth_exclude.start -->
## Download
You can download the mod from any of the platforms below.
**Modrinth (_recommended_)**: https://modrinth.com/mod/weather-changer <br>
**Curseforge**: https://www.curseforge.com/minecraft/mc-mods/weather-changer <br>
**Modrinth**: https://modrinth.com/mod/weather-changer <br>
**GitHub Releases:** https://github.com/Lucaslah/WeatherChanger/releases <br>
**Release Server**: https://release.cssudii.xyz/projects/weatherchanger
<!-- modrinth_exclude.end -->
## Release History
| Branch | Version | MC Version | Mod loaders | Git Tag | CI | Supported |
|--------|---------|---------------|---------------|------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
| main | v1.0.0 | 1.20.1-1.20.4 | fabric, forge | [1.0.0](https://github.com/Lucaslah/WeatherChanger/releases/tag/1.0.0) | [![Build](https://github.com/Lucaslah/WeatherChanger/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/Lucaslah/WeatherChanger/actions/workflows/release.yml) | Yes |
## Supported Versions
### Pre-release (v0) versions
| Branch | Version | MC Version | Mod loaders | Git Tag | CI | Supported |
|--------|---------|---------------|-------------|------------------------------------------------------------------------|-----|-----------|
| N/A | v0.3.0 | 1.20.1-1.20.4 | fabric | [0.3.0](https://github.com/Lucaslah/WeatherChanger/releases/tag/0.3.0) | N/A | No |
| N/A | v0.2.0 | 1.19.3 | fabric | [0.2.0](https://github.com/Lucaslah/WeatherChanger/releases/tag/0.2.0) | N/A | No |
| N/A | v0.1.0 | 1.19.1-1.19.2 | fabric | [0.1.0](https://github.com/Lucaslah/WeatherChanger/releases/tag/0.1.0) | N/A | No |
Supported versions may receive bug fixes,
older Minecraft versions may work with older
Weather Changer versions, but are not supported.
## Minecraft Versions
| Version | Status |
|---------|---------------------------------|
| 1.20.4 | Supported |
| 1.20.3 | Supported |
| 1.20.2 | Supported |
| 1.20.1 | Supported |
| 1.20 | Not Supported (available in v0) |
| 1.19.4 | Not Supported (available in v0) |
| 1.19.3 | Not Supported (available in v0) |
| 1.19.2 | Not Supported (available in v0) |
| 1.19.1 | Not Supported (available in v0) |
See the [GitHub releases](https://github.com/Lucaslah/WeatherChanger/releases) page for full release history.
*Older versions may be added on request*
| Weather Changer Version | Minecraft Version | Mod loaders | Latest Release |
|-------------------------|-------------------|---------------|------------------------------------------------------------------------------------|
| v1.3.x | 1.21.11 | Fabric, Forge | [1.3.0-beta1](https://github.com/Lucaslah/WeatherChanger/releases/tag/1.3.0-beta1) |
| v1.2.x | 1.21-1.21.10 | Fabric, Forge | [1.2.2](https://github.com/Lucaslah/WeatherChanger/releases/tag/1.2.2) |
------------------------------------------
*Licensed under the [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html) license.*

View File

@@ -1,32 +1,45 @@
import io.github.themrmilchmann.gradle.publish.curseforge.ChangelogFormat
import io.github.themrmilchmann.gradle.publish.curseforge.GameVersion
import io.github.themrmilchmann.gradle.publish.curseforge.ReleaseType
import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.RemapSourcesJarTask
plugins {
id("architectury-plugin") version "3.4-SNAPSHOT"
id ("dev.architectury.loom") version "1.4-SNAPSHOT" apply false
id("com.modrinth.minotaur") version "2.+"
id("io.github.themrmilchmann.curseforge-publish") version "0.6.1"
id("architectury-plugin") version "3.4.+"
id("dev.architectury.loom") version "1.13.+" apply false
}
architectury {
injectInjectables = false
minecraft = properties["minecraft_version"].toString()
}
subprojects {
apply(plugin = "java")
apply(plugin = "architectury-plugin")
apply(plugin = "dev.architectury.loom")
dependencies {
"minecraft"("com.mojang:minecraft:${properties["minecraft_version"]}")
"mappings"("net.fabricmc:yarn:${rootProject.properties["yarn_mappings"]}:v2")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(21)
}
tasks.withType<Jar> {
archiveBaseName.set(properties["archives_base_name"].toString() + "-${project.name}")
}
tasks.withType<RemapJarTask> {
archiveBaseName.set(properties["archives_base_name"].toString() + "-${project.name}")
}
tasks.withType<RemapSourcesJarTask> {
archiveBaseName.set(properties["archives_base_name"].toString() + "-${project.name}")
}
}
allprojects {
apply(plugin = "java")
apply(plugin = "maven-publish")
apply(plugin = "architectury-plugin")
version = if (System.getenv("CI_DEV_BUILD")?.toBoolean() == true) {
System.getenv("BUILD_NUMBER") ?: properties["mod_version"].toString()
@@ -35,58 +48,4 @@ allprojects {
}
group = properties["maven_group"].toString()
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}
tasks.withType<Jar> {
archiveBaseName.set(properties["archives_base_name"].toString())
}
}
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("nhSHTGyl")
versionNumber.set(properties["mod_version"].toString())
versionType.set(properties["release_channel"].toString())
uploadFile.set("build/libs/weather-changer-1.0.0.jar")
gameVersions.addAll("1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4")
loaders.add("fabric")
loaders.add("forge")
dependencies {
required.project("fabric-api")
}
syncBodyFrom = rootProject.file("README.md").readText()
}
curseforge {
apiToken = System.getenv("CURSEFORGE_TOKEN")
publications {
register("curseForge") {
projectId = "682513"
gameVersions.add(GameVersion("minecraft-1-20", "1.20"))
gameVersions.add(GameVersion("minecraft-1-20", "1.20.1"))
gameVersions.add(GameVersion("minecraft-1-20", "1.20.2"))
gameVersions.add(GameVersion("minecraft-1-20", "1.20.3"))
gameVersions.add(GameVersion("minecraft-1-20", "1.20.4"))
artifacts.register("main") {
displayName = "Weather Changer"
// TODO: read from file
releaseType = ReleaseType.BETA
changelog {
// TODO: get from git diff
format = ChangelogFormat.MARKDOWN
from(file("CHANGELOG.md"))
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
architectury {
injectInjectables = false
common(rootProject.property("enabled_platforms").toString().split(","))
}

View File

@@ -11,6 +11,7 @@ import me.lucaslah.weatherchanger.keys.ToggleClearKey;
import me.lucaslah.weatherchanger.keys.ToggleOffKey;
import me.lucaslah.weatherchanger.keys.ToggleRainKey;
import me.lucaslah.weatherchanger.keys.ToggleThunderKey;
import me.lucaslah.weatherchanger.timerlogic.Timer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
@@ -27,6 +28,8 @@ public class WeatherChanger {
private static WeatherChangerPlatform platform;
private static KeybindingManager keybindingManager;
private static CommandManager commandManager;
private static Timer weatherTimer;
private static boolean timerEnabled = false; // Default to false
public static void init(WeatherChangerPlatform platform) {
WeatherChanger.platform = platform;
@@ -57,6 +60,8 @@ public class WeatherChanger {
.add(new ToggleThunderKey());
commandManager.add(new WeatherChangerCommand());
weatherTimer = new Timer();
}
private static void loadConfig() {
@@ -148,7 +153,15 @@ public class WeatherChanger {
return commandManager;
}
public static void sendClientMessage(String message) {
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.literal(message));
public static void sendClientMessage(Text message) {
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(message);
}
public static void toggleTimer() {
timerEnabled = !timerEnabled;
}
public static boolean isTimerEnabled() {
return timerEnabled;
}
}

View File

@@ -2,11 +2,11 @@ package me.lucaslah.weatherchanger.commands;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import me.lucaslah.weatherchanger.WeatherChanger;
import me.lucaslah.weatherchanger.command.Command;
import me.lucaslah.weatherchanger.config.WcMode;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import static me.lucaslah.weatherchanger.WeatherChanger.sendClientMessage;
@@ -14,12 +14,12 @@ import static me.lucaslah.weatherchanger.WeatherChanger.sendClientMessage;
public class WeatherChangerCommand extends Command {
@Override
public <T> void register(CommandDispatcher<T> dispatcher) {
LiteralArgumentBuilder<T> command = LiteralArgumentBuilder.<T>literal("clientweather");
LiteralArgumentBuilder<T> command = LiteralArgumentBuilder.literal("clientweather");
command.then(LiteralArgumentBuilder.<T>literal("off")
.executes(context -> {
WeatherChanger.setMode(WcMode.OFF);
sendClientMessage("Set client weather to: Off");
sendClientMessage(Text.translatable("commands.weatherchanger.set.off"));
return 1;
})
);
@@ -27,7 +27,7 @@ public class WeatherChangerCommand extends Command {
command.then(LiteralArgumentBuilder.<T>literal("clear")
.executes(context -> {
WeatherChanger.setMode(WcMode.CLEAR);
sendClientMessage("Set client weather to: Clear");
sendClientMessage(Text.translatable("commands.weatherchanger.set.clear"));
return 1;
})
);
@@ -35,7 +35,7 @@ public class WeatherChangerCommand extends Command {
command.then(LiteralArgumentBuilder.<T>literal("rain")
.executes(context -> {
WeatherChanger.setMode(WcMode.RAIN);
sendClientMessage("Set client weather to: Rain");
sendClientMessage(Text.translatable("commands.weatherchanger.set.rain"));
return 1;
})
);
@@ -43,18 +43,27 @@ public class WeatherChangerCommand extends Command {
command.then(LiteralArgumentBuilder.<T>literal("thunder")
.executes(context -> {
WeatherChanger.setMode(WcMode.THUNDER);
sendClientMessage("Set client weather to: Thunder");
sendClientMessage(Text.translatable("commands.weatherchanger.set.thunder"));
return 1;
})
);
command.then(LiteralArgumentBuilder.<T>literal("toggleTimer")
.executes(context -> {
WeatherChanger.toggleTimer();
Text message = WeatherChanger.isTimerEnabled() ? Text.translatable("commands.weatherchanger.timer.on") : Text.translatable("commands.weatherchanger.timer.off");
sendClientMessage(message);
return 1;
})
);
LiteralCommandNode<T> node = dispatcher.register(command);
dispatcher.register((LiteralArgumentBuilder<T>) LiteralArgumentBuilder.literal("cweather").redirect((CommandNode<Object>) node));
dispatcher.register(LiteralArgumentBuilder.<T>literal("cweather").redirect(node));
}
@Override
public Identifier getId() {
return new Identifier("weatherchanger", "corecommand");
return Identifier.of("weatherchanger", "corecommand");
}
@Override

View File

@@ -10,8 +10,10 @@ public abstract class Key {
public KeyBinding keybind;
public MinecraftClient mc = MinecraftClient.getInstance();
public Key(@NotNull String name) {
keybind = new KeyBinding(this.getDisplayName(), this.getKeyType(), this.getKey(), this.getCategory());
private static final KeyBinding.Category CATEGORY = KeyBinding.Category.create(Identifier.of("weatherchanger"));
public Key() {
keybind = new KeyBinding(this.getDisplayName(), this.getKeyType(), this.getKey(), CATEGORY);
}
public abstract void onPress(@NotNull MinecraftClient client);
@@ -20,6 +22,5 @@ public abstract class Key {
public abstract boolean isEnabled();
public abstract String getDisplayName();
public abstract InputUtil.Type getKeyType();
public abstract String getCategory();
public abstract int getKey();
}

View File

@@ -5,26 +5,23 @@ import me.lucaslah.weatherchanger.config.WcMode;
import me.lucaslah.weatherchanger.keybinding.Key;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
public class ToggleClearKey extends Key {
public ToggleClearKey() {
super("ToggleClearKey");
}
@Override
public void onPress(@NotNull MinecraftClient client) {
WeatherChanger.setMode(WcMode.CLEAR);
assert mc.player != null;
mc.player.sendMessage(Text.of("Set client weather to: Clear"), true);
mc.player.sendMessage(Text.translatable("commands.weatherchanger.set.clear"), true);
}
@Override
public Identifier getId() {
return new Identifier("weatherchanger", "toggleclearkey");
return Identifier.of("weatherchanger", "toggleclearkey");
}
@Override
@@ -39,7 +36,7 @@ public class ToggleClearKey extends Key {
@Override
public String getDisplayName() {
return "Toggle Weather Clear";
return I18n.translate("keys.weatherchanger.clear.name");
}
@Override
@@ -47,11 +44,6 @@ public class ToggleClearKey extends Key {
return InputUtil.Type.KEYSYM;
}
@Override
public String getCategory() {
return "Weather Changer";
}
@Override
public int getKey() {
return -1;

View File

@@ -5,26 +5,23 @@ import me.lucaslah.weatherchanger.config.WcMode;
import me.lucaslah.weatherchanger.keybinding.Key;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
public class ToggleOffKey extends Key {
public ToggleOffKey() {
super("ToggleOffKey");
}
@Override
public void onPress(@NotNull MinecraftClient client) {
WeatherChanger.setMode(WcMode.OFF);
assert mc.player != null;
mc.player.sendMessage(Text.of("Set client weather to: Off"), true);
mc.player.sendMessage(Text.translatable("commands.weatherchanger.set.off"), true);
}
@Override
public Identifier getId() {
return new Identifier("weatherchanger", "toggleoffkey");
return Identifier.of("weatherchanger", "toggleoffkey");
}
@Override
@@ -39,7 +36,7 @@ public class ToggleOffKey extends Key {
@Override
public String getDisplayName() {
return "Toggle Weather Off";
return I18n.translate("keys.weatherchanger.off.name");
}
@Override
@@ -47,11 +44,6 @@ public class ToggleOffKey extends Key {
return InputUtil.Type.KEYSYM;
}
@Override
public String getCategory() {
return "Weather Changer";
}
@Override
public int getKey() {
return -1;

View File

@@ -5,26 +5,23 @@ import me.lucaslah.weatherchanger.config.WcMode;
import me.lucaslah.weatherchanger.keybinding.Key;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
public class ToggleRainKey extends Key {
public ToggleRainKey() {
super("ToggleRainKey");
}
@Override
public void onPress(@NotNull MinecraftClient client) {
WeatherChanger.setMode(WcMode.RAIN);
assert mc.player != null;
mc.player.sendMessage(Text.of("Set client weather to: Rain"), true);
mc.player.sendMessage(Text.translatable("commands.weatherchanger.set.rain"), true);
}
@Override
public Identifier getId() {
return new Identifier("weatherchanger", "togglerainkey");
return Identifier.of("weatherchanger", "togglerainkey");
}
@Override
@@ -39,7 +36,7 @@ public class ToggleRainKey extends Key {
@Override
public String getDisplayName() {
return "Toggle Weather Rain";
return I18n.translate("keys.weatherchanger.rain.name");
}
@Override
@@ -47,11 +44,6 @@ public class ToggleRainKey extends Key {
return InputUtil.Type.KEYSYM;
}
@Override
public String getCategory() {
return "Weather Changer";
}
@Override
public int getKey() {
return -1;

View File

@@ -5,26 +5,23 @@ import me.lucaslah.weatherchanger.config.WcMode;
import me.lucaslah.weatherchanger.keybinding.Key;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
public class ToggleThunderKey extends Key {
public ToggleThunderKey() {
super("ToggleThunderKey");
}
@Override
public void onPress(@NotNull MinecraftClient client) {
WeatherChanger.setMode(WcMode.THUNDER);
assert mc.player != null;
mc.player.sendMessage(Text.of("Set client weather to: Thunder"), true);
mc.player.sendMessage(Text.translatable("commands.weatherchanger.set.thunder"), true);
}
@Override
public Identifier getId() {
return new Identifier("weatherchanger", "togglethunderkey");
return Identifier.of("weatherchanger", "togglethunderkey");
}
@Override
@@ -39,7 +36,7 @@ public class ToggleThunderKey extends Key {
@Override
public String getDisplayName() {
return "Toggle Weather Thunder";
return I18n.translate("keys.weatherchanger.thunder.name");
}
@Override
@@ -47,11 +44,6 @@ public class ToggleThunderKey extends Key {
return InputUtil.Type.KEYSYM;
}
@Override
public String getCategory() {
return "Weather Changer";
}
@Override
public int getKey() {
return -1;

View File

@@ -2,25 +2,49 @@ package me.lucaslah.weatherchanger.mixin;
import me.lucaslah.weatherchanger.WeatherChanger;
import me.lucaslah.weatherchanger.config.WcMode;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Environment(EnvType.CLIENT)
@Mixin(World.class)
public class WorldMixin {
@Shadow
protected float rainGradientPrev;
protected float lastRainGradient;
@Shadow
protected float rainGradient;
@Shadow
protected float thunderGradientPrev;
protected float lastThunderGradient;
@Shadow
protected float thunderGradient;
@Shadow @Final private RegistryEntry<DimensionType> dimensionEntry;
@Unique
private float weatherChanger$getRainGradientOg(float delta) {
return MathHelper.lerp(delta, this.lastRainGradient, this.rainGradient);
}
@Unique
private float weatherChanger$getThunderGradientOg(float delta) {
return MathHelper.lerp(delta, this.lastThunderGradient, this.thunderGradient) * this.weatherChanger$getRainGradientOg(delta);
}
@Unique
public DimensionType weatherChanger$getDimension() {
return this.dimensionEntry.value();
}
@Inject(method = "getRainGradient", at = @At("HEAD"), cancellable = true)
public void getRainGradient(float delta, CallbackInfoReturnable<Float> callback) {
WcMode mode = WeatherChanger.getMode();
@@ -30,7 +54,7 @@ public class WorldMixin {
} else if (mode == WcMode.RAIN || mode == WcMode.THUNDER) {
callback.setReturnValue(1F);
} else {
callback.setReturnValue(MathHelper.lerp(delta, this.rainGradientPrev, this.rainGradient));
callback.setReturnValue(MathHelper.lerp(delta, this.lastRainGradient, this.rainGradient));
}
callback.cancel();
@@ -45,7 +69,24 @@ public class WorldMixin {
} else if (mode == WcMode.THUNDER) {
callback.setReturnValue(1F);
} else {
callback.setReturnValue(MathHelper.lerp(delta, this.thunderGradientPrev, this.thunderGradient) * MathHelper.lerp(delta, this.rainGradientPrev, this.rainGradient));
callback.setReturnValue(MathHelper.lerp(delta, this.lastThunderGradient, this.thunderGradient) * MathHelper.lerp(delta, this.lastRainGradient, this.rainGradient));
}
callback.cancel();
}
@Inject(method = "isRaining", at = @At("HEAD"), cancellable = true)
public void isRaining(CallbackInfoReturnable<Boolean> callback) {
callback.setReturnValue((double)this.weatherChanger$getRainGradientOg(1.0F) > 0.2);
callback.cancel();
}
@Inject(method = "isThundering", at = @At("HEAD"), cancellable = true)
public void isThundering(CallbackInfoReturnable<Boolean> callback) {
if (this.weatherChanger$getDimension().hasSkyLight() && !(this.weatherChanger$getDimension().hasCeiling())) {
callback.setReturnValue((double)this.weatherChanger$getThunderGradientOg(1.0F) > 0.9);
} else {
callback.setReturnValue(false);
}
callback.cancel();

View File

@@ -0,0 +1,66 @@
package me.lucaslah.weatherchanger.timerlogic;
import me.lucaslah.weatherchanger.WeatherChanger;
import me.lucaslah.weatherchanger.config.WcMode;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.Random;
public class Timer {
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private final Random random = new Random();
public Timer() {
scheduleWeatherChange();
scheduleWeatherIntensityAdjustment();
}
private void scheduleWeatherChange() {
int initialDelay = 0; // Start immediately
int delay = 20 + random.nextInt(11); // 20-30 minutes
scheduler.scheduleWithFixedDelay(this::decideWeather, initialDelay, delay, TimeUnit.MINUTES);
}
private void decideWeather() {
if (!WeatherChanger.isTimerEnabled()) return;
if (random.nextDouble() < 0.75) { // 75% chance to change the weather
if (random.nextDouble() < 0.66) { // 66% chance for rain
WeatherChanger.setMode(WcMode.RAIN);
} else { // 33% chance for thunderstorm
WeatherChanger.setMode(WcMode.THUNDER);
}
}
}
private void scheduleWeatherIntensityAdjustment() {
int initialDelay = 1; // Start after 1 minute
int delay = 1 + random.nextInt(2); // 1-2 minutes
scheduler.scheduleWithFixedDelay(this::adjustWeatherIntensity, initialDelay, delay, TimeUnit.MINUTES);
}
private void adjustWeatherIntensity() {
if (!WeatherChanger.isTimerEnabled()) return;
WcMode currentMode = WeatherChanger.getMode();
double chance = random.nextDouble();
if (currentMode == WcMode.RAIN) {
if (chance < 0.05) { // 5% chance to worsen from rain to thunderstorm
WeatherChanger.setMode(WcMode.THUNDER);
} else if (chance < 0.20) { // 15% chance to clear up from rain
WeatherChanger.setMode(WcMode.CLEAR);
}
} else if (currentMode == WcMode.THUNDER) {
if (chance < 0.05) { // 5% chance to worsen, but already at worst so no change
// No change
} else if (chance < 0.20) { // 15% chance to improve from thunderstorm to rain
WeatherChanger.setMode(WcMode.RAIN);
}
} else if (currentMode == WcMode.CLEAR) {
// No change, clear weather cannot improve or worsen in this context
}
}
}

View File

@@ -0,0 +1,13 @@
{
"key.category.minecraft.weatherchanger": "Weather Changer",
"commands.weatherchanger.set.off": "Set client weather to: Off",
"commands.weatherchanger.set.clear": "Set client weather to: Clear",
"commands.weatherchanger.set.rain": "Set client weather to: Rain",
"commands.weatherchanger.set.thunder": "Set client weather to: Thunder",
"commands.weatherchanger.timer.on": "Timer enabled",
"commands.weatherchanger.timer.off": "Timer disabled",
"keys.weatherchanger.off.name": "Toggle Weather Off",
"keys.weatherchanger.clear.name": "Toggle Weather Clear",
"keys.weatherchanger.rain.name": "Toggle Weather Rain",
"keys.weatherchanger.thunder.name": "Toggle Weather Thunder"
}

View File

@@ -0,0 +1,13 @@
{
"modmenu.descriptionTranslation.weatherchanger": "Позволяет изменять погоду в клиенте, не изменяя погоду сервера.",
"commands.weatherchanger.set.off": "Установлена клиентская погода: Выкл.",
"commands.weatherchanger.set.clear": "Установлена клиентская погода: Ясная",
"commands.weatherchanger.set.rain": "Установлена клиентская погода: Дождливая",
"commands.weatherchanger.set.thunder": "Установлена клиентская погода: Гроза и дождь",
"commands.weatherchanger.timer.on": "Таймер включен",
"commands.weatherchanger.timer.off": "Таймер выключен",
"keys.weatherchanger.off.name": "Выключить клиентскую погоду",
"keys.weatherchanger.clear.name": "Переключить ясную погоду",
"keys.weatherchanger.rain.name": "Переключить дождливую погоду",
"keys.weatherchanger.thunder.name": "Переключить дождливую и грозовую погоду"
}

View File

@@ -0,0 +1,14 @@
{
"modmenu.summaryTranslation.weatherchanger": "Клиент тарафыннан Minecraft һава торышын үзгәртү",
"modmenu.descriptionTranslation.weatherchanger": "Сервер тарафыннан һава торышын үзгәртмичә, клиент тарафыннан Minecraft һава торышын үзгәртү",
"commands.weatherchanger.set.off": "Клиентлы һава торышы урнаштырылды: Сүнек",
"commands.weatherchanger.set.clear": "Клиентлы һава торышы урнаштырылды: Аяз",
"commands.weatherchanger.set.rain": "Клиентлы һава торышы урнаштырылды: Яңгырлы",
"commands.weatherchanger.set.thunder": "Клиентлы һава торышы урнаштырылды: Яшенле һәм яңгырлы",
"commands.weatherchanger.timer.on": "Таймер кушык",
"commands.weatherchanger.timer.off": "Таймер сүнек",
"keys.weatherchanger.off.name": "Клиентлы һава торышын сүндерү",
"keys.weatherchanger.clear.name": "Аяз һава торышын күчерү",
"keys.weatherchanger.rain.name": "Яңгырлы һава торышын күчерү",
"keys.weatherchanger.thunder.name": "Яшенле һәм яңгырлы һава торышын күчерү"
}

View File

@@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "me.lucaslah.weatherchanger.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [
],
"client": [
@@ -10,5 +10,6 @@
],
"injectors": {
"defaultRequire": 1
}
},
"refmap": "weatherchanger-common-common-refmap.json"
}

View File

@@ -55,6 +55,8 @@ tasks {
rename { "assets/weatherchanger/icon.png" }
}
rename("common-common-refmap.json", "weatherchanger-common-common-refmap.json")
dependsOn(":common:transformProductionFabric")
from({

View File

@@ -62,6 +62,8 @@ tasks {
rename { "icon.png" }
}
rename("common-common-refmap.json", "weatherchanger-common-common-refmap.json")
dependsOn(":common:transformProductionForge")
from({

View File

@@ -1,27 +1,30 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
# Kotlin
kotlin.code.style=official
# Minecraft Properties
minecraft_version=1.20.1
minecraft_base=1.20.0
yarn_mappings=1.20.1+build.8
minecraft_version=1.21.11
minecraft_base=1.21
yarn_mappings=1.21.11+build.1
# Architectury Properties
enabled_platforms=fabric,forge
# Mod Properties
mod_version = 1.0.0
mod_version = 1.3.0-beta1
mod_id = weatherchanger
maven_group = me.lucaslah.weatherchanger
archives_base_name = weather-changer
# Release Properties
# options: none,alpha,beta,release
release_channel=none
# options: alpha,beta,release
release_channel=release
# Fabric
fabric.loader_version=0.14.21
fabric.version=0.84.0+1.20.1
fabric.loader_version=0.18.2
fabric.version=0.139.4+1.21.11
# Forge
forge.version=1.20.1-47.0.3
forge.version=1.21-51.0.21

Binary file not shown.

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

2
gradlew vendored
View File

@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.

20
gradlew.bat vendored
View File

@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail

View File

@@ -38,4 +38,4 @@ gradleEnterprise {
include("common")
include("fabric")
include("forge")
//include("forge")