Skip to content

Commit

Permalink
Fix infinite duration effects
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiahwinsley committed Aug 31, 2023
1 parent 9247aac commit cd19f42
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
32 changes: 23 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
Expand All @@ -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.

Expand Down Expand Up @@ -129,32 +130,45 @@ 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,
"Specification-Vendor" : group,
"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 {
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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



Original file line number Diff line number Diff line change
@@ -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<Float> 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);
}
}
}
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit cd19f42

Please sign in to comment.