diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bcaf166..893c9a0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,7 +33,7 @@ jobs: with: file_path: "${{ fromJson(steps.get_release_assets.outputs.downloaded_files)[0] }}" game_endpoint: "minecraft" - game_versions: "Minecraft 1.20:1.20,Java 17,Forge" + game_versions: "Minecraft 1.20:1.20.1,Java 17,Forge" project_id: "431430" token: ${{ secrets.CF_API_TOKEN }} changelog: "${{ fromJson(steps.get_release_by_tag.outputs.data).body }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57c7627..e5363f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,4 +27,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - asset_paths: '["build/libs/*.jar"]' + asset_paths: '["build/libs/*.jar", "build/checksums/*.sha512"]' diff --git a/build.gradle b/build.gradle index 9c41a6f..7322e73 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id 'idea' id 'maven-publish' + id 'org.gradle.crypto.checksum' version '1.4.0' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' } @@ -26,7 +27,7 @@ minecraft { // // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'official', version: '1.20' + mappings channel: 'official', version: minecraft_version // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. @@ -129,14 +130,14 @@ dependencies { // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.20-46.0.2' + minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' } // Example for how to get properties into the manifest for reading at runtime. jar { - archiveBaseName.set("${mod_id}-${mc_version}") + archiveBaseName.set("${mod_id}-${minecraft_version}") manifest { attributes([ "Specification-Title" : mod_id, @@ -144,17 +145,30 @@ jar { "Specification-Version" : "1", // We are version 1 of ourselves "Implementation-Title" : project.name, "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "MixinConfigs": "${mod_id}.mixins.json" ]) } + + // The settings below make sure that your build is reproducible + // More information at https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives + preserveFileTimestamps = false + reproducibleFileOrder = true + + // Example configuration to allow publishing using the maven-publish plugin + // This is the preferred method to reobfuscate your jar file + finalizedBy('reobfJar') } -// Example configuration to allow publishing using the maven-publish plugin -// This is the preferred method to reobfuscate your jar file -jar.finalizedBy('reobfJar') -// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing -// publish.dependsOn('reobfJar') +// generate checksum for output jar +import org.gradle.crypto.checksum.Checksum +tasks.register('createChecksums', Checksum) { + dependsOn jar + + inputFiles.setFrom(jar.outputs.files) + checksumAlgorithm.set(Checksum.Algorithm.SHA512) + appendFileNameToChecksum.set(true) +} +build.finalizedBy('createChecksums') publishing { publications { diff --git a/gradle.properties b/gradle.properties index 499d869..c425307 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,11 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mc_version=1.20 +minecraft_version=1.20.1 +forge_version=47.1.0 group=net.permutated mod_id=flickerfix -version=4.0.0 +version=4.0.1 diff --git a/src/main/java/net/permutated/flickerfix/mixin/MixinGameRenderer.java b/src/main/java/net/permutated/flickerfix/mixin/MixinGameRenderer.java index 0c7fdd4..9f36412 100644 --- a/src/main/java/net/permutated/flickerfix/mixin/MixinGameRenderer.java +++ b/src/main/java/net/permutated/flickerfix/mixin/MixinGameRenderer.java @@ -1,26 +1,25 @@ package net.permutated.flickerfix.mixin; -import net.permutated.flickerfix.FlickerFix; import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.LivingEntity; +import net.permutated.flickerfix.FlickerFix; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Optional; - -@SuppressWarnings({"java:S1118", "java:S1610"}) +@SuppressWarnings("java:S1118") @Mixin(GameRenderer.class) public abstract class MixinGameRenderer { @Inject(method = "getNightVisionScale", at = @At("HEAD"), cancellable = true) private static void getNightVisionScale(LivingEntity livingEntityIn, float entitylivingbaseIn, CallbackInfoReturnable cir) { - int i = Optional.ofNullable(livingEntityIn.getEffect(MobEffects.NIGHT_VISION)) - .map(MobEffectInstance::getDuration).orElse(0); - - cir.setReturnValue(i > FlickerFix.fadeTicks ? FlickerFix.brightness : i * FlickerFix.fadeRate); + MobEffectInstance instance = livingEntityIn.getEffect(MobEffects.NIGHT_VISION); + if (instance != null && !instance.isInfiniteDuration()) { + int i = instance.getDuration(); + cir.setReturnValue(i > FlickerFix.fadeTicks ? FlickerFix.brightness : i * FlickerFix.fadeRate); + } } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index ab0dcf8..48ea379 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[46,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[47,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="All rights reserved" @@ -33,7 +33,7 @@ Disables nightvision flickering when duration goes below 10 seconds. # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[46,)" #mandatory + versionRange="[47,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER