Added a not yet ready for public mono sound mode
This commit is contained in:
parent
cfdf9fcca0
commit
b87a6b3586
@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
@me.shedaniel.autoconfig.annotation.Config.Gui.Background("textures/block/note_block.png")
|
||||
public class Config implements ConfigData {
|
||||
public boolean hideWarning;
|
||||
@ConfigEntry.Gui.Tooltip public boolean monoNoteBlocks;
|
||||
@ConfigEntry.Gui.Excluded @ConfigEntry.Gui.Tooltip(count = 2) public boolean monoNoteBlocks;
|
||||
|
||||
@ConfigEntry.Gui.Excluded
|
||||
public ArrayList<String> favorites = new ArrayList<>();
|
||||
|
@ -39,7 +39,6 @@ public class Main implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// TODO: 5/31/2022 Add a note block mono mode, making all note block sounds play as mono instead of as stereo\
|
||||
configHolder = AutoConfig.register(Config.class, JanksonConfigSerializer::new);
|
||||
config = configHolder.getConfig();
|
||||
|
||||
|
39
src/main/java/semmiedev/disc_jockey/MonoSoundInstance.java
Normal file
39
src/main/java/semmiedev/disc_jockey/MonoSoundInstance.java
Normal file
@ -0,0 +1,39 @@
|
||||
package semmiedev.disc_jockey;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.sound.AbstractSoundInstance;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
|
||||
// TODO: 6/1/2022 Make it actually mono
|
||||
public class MonoSoundInstance extends AbstractSoundInstance {
|
||||
private final Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
|
||||
|
||||
public MonoSoundInstance(SoundEvent sound, SoundCategory category, float volume, float pitch, Random random) {
|
||||
super(sound, category, random);
|
||||
this.volume = volume;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return getPos().x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return getPos().y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return getPos().z;
|
||||
}
|
||||
|
||||
private Vec3d getPos() {
|
||||
return camera.getPos().add(Vec3d.fromPolar(camera.getPitch(), camera.getYaw()).multiply(0, 0, 1));
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package semmiedev.disc_jockey.mixin;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import semmiedev.disc_jockey.Main;
|
||||
import semmiedev.disc_jockey.MonoSoundInstance;
|
||||
|
||||
@Mixin(ClientWorld.class)
|
||||
public class ClientWorldMixin {
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
|
||||
@Inject(method = "playSound(DDDLnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundCategory;FFZJ)V", at = @At("HEAD"), cancellable = true)
|
||||
private void makeNoteBlocksMono(double x, double y, double z, SoundEvent event, SoundCategory category, float volume, float pitch, boolean useDistance, long seed, CallbackInfo ci) {
|
||||
if (Main.config.monoNoteBlocks && Main.SONG_PLAYER.running && event.getId().getPath().startsWith("block.note_block")) {
|
||||
ci.cancel();
|
||||
client.getSoundManager().play(new MonoSoundInstance(event, category, volume, pitch, Random.create(seed)));
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
"disc_jockey.key_bind.open_screen": "Open song selection screen",
|
||||
"text.autoconfig.disc_jockey.title": "Disc Jockey",
|
||||
"text.autoconfig.disc_jockey.option.hideWarning": "Hide Warning",
|
||||
"text.autoconfig.disc_jockey.option.monoNoteBlocks": "Mono Note Block Sounds",
|
||||
"text.autoconfig.disc_jockey.option.monoNoteBlocks.@Tooltip": "Makes all the note block sounds mono instead of stereo, creating a more pleasurable listening experience (clientside)"
|
||||
"text.autoconfig.disc_jockey.option.monoNoteBlocks": "Non-Directional Note Block Sounds",
|
||||
"text.autoconfig.disc_jockey.option.monoNoteBlocks.@Tooltip[0]": "Makes all note block sounds when playing a song non-directional, creating a more pleasurable listening experience (clientside)",
|
||||
"text.autoconfig.disc_jockey.option.monoNoteBlocks.@Tooltip[1]": "If you don't know what that means, I recommend you just try it and hear the difference"
|
||||
}
|
12
src/main/resources/disc_jockey.mixins.json
Normal file
12
src/main/resources/disc_jockey.mixins.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "semmiedev.disc_jockey.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ClientWorldMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
@ -21,6 +21,9 @@
|
||||
"semmiedev.disc_jockey.ModMenuIntegration"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"disc_jockey.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabric": "*",
|
||||
"minecraft": "1.19-beta.5"
|
||||
|
Loading…
x
Reference in New Issue
Block a user