Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
- Using F3+U allows the player to cycle through volumes.
  • Loading branch information
Lukiiy committed Feb 2, 2025
1 parent 7f614f7 commit 8fa3439
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
12 changes: 1 addition & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ processResources {
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}

Expand All @@ -52,19 +49,12 @@ jar {
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
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.
}
repositories {}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ org.gradle.parallel=true
loader_version=0.15.6-babric.2

# Mod Properties
mod_version = 1.0.0
mod_version = 1.0.1
maven_group = me.lukiiy
archives_base_name = lowrain
5 changes: 3 additions & 2 deletions src/main/java/me/lukiiy/lowrain/LowVolumeRain.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class LowVolumeRain implements ModInitializer {
public static final String ID = "lowrain";
public static final Logger LOGGER = LoggerFactory.getLogger(ID);

@Override
public void onInitialize() {}
public static float Volume = 0.025f;

@Override public void onInitialize() {}
}
32 changes: 32 additions & 0 deletions src/main/java/me/lukiiy/lowrain/mixin/ClientMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package me.lukiiy.lowrain.mixin;

import me.lukiiy.lowrain.LowVolumeRain;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.ClientPlayerEntity;
import org.lwjgl.input.Keyboard;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Arrays;
import java.util.List;

@Mixin(Minecraft.class)
public class ClientMixin {
@Shadow public ClientPlayerEntity player;
@Unique private static final List<Float> volCycle = Arrays.asList(0.12f, 0.075f, 0.05f, 0.025f, 0.012f);
@Unique private static int volIdx = 2;

@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isWorldRemote()Z", ordinal = 0))
private void lowrain_key(CallbackInfo info) {
if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_U && Keyboard.isKeyDown(Keyboard.KEY_F3)) {
volIdx = (volIdx + 1) % volCycle.size();
LowVolumeRain.Volume = volCycle.get(volIdx);

this.player.method_490("§e[LowVolumeRain] §fSet the volume to " + LowVolumeRain.Volume + "!");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.lukiiy.lowrain.mixin;

import me.lukiiy.lowrain.LowVolumeRain;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.class_555;
Expand All @@ -13,6 +14,6 @@
public class DecreaseVolumeMixin {
@Redirect(method = "method_1846", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;method_150(DDDLjava/lang/String;FF)V"))
private void lowrain_change(World instance, double e, double f, double string, String g, float h, float v) {
instance.method_150(e, f, string, g, 0.025f, v);
instance.method_150(e, f, string, g, LowVolumeRain.Volume, v);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/lowrain.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"mixins": [
],
"client": [
"DecreaseVolumeMixin"
"DecreaseVolumeMixin",
"ClientMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 8fa3439

Please sign in to comment.