Start on NEXT (version 1.0) branch

- update gradle wrapper version (8.4 to 8.5)
- update logo and add banner
- change to gradle kotlin DSL (from groovy)
- update README.md
- update project layout for planned forge support
- move common logic to common module
- change environment to 'client' to prevent servers from loading the mod (#2)
- cleanup unneeded files
- update LICENSE.md to use Markdown format for easier reading
- update version number to prepare for version 1.0

Signed-off-by: Lucas Petrino <nsx1lucas@gmail.com>
This commit is contained in:
2024-01-14 19:20:34 +13:00
parent 993df4b93d
commit 4eaf638e42
45 changed files with 804 additions and 683 deletions

View File

@@ -1,25 +0,0 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/java/.devcontainer/base.Dockerfile
# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11, 17, 11-bullseye, 17-bullseye, 11-buster, 17-buster
ARG VARIANT="17-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}
# [Option] Install Maven
ARG INSTALL_MAVEN="false"
ARG MAVEN_VERSION=""
# [Option] Install Gradle
ARG INSTALL_GRADLE="false"
ARG GRADLE_VERSION=""
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \
&& if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

View File

@@ -1,48 +0,0 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/java
{
"name": "Java",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update the VARIANT arg to pick a Java version: 11, 17
// Append -bullseye or -buster to pin to an OS version.
// Use the -bullseye variants on local arm64/Apple Silicon.
"VARIANT": "17-bullseye",
// Options
"INSTALL_MAVEN": "false",
"INSTALL_GRADLE": "true",
"NODE_VERSION": "none"
}
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vscjava.vscode-java-pack"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "java -version",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"git": "os-provided",
"github-cli": "latest",
"sshd": "latest",
"fish": "latest"
}
}

0
CHANGELOG.md Normal file
View File

165
LICENSE
View File

@@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

157
LICENSE.md Normal file
View File

@@ -0,0 +1,157 @@
# GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the
terms and conditions of version 3 of the GNU General Public License,
supplemented by the additional permissions listed below.
## 0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the
GNU General Public License.
"The Library" refers to a covered work governed by this License, other
than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
## 1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
## 2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
- a) under this License, provided that you make a good faith effort
to ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
- b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
## 3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a
header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
- a) Give prominent notice with each copy of the object code that
the Library is used in it and that the Library and its use are
covered by this License.
- b) Accompany the object code with a copy of the GNU GPL and this
license document.
## 4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken
together, effectively do not restrict modification of the portions of
the Library contained in the Combined Work and reverse engineering for
debugging such modifications, if you also do each of the following:
- a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
- b) Accompany the Combined Work with a copy of the GNU GPL and this
license document.
- c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
- d) Do one of the following:
- 0) Convey the Minimal Corresponding Source under the terms of
this License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
- 1) Use a suitable shared library mechanism for linking with
the Library. A suitable mechanism is one that (a) uses at run
time a copy of the Library already present on the user's
computer system, and (b) will operate properly with a modified
version of the Library that is interface-compatible with the
Linked Version.
- e) Provide Installation Information, but only if you would
otherwise be required to provide such information under section 6
of the GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the Application
with a modified version of the Linked Version. (If you use option
4d0, the Installation Information must accompany the Minimal
Corresponding Source and Corresponding Application Code. If you
use option 4d1, you must provide the Installation Information in
the manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.)
## 5. Combined Libraries.
You may place library facilities that are a work based on the Library
side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
- a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities, conveyed under the terms of this License.
- b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
## 6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
as you received it specifies that a certain numbered version of the
GNU Lesser General Public License "or any later version" applies to
it, you have the option of following the terms and conditions either
of that published version or of any later version published by the
Free Software Foundation. If the Library as you received it does not
specify a version number of the GNU Lesser General Public License, you
may choose any version of the GNU Lesser General Public License ever
published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@@ -1,9 +1,71 @@
# Weather Changer
Changes the weather on client side
<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"/>
</p>
Supports fabric 1.20.0+, forge support is coming soon!\
The fabric api is required.
<h1 align="center" style="margin-top: 0;margin-bottom: 0">Weather Changer</h1>
<p align="center" style="margin-top: 0;">Client side weather change for Minecraft</p>
## Links
Modrinth: https://modrinth.com/mod/weather-changer \
Curseforge: https://www.curseforge.com/minecraft/mc-mods/weather-changer <br>
<p align="center"><a href="https://www.curseforge.com/minecraft/mc-mods/weather-changer"><img src="https://cf.way2muchnoise.eu/full_682513_downloads.svg" alt="curseforge-downloads"></a>
<a href="https://modrinth.com/mod/weather-changer"><img src="https://img.shields.io/modrinth/dt/nhSHTGyl?logo=Modrinth" alt="modrinth-downloads"></a></p>
<p align="center" style="display: block;margin: 0 auto;">
<img src="assets/banner.png" alt="Weather Changer Banner"/>
</p>
> Warning: This is the v1.0 (next) branch and is still in development.
## 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.
### In-Game Command Usage
`/clientweather <off | clear | rain | thunder>`
The command alias `/cweather` may also be used as a shortcut.
### Keybindings
To set the keybindings you can do so in the minecraft keyBase bind 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)
## 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>
**GitHub Releases:** https://github.com/Lucaslah/WeatherChanger/releases <br>
**Release Server**: https://release.cssudii.xyz/projects/weatherchanger
## Release History
| Branch | Version | MC Version | Mod loaders | Git Tag | CI | Supported |
|--------|---------|---------------|-------------|------------------------------------------------------------------------|-----|-----------|
### 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 |
## Minecraft Versions
| Version | Status |
|---------|---------------------------------|
| 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) |
*Older versions may be added on request*
------------------------------------------
*Licensed under the [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html) license.*

BIN
assets/banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
assets/logo-242x242.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1013 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 KiB

View File

@@ -1,92 +0,0 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}
configurations {
includeModImplementation
includeImplementation
include.extendsFrom includeImplementation
include.extendsFrom includeModImplementation
implementation.extendsFrom includeImplementation
modImplementation.extendsFrom includeModImplementation
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
//includeModImplementation fabricApi.module("fabric-api-base", project.fabric_version)
//includeModImplementation fabricApi.module("fabric-command-api-v2", project.fabric_version)
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

35
build.gradle.kts Normal file
View File

@@ -0,0 +1,35 @@
plugins {
id("architectury-plugin") version "3.4-SNAPSHOT"
id ("dev.architectury.loom") version "1.3-SNAPSHOT" apply false
}
architectury {
minecraft = properties["minecraft_version"].toString()
}
subprojects {
apply(plugin = "dev.architectury.loom")
dependencies {
"minecraft"("com.mojang:minecraft:${properties["minecraft_version"]}")
"mappings"("net.fabricmc:yarn:${rootProject.properties["yarn_mappings"]}:v2")
}
}
allprojects {
apply(plugin = "java")
apply(plugin = "maven-publish")
apply(plugin = "architectury-plugin")
version = properties["mod_version"].toString()
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())
}
}

16
common/build.gradle.kts Normal file
View File

@@ -0,0 +1,16 @@
architectury {
common(rootProject.property("enabled_platforms").toString().split(","))
}
loom {
accessWidenerPath = file("src/main/resources/weatherchanger.accesswidener")
}
repositories {
mavenCentral()
}
dependencies {
implementation("com.google.code.gson:gson:2.10.1")
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric.loader_version")}")
}

View File

@@ -0,0 +1,133 @@
package me.lucaslah.weatherchanger;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import me.lucaslah.weatherchanger.config.WcConfig;
import me.lucaslah.weatherchanger.config.WcMode;
import me.lucaslah.weatherchanger.keybinding.KeybindingManager;
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 java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.nio.file.Files;
import java.util.Objects;
public class WeatherChanger {
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
private static WcMode currentMode = WcMode.OFF;
public static void init() {
boolean fileCreated = false;
File configPath = getConfigFile();
if (!configPath.exists()) {
try {
fileCreated = configPath.createNewFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
if (fileCreated) {
writeConfig();
} else {
loadConfig();
}
KeybindingManager keybindingManager = WeatherChangerExpectPlatform.getKeybindingManager();
keybindingManager
.add(new ToggleClearKey())
.add(new ToggleOffKey())
.add(new ToggleRainKey())
.add(new ToggleThunderKey());
keybindingManager.registerKeys();
}
private static void loadConfig() {
Reader reader;
try {
reader = Files.newBufferedReader(getConfigFile().toPath());
} catch (IOException e) {
throw new RuntimeException(e);
}
WcConfig config = gson.fromJson(reader, WcConfig.class);
if (!Objects.equals(config.getVersion(), "1.0.0")) {
throw new RuntimeException("Invalid weather changer config version! Try removing the config file and try again.");
}
currentMode = config.getMode();
try {
reader.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static void writeConfig() {
WcConfig config = new WcConfig();
config.setMode(currentMode);
config.setVersion("1.0.0");
Writer writer;
try {
writer = Files.newBufferedWriter(getConfigFile().toPath());
} catch (IOException e) {
throw new RuntimeException(e);
}
gson.toJson(config, writer);
try {
writer.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static File getConfigFile() {
return WeatherChangerExpectPlatform.getConfigDirectory().resolve("weather-changer.json").toFile();
}
/**
* Reloads the config file from disk
* @return if the reload was successful
*/
public static boolean reloadConfig() {
if (getConfigFile().exists() && getConfigFile().isFile()) {
loadConfig();
return true;
}
return false;
}
/**
* Sets the current mode
* @param mode the mode
*/
public static void setMode(WcMode mode) {
currentMode = mode;
}
public static WcMode getMode() {
return currentMode;
}
/**
* Call on shutdown
*/
public static void shutdown() {
writeConfig();
}
}

View File

@@ -0,0 +1,18 @@
package me.lucaslah.weatherchanger;
import dev.architectury.injectables.annotations.ExpectPlatform;
import me.lucaslah.weatherchanger.keybinding.KeybindingManager;
import java.nio.file.Path;
public class WeatherChangerExpectPlatform {
@ExpectPlatform
public static Path getConfigDirectory() {
throw new AssertionError();
}
@ExpectPlatform
public static KeybindingManager getKeybindingManager() {
throw new AssertionError();
}
}

View File

@@ -0,0 +1,4 @@
package me.lucaslah.weatherchanger.command;
public class CommandManager {
}

View File

@@ -0,0 +1,30 @@
package me.lucaslah.weatherchanger.config;
public class WcConfig {
private WcMode mode;
private String version;
public WcConfig() {
}
public WcConfig(WcMode mode, String version) {
this.mode = mode;
this.version = version;
}
public WcMode getMode() {
return mode;
}
public void setMode(WcMode mode) {
this.mode = mode;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}

View File

@@ -0,0 +1,8 @@
package me.lucaslah.weatherchanger.config;
public enum WcMode {
OFF,
CLEAR,
RAIN,
THUNDER
}

View File

@@ -1,31 +1,25 @@
package me.lucaslah.weatherchanger.keybind;
package me.lucaslah.weatherchanger.keybinding;
import me.lucaslah.weatherchanger.WeatherChanger;
import org.jetbrains.annotations.NotNull;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil.Type;
import net.minecraft.client.util.InputUtil;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
public abstract class Key {
public KeyBinding keybind;
public WeatherChanger mod = WeatherChanger.getInstance();
public MinecraftClient mc = MinecraftClient.getInstance();
public Key(@NotNull String name) {
keybind = KeyBindingHelper.registerKeyBinding(new KeyBinding(this.getDisplayName(), this.getKeyType(), this.getKey(), this.getCategory()));
keybind = new KeyBinding(this.getDisplayName(), this.getKeyType(), this.getKey(), this.getCategory());
}
public abstract void onPress(@NotNull MinecraftClient client);
public abstract Identifier getId();
public abstract KeyBinding getKeyBinding();
public abstract boolean isEnabled();
public abstract String getDisplayName();
public abstract Type getKeyType();
public abstract InputUtil.Type getKeyType();
public abstract String getCategory();
public abstract int getKey();
}

View File

@@ -0,0 +1,30 @@
package me.lucaslah.weatherchanger.keybinding;
import net.minecraft.util.Identifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public abstract class KeybindingManager {
private final HashMap<Identifier, Key> entries = new HashMap<>();
public KeybindingManager add(Key entry) {
entries.put(entry.getId(), entry);
return this;
}
public Key get(Identifier identifier) {
return entries.get(identifier);
}
public List<Key> getEntries() {
if (!entries.isEmpty()) {
return new ArrayList<>(entries.values());
}
return new ArrayList<>();
}
public abstract void registerKeys();
}

View File

@@ -1,6 +1,8 @@
package me.lucaslah.weatherchanger.keybindings;
package me.lucaslah.weatherchanger.keys;
import me.lucaslah.weatherchanger.keybind.Key;
import me.lucaslah.weatherchanger.WeatherChanger;
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.util.InputUtil;
@@ -15,14 +17,14 @@ public class ToggleClearKey extends Key {
@Override
public void onPress(@NotNull MinecraftClient client) {
mod.setClear();
WeatherChanger.setMode(WcMode.CLEAR);
assert mc.player != null;
mc.player.sendMessage(Text.of("Set client weather to: Clear"), true);
}
@Override
public Identifier getId() {
return new Identifier("weatherchangerkeys", "toggleclearkey");
return new Identifier("weatherchanger", "toggleclearkey");
}
@Override

View File

@@ -1,6 +1,8 @@
package me.lucaslah.weatherchanger.keybindings;
package me.lucaslah.weatherchanger.keys;
import me.lucaslah.weatherchanger.keybind.Key;
import me.lucaslah.weatherchanger.WeatherChanger;
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.util.InputUtil;
@@ -15,14 +17,14 @@ public class ToggleOffKey extends Key {
@Override
public void onPress(@NotNull MinecraftClient client) {
mod.setOff();
WeatherChanger.setMode(WcMode.OFF);
assert mc.player != null;
mc.player.sendMessage(Text.of("Set client weather to: Off"), true);
}
@Override
public Identifier getId() {
return new Identifier("weatherchangerkeys", "toggleoffkey");
return new Identifier("weatherchanger", "toggleoffkey");
}
@Override

View File

@@ -1,6 +1,8 @@
package me.lucaslah.weatherchanger.keybindings;
package me.lucaslah.weatherchanger.keys;
import me.lucaslah.weatherchanger.keybind.Key;
import me.lucaslah.weatherchanger.WeatherChanger;
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.util.InputUtil;
@@ -15,14 +17,14 @@ public class ToggleRainKey extends Key {
@Override
public void onPress(@NotNull MinecraftClient client) {
mod.setRain();
WeatherChanger.setMode(WcMode.RAIN);
assert mc.player != null;
mc.player.sendMessage(Text.of("Set client weather to: Rain"), true);
}
@Override
public Identifier getId() {
return new Identifier("weatherchangerkeys", "togglerainkey");
return new Identifier("weatherchanger", "togglerainkey");
}
@Override

View File

@@ -1,6 +1,8 @@
package me.lucaslah.weatherchanger.keybindings;
package me.lucaslah.weatherchanger.keys;
import me.lucaslah.weatherchanger.keybind.Key;
import me.lucaslah.weatherchanger.WeatherChanger;
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.util.InputUtil;
@@ -15,14 +17,14 @@ public class ToggleThunderKey extends Key {
@Override
public void onPress(@NotNull MinecraftClient client) {
mod.setThunder();
WeatherChanger.setMode(WcMode.THUNDER);
assert mc.player != null;
mc.player.sendMessage(Text.of("Set client weather to: Thunder"), true);
}
@Override
public Identifier getId() {
return new Identifier("weatherchangerkeys", "togglethunderkey");
return new Identifier("weatherchanger", "togglethunderkey");
}
@Override

View File

@@ -1,6 +1,7 @@
package me.lucaslah.weatherchanger.mixin;
import me.lucaslah.weatherchanger.WeatherChanger;
import me.lucaslah.weatherchanger.config.WcMode;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
@@ -11,19 +12,22 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(World.class)
public class WorldMixin {
private WeatherChanger mod = WeatherChanger.getInstance();
@Shadow
protected float rainGradientPrev;
@Shadow
protected float rainGradient;
@Shadow
protected float thunderGradientPrev;
@Shadow
protected float thunderGradient;
@Inject(method = "getRainGradient", at = @At("HEAD"), cancellable = true)
public void changeRainGradient(float delta, CallbackInfoReturnable<Float> callback) {
if (mod.mode == WeatherChanger.Mode.CLEAR) {
public void getRainGradient(float delta, CallbackInfoReturnable<Float> callback) {
WcMode mode = WeatherChanger.getMode();
if (mode == WcMode.CLEAR) {
callback.setReturnValue(0F);
} else if (mod.mode == WeatherChanger.Mode.RAIN || mod.mode == WeatherChanger.Mode.THUNDER) {
} else if (mode == WcMode.RAIN || mode == WcMode.THUNDER) {
callback.setReturnValue(1F);
} else {
callback.setReturnValue(MathHelper.lerp(delta, this.rainGradientPrev, this.rainGradient));
@@ -34,19 +38,16 @@ public class WorldMixin {
@Inject(method = "getThunderGradient", at = @At("HEAD"), cancellable = true)
public void getThunderGradient(float delta, CallbackInfoReturnable<Float> callback) {
if (mod.mode == WeatherChanger.Mode.CLEAR) {
WcMode mode = WeatherChanger.getMode();
if (mode == WcMode.CLEAR) {
callback.setReturnValue(0F);
} else if (mod.mode == WeatherChanger.Mode.THUNDER) {
} else if (mode == WcMode.THUNDER) {
callback.setReturnValue(1F);
} else {
callback.setReturnValue(this.getRainGradient(delta));
callback.setReturnValue(MathHelper.lerp(delta, this.thunderGradientPrev, this.thunderGradient) * MathHelper.lerp(delta, this.rainGradientPrev, this.rainGradient));
}
callback.cancel();
}
public float getRainGradient(float delta) {
return MathHelper.lerp(delta, this.rainGradientPrev, this.rainGradient);
}
}

View File

@@ -0,0 +1,3 @@
{
"accessWidener": "weatherchanger.accesswidener"
}

View File

@@ -0,0 +1 @@
accessWidener v2 named

View File

@@ -11,4 +11,4 @@
"injectors": {
"defaultRequire": 1
}
}
}

82
fabric/build.gradle.kts Normal file
View File

@@ -0,0 +1,82 @@
architectury {
platformSetupLoomIde()
fabric()
}
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
}
val common: Configuration by configurations.creating
val shadowCommon: Configuration by configurations.creating
configurations {
compileOnly.configure { extendsFrom(common) }
runtimeOnly.configure { extendsFrom(common) }
}
dependencies {
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric.loader_version")}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.property("fabric.version")}")
common(project(":common", "namedElements")) {
isTransitive = false
}
shadowCommon(project(":common", "transformProductionFabric")){
isTransitive = false
}
}
tasks {
processResources {
inputs.property("version", project.version)
filesMatching("fabric.mod.json") {
expand(mapOf(
"version" to project.version,
"mod_id" to rootProject.property("mod_id"),
"minecraft_version" to rootProject.property("minecraft_version"),
"minecraft_base_version" to rootProject.property("minecraft_base"),
"fabric_loader_version" to rootProject.property("fabric.loader_version")
))
}
}
remapJar {
injectAccessWidener.set(true)
}
jar {
from("../LICENSE.md")
from("../assets/logo.png") {
rename { "assets/weatherchanger/icon.png" }
}
dependsOn(":common:transformProductionFabric")
from({
shadowCommon.filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}
}
java {
withSourcesJar()
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

View File

@@ -0,0 +1,23 @@
package me.lucaslah.weatherchanger.fabric;
import me.lucaslah.weatherchanger.keybinding.Key;
import me.lucaslah.weatherchanger.keybinding.KeybindingManager;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
public class FabricKeybindingManager extends KeybindingManager {
@Override
public void registerKeys() {
for (Key key : getEntries()) {
KeyBindingHelper.registerKeyBinding(key.getKeyBinding());
}
ClientTickEvents.END_CLIENT_TICK.register(client -> {
for (Key key : getEntries()) {
if (key.isEnabled() && key.getKeyBinding().wasPressed()) {
key.onPress(client);
}
}
});
}
}

View File

@@ -0,0 +1,16 @@
package me.lucaslah.weatherchanger.fabric;
import me.lucaslah.weatherchanger.keybinding.KeybindingManager;
import net.fabricmc.loader.api.FabricLoader;
import java.nio.file.Path;
public class WeatherChangerExpectPlatformImpl {
public static Path getConfigDirectory() {
return FabricLoader.getInstance().getConfigDir();
}
public static KeybindingManager getKeybindingManager() {
return new FabricKeybindingManager();
}
}

View File

@@ -0,0 +1,17 @@
package me.lucaslah.weatherchanger.fabric;
import me.lucaslah.weatherchanger.WeatherChanger;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class WeatherChangerFabric implements ClientModInitializer {
public static final Logger LOGGER = LogManager.getLogger("weather-changer");
@Override
public void onInitializeClient() {
WeatherChanger.init();
ClientLifecycleEvents.CLIENT_STOPPING.register(client -> WeatherChanger.shutdown());
}
}

View File

@@ -0,0 +1,31 @@
{
"schemaVersion": 1,
"id": "${mod_id}",
"version": "${version}",
"name": "WeatherChanger",
"description": "Client side weather change for Minecraft",
"authors": [
"Lucaslah"
],
"contact": {
"sources": "https://github.com/Lucaslah/WeatherChanger",
"homepage": "https://lucaslah.github.com/WeatherChanger",
"issues": "https://github.com/Lucaslah/WeatherChanger/issues"
},
"license": "LGPL-3.0",
"icon": "assets/weatherchanger/icon.png",
"environment": "client",
"entrypoints": {
"client": [
"me.lucaslah.weatherchanger.fabric.WeatherChangerFabric"
]
},
"mixins": [
"weatherchanger.mixins.json"
],
"depends": {
"fabricloader": ">=${fabric_loader_version}",
"fabric": "*",
"minecraft": ">=${minecraft_base_version}"
}
}

View File

@@ -1,17 +1,23 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://fabricmc.net/develop
# Minecraft Properties
minecraft_version=1.20.1
minecraft_base=1.20.0
yarn_mappings=1.20.1+build.8
loader_version=0.14.21
# Architectury Properties
enabled_platforms=fabric,forge
# Mod Properties
mod_version = 0.3.0
version = 0.1.0
maven_group = me.lucaslah
mod_version = 1.0.0
mod_id = weatherchanger
maven_group = me.lucaslah.weatherchanger
archives_base_name = weather-changer
# Dependencies
fabric_version=0.84.0+1.20.1
# Fabric
fabric.loader_version=0.14.21
fabric.version=0.84.0+1.20.1
# Forge
forge.version=1.20.1-47.0.3

Binary file not shown.

View File

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

51
gradlew vendored
View File

@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -205,6 +214,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

15
gradlew.bat vendored
View File

@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

View File

@@ -1,10 +0,0 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}

26
settings.gradle.kts Normal file
View File

@@ -0,0 +1,26 @@
rootProject.name = "WeatherChanger"
pluginManagement {
repositories {
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
maven {
name = "Forge"
url = uri("https://maven.minecraftforge.net/")
}
maven {
name = "Architectury"
url = uri("https://maven.architectury.dev/")
}
mavenCentral()
gradlePluginPortal()
}
}
include("common")
include("fabric")

View File

@@ -1,19 +0,0 @@
package me.lucaslah.weatherchanger;
public class Config {
private String mode;
public Config() {}
public Config(String mode) {
this.mode = mode;
}
public String getMode() {
return mode;
}
public void setMode(String mode) {
this.mode = mode;
}
}

View File

@@ -1,158 +0,0 @@
package me.lucaslah.weatherchanger;
import com.google.gson.Gson;
import me.lucaslah.weatherchanger.keybind.KeybindManager;
import me.lucaslah.weatherchanger.keybindings.ToggleClearKey;
import me.lucaslah.weatherchanger.keybindings.ToggleOffKey;
import me.lucaslah.weatherchanger.keybindings.ToggleRainKey;
import me.lucaslah.weatherchanger.keybindings.ToggleThunderKey;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.text.Text;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.nio.file.Files;
public class WeatherChanger implements ModInitializer {
public static WeatherChanger instance;
public static final Logger LOGGER = LogManager.getLogger("weather-changer");
public Mode mode = Mode.OFF;
@Override
public void onInitialize() {
instance = this;
// Create config if it does not exist
File configFile = new File(FabricLoader.getInstance().getConfigDir().resolve("weather-changer.json").toUri());
if (!configFile.exists()) {
try {
configFile.createNewFile();
writeModeToConfig();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
loadModeFromFile();
// Keybindings
new KeybindManager()
.add(new ToggleOffKey())
.add(new ToggleClearKey())
.add(new ToggleRainKey())
.add(new ToggleThunderKey());
// Command
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("clientweather")
.then(ClientCommandManager.literal("off")
.executes(context -> {
setOff();
context.getSource().sendFeedback(Text.literal("Set client weather to: Off"));
return 1;
})
).then(ClientCommandManager.literal("clear")
.executes(context -> {
setClear();
context.getSource().sendFeedback(Text.literal("Set client weather to: Clear"));
return 1;
})
).then(ClientCommandManager.literal("rain")
.executes(context -> {
setRain();
context.getSource().sendFeedback(Text.literal("Set client weather to: Rain"));
return 1;
})
).then(ClientCommandManager.literal("thunder")
.executes(context -> {
setThunder();
context.getSource().sendFeedback(Text.literal("Set client weather to: Thunder"));
return 1;
})
).executes((context -> {
context.getSource().sendFeedback(Text.literal("Client weather is set to: " + getMode().toString().toLowerCase()));
return 1;
}))
));
}
public static WeatherChanger getInstance() {
return instance;
}
public enum Mode {
OFF,
CLEAR,
RAIN,
THUNDER
}
public void setMode(Mode mode) {
this.mode = mode;
}
public Mode getMode() {
return mode;
}
public void writeModeToConfig() {
Gson gson = new Gson();
Config config = new Config(getMode().toString().toUpperCase());
Writer writer;
try {
writer = Files.newBufferedWriter(FabricLoader.getInstance().getConfigDir().resolve("weather-changer.json"));
} catch (IOException e) {
throw new RuntimeException(e);
}
gson.toJson(config, writer);
try {
writer.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void loadModeFromFile() {
Gson gson = new Gson();
Reader reader = null;
try {
reader = Files.newBufferedReader(FabricLoader.getInstance().getConfigDir().resolve("weather-changer.json"));
} catch (IOException e) {
throw new RuntimeException(e);
}
Config config = gson.fromJson(reader, Config.class);
setMode(Mode.valueOf(config.getMode().toUpperCase()));
try {
reader.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void setOff() {
setMode(Mode.OFF);
writeModeToConfig();
}
public void setClear() {
setMode(Mode.CLEAR);
writeModeToConfig();
}
public void setRain() {
setMode(Mode.RAIN);
writeModeToConfig();
}
public void setThunder() {
setMode(Mode.THUNDER);
writeModeToConfig();
}
}

View File

@@ -1,46 +0,0 @@
package me.lucaslah.weatherchanger.keybind;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.util.Identifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class KeybindManager {
private final HashMap<Identifier, Key> entries = new HashMap<>();
private static KeybindManager INSTANCE;
public KeybindManager() {
INSTANCE = this;
ClientTickEvents.END_CLIENT_TICK.register(client -> {
for (Key key : getEntries()) {
if (key.isEnabled() && key.getKeyBinding().wasPressed()) {
key.onPress(client);
}
}
});
}
public KeybindManager add(Key entry) {
entries.put(entry.getId(), entry);
return this;
}
public Key get(Identifier identifier) {
return entries.get(identifier);
}
public List<Key> getEntries() {
if (entries.size() > 0) {
return new ArrayList<>(entries.values());
}
return new ArrayList<>();
}
public static KeybindManager getInstance() {
return INSTANCE;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,37 +0,0 @@
{
"schemaVersion": 1,
"id": "weather-changer",
"version": "${version}",
"name": "Weather Changer",
"description": "Client side weather changer",
"authors": [
"Lucaslah"
],
"contact": {
"homepage": "https://cssudii.xyz/r/project/oss/weather-changer",
"sources": "https://github.com/Lucaslah/WeatherChanger",
"issues": "https://github.com/Lucaslah/WeatherChanger/issues",
"email": "ossprojects@cssudii.xyz"
},
"license": "lgpl-3",
"icon": "assets/weatherchanger/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"me.lucaslah.weatherchanger.WeatherChanger"
]
},
"mixins": [
"weatherchanger.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.6",
"fabric-api": "*",
"minecraft": ">=1.20.0",
"java": ">=17"
}
}