mirror of
https://github.com/Lucaslah/WeatherChanger.git
synced 2026-01-07 14:07:50 +00:00
First progress on forge support
- add forge module - github actions build and release - aim for all-in-one jar supporting both fabric and forge **NOTICE** Forge support is not currently working. Signed-off-by: Lucas Petrino <nsx1lucas@gmail.com>
This commit is contained in:
34
.devcontainer/devcontainer.json
Normal file
34
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||||
|
// README at: https://github.com/devcontainers/templates/tree/main/src/java
|
||||||
|
{
|
||||||
|
"name": "Java",
|
||||||
|
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/java:1-17-bookworm",
|
||||||
|
|
||||||
|
"features": {
|
||||||
|
"ghcr.io/devcontainers/features/java:1": {
|
||||||
|
"version": "none",
|
||||||
|
"installMaven": "false",
|
||||||
|
"installGradle": "true"
|
||||||
|
},
|
||||||
|
"ghcr.io/devcontainers/features/github-cli:1": {
|
||||||
|
"installDirectlyFromGitHubRelease": true,
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/itsmechlark/features/act:1": {
|
||||||
|
"version": "latest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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",
|
||||||
|
|
||||||
|
// Configure tool-specific properties.
|
||||||
|
// "customizations": {},
|
||||||
|
|
||||||
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
|
// "remoteUser": "root"
|
||||||
|
}
|
||||||
9
.gitattributes
vendored
Normal file
9
.gitattributes
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#
|
||||||
|
# https://help.github.com/articles/dealing-with-line-endings/
|
||||||
|
#
|
||||||
|
# Linux start script should use lf
|
||||||
|
/gradlew text eol=lf
|
||||||
|
|
||||||
|
# These are Windows script files and should use crlf
|
||||||
|
*.bat text eol=crlf
|
||||||
|
|
||||||
28
.github/workflows/build.yml
vendored
Normal file
28
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'temurin'
|
||||||
|
- name: Make gradlew executable
|
||||||
|
run: chmod +x ./gradlew
|
||||||
|
- name: Build with Gradle
|
||||||
|
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25
|
||||||
|
with:
|
||||||
|
arguments: build
|
||||||
|
- name: Upload Build Results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build
|
||||||
|
path: build/libs/*.jar
|
||||||
58
.github/workflows/release.yml
vendored
Normal file
58
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'temurin'
|
||||||
|
- name: Make gradlew executable
|
||||||
|
run: chmod +x ./gradlew
|
||||||
|
- name: Build with Gradle
|
||||||
|
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25
|
||||||
|
with:
|
||||||
|
arguments: build
|
||||||
|
- name: Upload Build Results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build
|
||||||
|
path: build/libs/*.jar
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
needs: [build]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
- name: Create Release
|
||||||
|
run: |
|
||||||
|
mkdir dist
|
||||||
|
mv build/*.jar dist
|
||||||
|
|
||||||
|
pushd dist
|
||||||
|
shasum -a 256 * > checksums.txt
|
||||||
|
popd
|
||||||
|
|
||||||
|
version=$(grep mod_version gradle.properties | cut -d'=' -f2 | awk '{gsub(/^ +| + $/,""); print}')
|
||||||
|
channel=$(grep release_channel gradle.properties | cut -d'=' -f2 | awk '{gsub(/^ +| + $/,""); print}')
|
||||||
|
|
||||||
|
release_args=(
|
||||||
|
"$version"
|
||||||
|
--title "Weather Changer ${version}"
|
||||||
|
--generate-notes
|
||||||
|
)
|
||||||
|
|
||||||
|
gh release create "${release_args[@]}" ./dist/*
|
||||||
@@ -4,6 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
|
injectInjectables = false
|
||||||
minecraft = properties["minecraft_version"].toString()
|
minecraft = properties["minecraft_version"].toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ import java.util.Objects;
|
|||||||
public class WeatherChanger {
|
public class WeatherChanger {
|
||||||
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
private static WcMode currentMode = WcMode.OFF;
|
private static WcMode currentMode = WcMode.OFF;
|
||||||
|
private static WeatherChangerPlatform platform;
|
||||||
|
|
||||||
public static void init() {
|
public static void init(WeatherChangerPlatform platform) {
|
||||||
|
WeatherChanger.platform = platform;
|
||||||
boolean fileCreated = false;
|
boolean fileCreated = false;
|
||||||
File configPath = getConfigFile();
|
File configPath = getConfigFile();
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ public class WeatherChanger {
|
|||||||
loadConfig();
|
loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
KeybindingManager keybindingManager = WeatherChangerExpectPlatform.getKeybindingManager();
|
KeybindingManager keybindingManager = platform.getKeybindingManager();
|
||||||
|
|
||||||
keybindingManager
|
keybindingManager
|
||||||
.add(new ToggleClearKey())
|
.add(new ToggleClearKey())
|
||||||
@@ -96,7 +98,7 @@ public class WeatherChanger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static File getConfigFile() {
|
private static File getConfigFile() {
|
||||||
return WeatherChangerExpectPlatform.getConfigDirectory().resolve("weather-changer.json").toFile();
|
return platform.getConfigDirectory().resolve("weather-changer.json").toFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package me.lucaslah.weatherchanger;
|
||||||
|
|
||||||
|
import me.lucaslah.weatherchanger.keybinding.KeybindingManager;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public interface WeatherChangerPlatform {
|
||||||
|
Path getConfigDirectory();
|
||||||
|
KeybindingManager getKeybindingManager();
|
||||||
|
}
|
||||||
@@ -3,15 +3,11 @@ package me.lucaslah.weatherchanger.fabric;
|
|||||||
import me.lucaslah.weatherchanger.WeatherChanger;
|
import me.lucaslah.weatherchanger.WeatherChanger;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
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 class WeatherChangerFabric implements ClientModInitializer {
|
||||||
public static final Logger LOGGER = LogManager.getLogger("weather-changer");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
WeatherChanger.init();
|
WeatherChanger.init(new WeatherChangerPlatformImpl());
|
||||||
ClientLifecycleEvents.CLIENT_STOPPING.register(client -> WeatherChanger.shutdown());
|
ClientLifecycleEvents.CLIENT_STOPPING.register(client -> WeatherChanger.shutdown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
package me.lucaslah.weatherchanger.fabric;
|
package me.lucaslah.weatherchanger.fabric;
|
||||||
|
|
||||||
|
import me.lucaslah.weatherchanger.WeatherChangerPlatform;
|
||||||
import me.lucaslah.weatherchanger.keybinding.KeybindingManager;
|
import me.lucaslah.weatherchanger.keybinding.KeybindingManager;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class WeatherChangerExpectPlatformImpl {
|
public class WeatherChangerPlatformImpl implements WeatherChangerPlatform {
|
||||||
public static Path getConfigDirectory() {
|
@Override
|
||||||
|
public Path getConfigDirectory() {
|
||||||
return FabricLoader.getInstance().getConfigDir();
|
return FabricLoader.getInstance().getConfigDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeybindingManager getKeybindingManager() {
|
@Override
|
||||||
|
public KeybindingManager getKeybindingManager() {
|
||||||
return new FabricKeybindingManager();
|
return new FabricKeybindingManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
89
forge/build.gradle.kts
Normal file
89
forge/build.gradle.kts
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
architectury {
|
||||||
|
platformSetupLoomIde()
|
||||||
|
forge()
|
||||||
|
}
|
||||||
|
|
||||||
|
loom {
|
||||||
|
accessWidenerPath.set(project(":common").loom.accessWidenerPath)
|
||||||
|
|
||||||
|
forge.apply {
|
||||||
|
convertAccessWideners.set(true)
|
||||||
|
extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
|
||||||
|
|
||||||
|
mixinConfig("weatherchanger.mixins.json")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val common: Configuration by configurations.creating
|
||||||
|
val shadowCommon: Configuration by configurations.creating
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
compileOnly.configure { extendsFrom(common) }
|
||||||
|
runtimeOnly.configure { extendsFrom(common) }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
forge("net.minecraftforge:forge:${rootProject.property("forge.version")}")
|
||||||
|
|
||||||
|
common(project(":common", "namedElements")) {
|
||||||
|
isTransitive = false
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowCommon(project(":common", "transformProductionForge")) {
|
||||||
|
isTransitive = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
processResources {
|
||||||
|
inputs.property("group", rootProject.property("maven_group"))
|
||||||
|
inputs.property("version", project.version)
|
||||||
|
|
||||||
|
filesMatching("META-INF/mods.toml") {
|
||||||
|
expand(mapOf(
|
||||||
|
"group" to rootProject.property("maven_group"),
|
||||||
|
"version" to project.version,
|
||||||
|
|
||||||
|
"mod_id" to rootProject.property("mod_id"),
|
||||||
|
"minecraft_version" to rootProject.property("minecraft_version")
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
remapJar {
|
||||||
|
injectAccessWidener.set(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
from("../LICENSE.md")
|
||||||
|
from("../assets/logo.png") {
|
||||||
|
rename { "icon.png" }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependsOn(":common:transformProductionForge")
|
||||||
|
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
}
|
||||||
1
forge/gradle.properties
Normal file
1
forge/gradle.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
loom.platform=forge
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package me.lucaslah.weatherchanger.forge;
|
||||||
|
|
||||||
|
import me.lucaslah.weatherchanger.keybinding.KeybindingManager;
|
||||||
|
|
||||||
|
public class ForgeKeybindingManager extends KeybindingManager {
|
||||||
|
@Override
|
||||||
|
public void registerKeys() {
|
||||||
|
// forge handles keybindings in a event
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package me.lucaslah.weatherchanger.forge;
|
||||||
|
|
||||||
|
import me.lucaslah.weatherchanger.WeatherChanger;
|
||||||
|
import me.lucaslah.weatherchanger.keybinding.Key;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.TickEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
|
||||||
|
@Mod("weatherchanger")
|
||||||
|
public class WeatherChangerForge {
|
||||||
|
private static WeatherChangerForge instance;
|
||||||
|
private ForgeKeybindingManager forgeKeybindingManager;
|
||||||
|
|
||||||
|
public WeatherChangerForge() {
|
||||||
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
modEventBus.addListener(this::onClientSetup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onClientSetup(FMLClientSetupEvent event) {
|
||||||
|
instance = this;
|
||||||
|
forgeKeybindingManager = new ForgeKeybindingManager();
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
WeatherChanger.init(new WeatherChangerPlatformImpl());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WeatherChangerForge getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForgeKeybindingManager getKeybindingManager() {
|
||||||
|
return forgeKeybindingManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void registerBindings(RegisterKeyMappingsEvent event) {
|
||||||
|
for (Key key : forgeKeybindingManager.getEntries()) {
|
||||||
|
event.register(key.getKeyBinding());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onClientTick(TickEvent.ClientTickEvent event) {
|
||||||
|
if (event.phase == TickEvent.Phase.END) {
|
||||||
|
for (Key key : forgeKeybindingManager.getEntries()) {
|
||||||
|
if (key.isEnabled() && key.getKeyBinding().wasPressed()) {
|
||||||
|
key.onPress(MinecraftClient.getInstance());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package me.lucaslah.weatherchanger.forge;
|
||||||
|
|
||||||
|
import me.lucaslah.weatherchanger.WeatherChangerPlatform;
|
||||||
|
import me.lucaslah.weatherchanger.keybinding.KeybindingManager;
|
||||||
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class WeatherChangerPlatformImpl implements WeatherChangerPlatform {
|
||||||
|
@Override
|
||||||
|
public Path getConfigDirectory() {
|
||||||
|
return FMLPaths.CONFIGDIR.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KeybindingManager getKeybindingManager() {
|
||||||
|
return WeatherChangerForge.getInstance().getKeybindingManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
28
forge/src/main/resources/META-INF/mods.toml
Normal file
28
forge/src/main/resources/META-INF/mods.toml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
modLoader = "javafml"
|
||||||
|
loaderVersion = "[4,)"
|
||||||
|
issueTrackerURL = "https://github.com/Lucaslah/WeatherChanger/issues"
|
||||||
|
license = "LGPL-3.0"
|
||||||
|
|
||||||
|
[[mods]]
|
||||||
|
modId = "${mod_id}"
|
||||||
|
version = "${version}"
|
||||||
|
displayName = "Weather Changer"
|
||||||
|
authors = "Lucaslah"
|
||||||
|
description = '''
|
||||||
|
Client side weather change for Minecraft
|
||||||
|
'''
|
||||||
|
logoFile = "icon.png"
|
||||||
|
|
||||||
|
[[dependencies.${mod_id}]]
|
||||||
|
modId = "forge"
|
||||||
|
mandatory = true
|
||||||
|
versionRange = "[43,)"
|
||||||
|
ordering = "NONE"
|
||||||
|
side = "CLIENT"
|
||||||
|
|
||||||
|
[[dependencies.${mod_id}]]
|
||||||
|
modId = "minecraft"
|
||||||
|
mandatory = true
|
||||||
|
versionRange = "[${minecraft_version},)"
|
||||||
|
ordering = "NONE"
|
||||||
|
side = "CLIENT"
|
||||||
6
forge/src/main/resources/pack.mcmeta
Normal file
6
forge/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"pack": {
|
||||||
|
"description": "Weather Changer",
|
||||||
|
"pack_format": 9
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,10 @@ mod_id = weatherchanger
|
|||||||
maven_group = me.lucaslah.weatherchanger
|
maven_group = me.lucaslah.weatherchanger
|
||||||
archives_base_name = weather-changer
|
archives_base_name = weather-changer
|
||||||
|
|
||||||
|
# Release Properties
|
||||||
|
# options: none,alpha,beta,release
|
||||||
|
release_channel=none
|
||||||
|
|
||||||
# Fabric
|
# Fabric
|
||||||
fabric.loader_version=0.14.21
|
fabric.loader_version=0.14.21
|
||||||
fabric.version=0.84.0+1.20.1
|
fabric.version=0.84.0+1.20.1
|
||||||
|
|||||||
@@ -24,3 +24,4 @@ pluginManagement {
|
|||||||
|
|
||||||
include("common")
|
include("common")
|
||||||
include("fabric")
|
include("fabric")
|
||||||
|
include("forge")
|
||||||
|
|||||||
Reference in New Issue
Block a user