GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — added footstep-soundsliders for yourself and other players · Intiiii/OneConfigExampleMod@02ed171

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • build.gradle.kts
  • gradle.properties
  • src/main
    • java/org/polyfrost
      • ares
        • AresMod.java
        • config
          • TestConfig.java
        • mixin
          • SoundMixin.java
      • example
        • ExampleMod.java
        • command
          • ExampleCommand.java
        • config
          • TestConfig.java
        • hud
          • TestHud.java
        • mixin
          • MinecraftMixin.java
    • resources
      • mixins.ares.json
      • mixins.examplemod.json
  • update-to-301a6ca.md
  • update-to-fd8e095.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# OneConfigExampleMod
1+
# OneConfigAresMod
22

33
![Powered by OneConfig](https://polyfrost.org/media/branding/badges/badge_1.svg)
44
![Compact Powered by OneConfig](https://polyfrost.org/media/branding/badges/badge_2.svg)
Collapse file

‎build.gradle.kts‎

Copy file name to clipboardExpand all lines: build.gradle.kts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ val mod_version: String by project
2323
val mod_id: String by project
2424
val mod_archives_name: String by project
2525

26-
// Replaces the variables in `ExampleMod.java` to the ones specified in `gradle.properties`.
26+
// Replaces the variables in `AresMod.java` to the ones specified in `gradle.properties`.
2727
blossom {
2828
replaceToken("@VER@", mod_version)
2929
replaceToken("@NAME@", mod_name)
Collapse file

‎gradle.properties‎

Copy file name to clipboard
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# gradle.properties file -- CHANGE THE VALUES STARTING WITH `mod_*` AND REMOVE THIS COMMENT.
22

33
# Sets the name of your mod.
4-
mod_name=ExampleMod
4+
mod_name=Ares
55
# Sets the id of your mod that mod loaders use to recognize it.
6-
mod_id=examplemod
6+
mod_id=ares
77
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
88
mod_version=1.0.0
99
# Sets the name of the jar file that you put in your 'mods' folder.
10-
mod_archives_name=ExampleMod
10+
mod_archives_name=Ares
1111

1212
# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
1313
polyfrost.defaults.loom=3
1414
org.gradle.daemon=true
1515
org.gradle.parallel=true
1616
org.gradle.configureoncommand=true
1717
org.gradle.parallel.threads=4
18-
org.gradle.jvmargs=-Xmx2G
18+
org.gradle.jvmargs=-Xmx2G
19+
org.gradle.java.home=C:\\Program Files\\Java\\jdk-1.8
Collapse file

‎src/main/java/org/polyfrost/ares/AresMod.java‎

Copy file name to clipboard
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.polyfrost.ares;
2+
3+
import org.polyfrost.ares.config.TestConfig;
4+
import cc.polyfrost.oneconfig.events.event.InitializationEvent;
5+
import net.minecraftforge.fml.common.Mod;
6+
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
7+
8+
/**
9+
* The Ares Mod - Footstep Volume Control
10+
*/
11+
@Mod(modid = AresMod.MODID, name = AresMod.NAME, version = AresMod.VERSION)
12+
public class AresMod {
13+
public static final String MODID = "@ID@";
14+
public static final String NAME = "@NAME@";
15+
public static final String VERSION = "@VER@";
16+
17+
@Mod.Instance(MODID)
18+
public static AresMod INSTANCE;
19+
public static TestConfig config;
20+
21+
@Mod.EventHandler
22+
public void onInit(FMLInitializationEvent event) {
23+
config = new TestConfig();
24+
}
25+
}
Collapse file

‎src/main/java/org/polyfrost/ares/config/TestConfig.java‎

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.polyfrost.ares.config;
2+
3+
import org.polyfrost.ares.AresMod;
4+
import cc.polyfrost.oneconfig.config.Config;
5+
import cc.polyfrost.oneconfig.config.annotations.Slider;
6+
import cc.polyfrost.oneconfig.config.data.Mod;
7+
import cc.polyfrost.oneconfig.config.data.ModType;
8+
9+
/**
10+
* Configuration for the Ares mod footstep volume controls
11+
*/
12+
public class TestConfig extends Config {
13+
@Slider(
14+
name = "Own Footsteps Volume",
15+
min = 0f, max = 100f,
16+
step = 5,
17+
description = "Adjust the volume of your own footsteps"
18+
)
19+
public static float ownFootstepsVolume = 100f;
20+
21+
@Slider(
22+
name = "Other Players Footsteps Volume",
23+
min = 0f, max = 100f,
24+
step = 5,
25+
description = "Adjust the volume of other players' footsteps"
26+
)
27+
public static float otherFootstepsVolume = 100f;
28+
29+
public TestConfig() {
30+
super(new Mod(AresMod.NAME, ModType.UTIL_QOL), AresMod.MODID + ".json");
31+
initialize();
32+
}
33+
}
Collapse file

‎src/main/java/org/polyfrost/ares/mixin/SoundMixin.java‎

Copy file name to clipboard
+115Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package org.polyfrost.ares.mixin;
2+
3+
import net.minecraft.client.audio.ISound;
4+
import net.minecraft.client.audio.SoundManager;
5+
import net.minecraft.client.Minecraft;
6+
import net.minecraft.entity.Entity;
7+
import org.polyfrost.ares.AresMod;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
11+
12+
@Mixin(SoundManager.class)
13+
public class SoundMixin {
14+
15+
@ModifyVariable(
16+
method = "playSound",
17+
at = @At("HEAD"),
18+
ordinal = 0
19+
)
20+
private ISound modifySound(ISound sound) {
21+
if (sound == null) return sound;
22+
23+
String soundName = sound.getSoundLocation().getResourcePath().toLowerCase();
24+
System.out.println("[Ares] Sound playing: " + soundName);
25+
26+
// Check of het een voetstap geluid is
27+
if (soundName.contains("step") || soundName.contains("dig")) {
28+
float x = sound.getXPosF();
29+
float y = sound.getYPosF();
30+
float z = sound.getZPosF();
31+
32+
Entity closestEntity = null;
33+
double closestDistance = 1.0; // Maximale afstand om een entity te vinden
34+
35+
// Zoek de dichtstbijzijnde entity bij het geluid
36+
for (Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) {
37+
double distance = entity.getDistanceSq(x, y, z);
38+
if (distance < closestDistance) {
39+
closestDistance = distance;
40+
closestEntity = entity;
41+
}
42+
}
43+
44+
// Als we een entity hebben gevonden
45+
if (closestEntity != null) {
46+
System.out.println("[Ares] Found entity: " + closestEntity.getClass().getName());
47+
48+
// Check of het de speler zelf is
49+
if (closestEntity == Minecraft.getMinecraft().thePlayer) {
50+
return new ModifiedSound(sound, AresMod.config.ownFootstepsVolume / 100f);
51+
} else {
52+
return new ModifiedSound(sound, AresMod.config.otherFootstepsVolume / 100f);
53+
}
54+
}
55+
}
56+
57+
return sound;
58+
}
59+
60+
// Inner class om het volume van een geluid aan te passen
61+
private static class ModifiedSound implements ISound {
62+
private final ISound original;
63+
private final float volumeMultiplier;
64+
65+
public ModifiedSound(ISound original, float volumeMultiplier) {
66+
this.original = original;
67+
this.volumeMultiplier = volumeMultiplier;
68+
}
69+
70+
@Override
71+
public net.minecraft.util.ResourceLocation getSoundLocation() {
72+
return original.getSoundLocation();
73+
}
74+
75+
@Override
76+
public float getVolume() {
77+
return Math.max(0.0001f, original.getVolume() * volumeMultiplier);
78+
}
79+
80+
@Override
81+
public float getPitch() {
82+
return original.getPitch();
83+
}
84+
85+
@Override
86+
public float getXPosF() {
87+
return original.getXPosF();
88+
}
89+
90+
@Override
91+
public float getYPosF() {
92+
return original.getYPosF();
93+
}
94+
95+
@Override
96+
public float getZPosF() {
97+
return original.getZPosF();
98+
}
99+
100+
@Override
101+
public net.minecraft.client.audio.ISound.AttenuationType getAttenuationType() {
102+
return original.getAttenuationType();
103+
}
104+
105+
@Override
106+
public boolean canRepeat() {
107+
return original.canRepeat();
108+
}
109+
110+
@Override
111+
public int getRepeatDelay() {
112+
return original.getRepeatDelay();
113+
}
114+
}
115+
}
Collapse file

‎src/main/java/org/polyfrost/example/ExampleMod.java‎

Copy file name to clipboardExpand all lines: src/main/java/org/polyfrost/example/ExampleMod.java
-33Lines changed: 0 additions & 33 deletions
This file was deleted.
Collapse file

‎src/main/java/org/polyfrost/example/command/ExampleCommand.java‎

Copy file name to clipboardExpand all lines: src/main/java/org/polyfrost/example/command/ExampleCommand.java
-21Lines changed: 0 additions & 21 deletions
This file was deleted.
Collapse file

‎src/main/java/org/polyfrost/example/config/TestConfig.java‎

Copy file name to clipboardExpand all lines: src/main/java/org/polyfrost/example/config/TestConfig.java
-48Lines changed: 0 additions & 48 deletions
This file was deleted.
Collapse file

‎src/main/java/org/polyfrost/example/hud/TestHud.java‎

Copy file name to clipboardExpand all lines: src/main/java/org/polyfrost/example/hud/TestHud.java
-20Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.