From 2cb91092f6230784b268df1a22dd6f31415c8569 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Fri, 21 May 2021 15:23:29 +0800 Subject: [PATCH] netherPortalSoundChance --- README.md | 5 ++-- gradle.properties | 2 +- .../config/TweakerMoreConfigs.java | 5 ++++ .../mixins/core/GenericConfigsMixin.java | 26 +++++++++++++++++++ .../NetherPortalBlockMixin.java | 23 ++++++++++++++++ src/main/resources/tweakermore.mixins.json | 2 ++ 6 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 src/main/java/me/fallenbreath/tweakermore/mixins/core/GenericConfigsMixin.java create mode 100644 src/main/java/me/fallenbreath/tweakermore/mixins/netherPortalSoundChance/NetherPortalBlockMixin.java diff --git a/README.md b/README.md index 71015359..bbb2f535 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ An addon of masa's [tweakeroo](https://github.com/maruohon/tweakeroo) mod using epic mixin hack -New Disable tweaks: +New tweaks: -- disableLightUpdates +- netherPortalSoundChance (Generic) +- disableLightUpdates (Disable) diff --git a/gradle.properties b/gradle.properties index 367c73b5..aa8ba31e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.10.3+build.211 # Mod Properties - mod_version = 1.0.1 + mod_version = 1.1.0 maven_group = tweakermore archives_base_name = tweakermore diff --git a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java index 9d80985f..95fb5b1c 100644 --- a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java +++ b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java @@ -1,8 +1,13 @@ package me.fallenbreath.tweakermore.config; import fi.dy.masa.malilib.config.options.ConfigBooleanHotkeyed; +import fi.dy.masa.malilib.config.options.ConfigDouble; public class TweakerMoreConfigs { + // Generic + public static final ConfigDouble NETHER_PORTAL_SOUND_CHANCE = new ConfigDouble("netherPortalSoundChance", 0.01D, 0.0D, 0.01D, "The chance for a nether portal block to play sound\nSet it to 0.001 or 0.0001 for less noisy portal"); + + // Disable public static final ConfigBooleanHotkeyed DISABLE_LIGHT_UPDATES = new ConfigBooleanHotkeyed("disableLightUpdates", false, "", "Yeets client-side light updates"); } diff --git a/src/main/java/me/fallenbreath/tweakermore/mixins/core/GenericConfigsMixin.java b/src/main/java/me/fallenbreath/tweakermore/mixins/core/GenericConfigsMixin.java new file mode 100644 index 00000000..4122a654 --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/mixins/core/GenericConfigsMixin.java @@ -0,0 +1,26 @@ +package me.fallenbreath.tweakermore.mixins.core; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import fi.dy.masa.malilib.config.IConfigBase; +import fi.dy.masa.tweakeroo.config.Configs; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.List; + +@Mixin(Configs.Generic.class) +public abstract class GenericConfigsMixin +{ + @Mutable + @Shadow(remap = false) @Final public static ImmutableList OPTIONS; + + static + { + List optionList = Lists.newArrayList(OPTIONS); + optionList.add(me.fallenbreath.tweakermore.config.TweakerMoreConfigs.NETHER_PORTAL_SOUND_CHANCE); + OPTIONS = ImmutableList.copyOf(optionList); + } +} diff --git a/src/main/java/me/fallenbreath/tweakermore/mixins/netherPortalSoundChance/NetherPortalBlockMixin.java b/src/main/java/me/fallenbreath/tweakermore/mixins/netherPortalSoundChance/NetherPortalBlockMixin.java new file mode 100644 index 00000000..94914924 --- /dev/null +++ b/src/main/java/me/fallenbreath/tweakermore/mixins/netherPortalSoundChance/NetherPortalBlockMixin.java @@ -0,0 +1,23 @@ +package me.fallenbreath.tweakermore.mixins.netherPortalSoundChance; + +import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; +import net.minecraft.block.NetherPortalBlock; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(value = NetherPortalBlock.class, priority = 10000) +public abstract class NetherPortalBlockMixin +{ + @ModifyConstant( + method = "randomDisplayTick", + constant = @Constant(intValue = 100), + require = 0, + allow = 1 + ) + private int modifyPlaySoundChance(int vanillaChance) + { + double value = TweakerMoreConfigs.NETHER_PORTAL_SOUND_CHANCE.getDoubleValue(); + return value <= 0.0D ? Integer.MAX_VALUE : (int)(1.0D / value); + } +} diff --git a/src/main/resources/tweakermore.mixins.json b/src/main/resources/tweakermore.mixins.json index 21bc36fc..a369937f 100644 --- a/src/main/resources/tweakermore.mixins.json +++ b/src/main/resources/tweakermore.mixins.json @@ -4,6 +4,8 @@ "package": "me.fallenbreath.tweakermore.mixins", "compatibilityLevel": "JAVA_8", "mixins": [ + "core.GenericConfigsMixin", + "netherPortalSoundChance.NetherPortalBlockMixin" ], "client": [ "core.DisableConfigsMixin",