From 4325c5a3f0d03869ffe543687aad106dd49a84c7 Mon Sep 17 00:00:00 2001 From: MUKSC <68376185+MUKSC@users.noreply.github.com> Date: Wed, 4 Dec 2024 02:40:22 +0900 Subject: [PATCH] initial commit --- .gitignore | 119 ++++++++++++++++++ LICENSE.txt | 2 + build.gradle.kts | 79 ++++++++++++ gradle.properties | 9 ++ gradle/libs.versions.toml | 19 +++ gradle/wrapper/gradle-wrapper.properties | 1 + settings.gradle.kts | 8 ++ .../me/muksc/mcssc/MCSSCMixinCanceller.java | 12 ++ .../muksc/mcssc/mixin/WorldRendererMixin.java | 38 ++++++ src/main/resources/fabric.mod.json | 24 ++++ src/main/resources/mcssc.mixins.json | 12 ++ 11 files changed, 323 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 build.gradle.kts create mode 100644 gradle.properties create mode 100644 gradle/libs.versions.toml create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 settings.gradle.kts create mode 100644 src/main/java/me/muksc/mcssc/MCSSCMixinCanceller.java create mode 100644 src/main/java/me/muksc/mcssc/mixin/WorldRendererMixin.java create mode 100644 src/main/resources/fabric.mod.json create mode 100644 src/main/resources/mcssc.mixins.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5f737e --- /dev/null +++ b/.gitignore @@ -0,0 +1,119 @@ +# User-specific stuff +.idea/ + +*.iml +*.ipr +*.iws + +# IntelliJ +out/ +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Cache of project +.gradletasknamecache + +**/build/ + +# Common working directory +run/ +runs/ + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..c345176 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,2 @@ +Copyright (c) 2024 +All rights reserved. diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..c009621 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,79 @@ +plugins { + alias(libs.plugins.fabric.loom) +} + +version = project.property("mod_version") as String +group = project.property("maven_group") as String + +base { + archivesName.set(project.property("archives_base_name") as String) +} + +val targetJavaVersion = 17 +java { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) +} + +loom { +// accessWidenerPath = file("src/main/resources/darkdaysahead.accesswidener") + + mods { + register("mcssc") { + sourceSet("main") + } + } +} + +repositories { + exclusiveContent { + forRepository { + maven { + name = "Modrinth" + url = uri("https://api.modrinth.com/maven") + } + } + filter { + includeGroup("maven.modrinth") + } + } + maven("https://maven.bawnorton.com/releases") + maven("https://maven.shedaniel.me") + maven("https://maven.terraformersmc.com/releases") +} + +dependencies { + minecraft(libs.com.mojang.minecraft) + mappings(variantOf(libs.net.fabricmc.yarn) { classifier("v2") }) + modImplementation(libs.net.fabricmc.fabric.loader) + libs.com.github.bawnorton.mixinsquared.fabric.run { + annotationProcessor(this) + implementation(this) + include(this) + } + + modCompileOnly(libs.modrinth.sereneseasons) +} + +tasks.processResources { + val properties = mapOf( + "id" to project.property("mod_id") as String, + "version" to project.version, + "name" to project.property("mod_name") as String, + "minecraft_version" to libs.versions.minecraft.get(), + "loader_version" to libs.versions.fabric.loader.get() + ) + filteringCharset = "UTF-8" + inputs.properties(properties) + filesMatching("fabric.mod.json") { expand(properties) } +} + +tasks.withType().configureEach { + options.encoding = "UTF-8" + options.release.set(targetJavaVersion) +} + +tasks.jar { + from("LICENSE") { + rename { "${it}_${project.base.archivesName}" } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..a09e63d --- /dev/null +++ b/gradle.properties @@ -0,0 +1,9 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G + +# Mod Properties +mod_id=moreculling-sereneseasons-compat +mod_version=1.0.0 +mod_name=MoreCulling-Serene Seasons Compat +maven_group=me.muksc.mcssc +archives_base_name=moreculling-sereneseasons-compat diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..6ad1469 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,19 @@ +[versions] +loom = "1.8-SNAPSHOT" +minecraft = "1.20.1" +yarn = "1.20.1+build.10" +fabric-loader = "0.16.9" +mixinsquared = "0.2.0" + +sereneseasons = "4RgDk9NB" + +[libraries] +com-mojang-minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } +net-fabricmc-yarn = { module = "net.fabricmc:yarn", version.ref = "yarn" } +net-fabricmc-fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" } +com-github-bawnorton-mixinsquared-fabric = { module = "com.github.bawnorton.mixinsquared:mixinsquared-fabric", version.ref = "mixinsquared" } + +modrinth-sereneseasons = { module = "maven.modrinth:serene-seasons", version.ref = "sereneseasons" } + +[plugins] +fabric-loom = { id = "fabric-loom", version.ref = "loom" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..de9161e --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..05eb23d --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,8 @@ +pluginManagement { + repositories { + maven("https://maven.fabricmc.net/") { + name = "Fabric" + } + gradlePluginPortal() + } +} diff --git a/src/main/java/me/muksc/mcssc/MCSSCMixinCanceller.java b/src/main/java/me/muksc/mcssc/MCSSCMixinCanceller.java new file mode 100644 index 0000000..4d2883b --- /dev/null +++ b/src/main/java/me/muksc/mcssc/MCSSCMixinCanceller.java @@ -0,0 +1,12 @@ +package me.muksc.mcssc; + +import com.bawnorton.mixinsquared.api.MixinCanceller; + +import java.util.List; + +public class MCSSCMixinCanceller implements MixinCanceller { + @Override + public boolean shouldCancel(List targetClassNames, String mixinClassName) { + return mixinClassName.equals("sereneseasons.mixin.client.MixinLevelRenderer"); + } +} diff --git a/src/main/java/me/muksc/mcssc/mixin/WorldRendererMixin.java b/src/main/java/me/muksc/mcssc/mixin/WorldRendererMixin.java new file mode 100644 index 0000000..dc1df80 --- /dev/null +++ b/src/main/java/me/muksc/mcssc/mixin/WorldRendererMixin.java @@ -0,0 +1,38 @@ +package me.muksc.mcssc.mixin; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.minecraft.client.render.WorldRenderer; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import org.spongepowered.asm.mixin.Debug; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import sereneseasons.season.SeasonHooks; + +@Debug(export = true) +@Mixin(value = WorldRenderer.class, priority = 1500) +public abstract class WorldRendererMixin { + @Unique + private World world; + @Unique + private RegistryEntry biome; + + @WrapOperation(method = "renderWeather", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBiome(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/registry/entry/RegistryEntry;")) + private RegistryEntry storeBiome(World instance, BlockPos blockPos, Operation> original) { + RegistryEntry result = original.call(instance, blockPos); + world = instance; + biome = result; + return result; + } + + @ModifyExpressionValue(method = "renderWeather", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;hasPrecipitation()Z")) + private boolean hasPrecipitation(boolean original) { + return SeasonHooks.hasPrecipitationSeasonal(world, biome); + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..3825000 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,24 @@ +{ + "schemaVersion": 1, + "id": "${id}", + "version": "${version}", + "name": "${name}", + "description": "", + "authors": [], + "contact": {}, + "license": "All-Rights-Reserved", + "environment": "client", + "entrypoints": { + "mixinsquared": [ + "me.muksc.mcssc.MCSSCMixinCanceller" + ] + }, + "mixins": [ + "mcssc.mixins.json" + ], + "depends": { + "fabricloader": ">=${loader_version}", + "minecraft": "${minecraft_version}", + "sereneseasons": "*" + } +} diff --git a/src/main/resources/mcssc.mixins.json b/src/main/resources/mcssc.mixins.json new file mode 100644 index 0000000..933ac0e --- /dev/null +++ b/src/main/resources/mcssc.mixins.json @@ -0,0 +1,12 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "me.muksc.mcssc.mixin", + "compatibilityLevel": "JAVA_17", + "client": [ + "WorldRendererMixin" + ], + "injectors": { + "defaultRequire": 1 + } +}