Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.1.2 #433

Merged
merged 17 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
1.20.4
1.21
1.21.1
1.21.2
1.21.3
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand All @@ -84,6 +86,8 @@ jobs:
1.20.4
1.21
1.21.1
1.21.2
1.21.3
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
1.20.4
1.21
1.21.1
1.21.2
1.21.3
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand All @@ -82,6 +84,8 @@ jobs:
1.20.4
1.21
1.21.1
1.21.2
1.21.3
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ public interface AlSource extends DeviceSource {
*/
void setCloseTimeoutMs(long timeoutMs);

/**
* Updates last buffer time to current time provided by the time supplier.
*/
void updateLastBufferTime();

/**
* Gets the OpenAL format of the source.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ interface ClientConfig {

val panning: BooleanConfigEntry

val mutePlayerOnDirect: BooleanConfigEntry

val cameraSoundListener: BooleanConfigEntry

val exponentialVolumeSlider: BooleanConfigEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AudioSender(

val job = CoroutineScope(Dispatchers.Default).launch {
var sequenceNumber = 0L
val startTime = System.nanoTime()
var startTime = 0L

var endOfStream = false

Expand All @@ -49,6 +49,7 @@ class AudioSender(
if (!endOfStream) {
endOfStream = true
onEnd.invoke(sequenceNumber++)
startTime = 0L
}

delay(10L)
Expand All @@ -61,6 +62,7 @@ class AudioSender(

endOfStream = true
onEnd.invoke(sequenceNumber++)
startTime = 0L
continue
}

Expand All @@ -76,6 +78,10 @@ class AudioSender(
continue
}

if (startTime == 0L) {
startTime = System.nanoTime()
}

val frameTime = 20_000_000 * sequenceNumber
val waitTime = startTime + frameTime - System.nanoTime()

Expand Down
1 change: 0 additions & 1 deletion client/1.21.2-neoforge/gradle.properties

This file was deleted.

1 change: 1 addition & 0 deletions client/1.21.3-neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
essential.defaults.loom.neoForge=net.neoforged:neoforge:21.3.57
1 change: 1 addition & 0 deletions client/1.21.4-fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
essential.defaults.loom.minecraft=com.mojang:minecraft:1.21.4
1 change: 1 addition & 0 deletions client/1.21.4-neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
essential.defaults.loom.neoForge=net.neoforged:neoforge:21.4.2-beta
15 changes: 11 additions & 4 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ val shadowCommon by configurations.creating
fun slibArtifact(): String {
val minecraftVersion = when (platform.mcVersion) {
11904 -> "1.19.3"
12103, 12104 -> "1.21.2"
else -> platform.mcVersionStr
}

Expand Down Expand Up @@ -88,15 +89,21 @@ dependencies {
12004 -> "0.95.4+1.20.4"
12006 -> "0.97.7+1.20.6"
12100 -> "0.100.4+1.21"
12102 -> "0.105.3+1.21.2"
12103 -> "0.110.0+1.21.3"
12104 -> "0.110.5+1.21.4"
else -> throw GradleException("Unsupported platform $platform")
}

modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricApiVersion}")
fun fabricApiModules(vararg module: String) {
module.forEach {
modImplementation(fabricApi.module("fabric-$it", fabricApiVersion))
}
}

fabricApiModules("rendering-v1", "networking-api-v1", "lifecycle-events-v1", "key-binding-api-v1")

if (platform.mcVersion >= 12102) {
// https://github.com/lucko/fabric-permissions-api/pull/26
"include"("com.github.sakura-ryoko:fabric-permissions-api:b43d33efb8")
"include"("me.lucko:fabric-permissions-api:0.3.3")
} else {
"include"("me.lucko:fabric-permissions-api:0.2-SNAPSHOT")
}
Expand Down
16 changes: 7 additions & 9 deletions client/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ If you encounter any issues, please report them on Discord: https://discord.gg/u
Versions 2.0.x and 2.1.x are protocol-compatible,
so there’s no need to worry if the server hasn't been updated to 2.1.x.

### Changes in 2.1.1
- Build for 1.19.3 was reintroduced.
- Soften Minecraft version bounds:
- 1.20.4 now allows 1.20.2, 1.20.3 and 1.20.4
- 1.19.2 now allows 1.19, 1.19.1 and 1.19.2
- Updated to 1.21.2.
- Updated [slib](https://github.com/plasmoapp/mc-slib) to fix crash with EssentialAddons on world join.
- Fixed audio sources causing a high CPU load. [#421](https://github.com/plasmoapp/plasmo-voice/issues/421)
- Attempt to fix "Cannot measure distance between worlds" exception, see [#422](https://github.com/plasmoapp/plasmo-voice/issues/422).
### Changes in 2.1.2
- 1.21.4 fabric/neoforge.
- Fixed buffer overflow when using AudioSender with delayed first frame.
- Fixed EncoderException on server switch on servers with proxy and proxy-side addons (e.g, groups addon).
- Fixed `pv.activation.*` permission is not being updated on the client without reconnect.
- Fixed textfield input not being handled.
- Player sources are now automatically muted if the direct source from the same player becomes active. Can be disabled in menu `Advanced`/`Mute Player On Direct`.
14 changes: 10 additions & 4 deletions client/root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ group = "$group.client-root"

preprocess {

val neoForge12102 = createNode("1.21.2-neoforge", 12102, "official")
val fabric12102 = createNode("1.21.2-fabric", 12102, "official")
val neoForge12104 = createNode("1.21.4-neoforge", 12104, "official")
val fabric12104 = createNode("1.21.4-fabric", 12104, "official")

val neoForge12103 = createNode("1.21.3-neoforge", 12103, "official")
val fabric12103 = createNode("1.21.3-fabric", 12103, "official")

val neoForge12100 = createNode("1.21-neoforge", 12100, "official")
val fabric12100 = createNode("1.21-fabric", 12100, "official")
Expand Down Expand Up @@ -37,8 +40,11 @@ preprocess {
val forge11605 = createNode("1.16.5-forge", 11605, "official")
val fabric11605 = createNode("1.16.5-fabric", 11605, "official")

fabric12102.link(fabric12100)
neoForge12102.link(neoForge12100)
fabric12104.link(fabric12103)
neoForge12104.link(neoForge12103)

fabric12103.link(fabric12100)
neoForge12103.link(neoForge12100)

neoForge12100.link(fabric12100)
fabric12100.link(fabric12004, file("1.21-1.20.6.txt"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,14 @@ public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
// return screen.mouseScrolled(mouseX, mouseY, delta);
// }

@Override
public boolean charTyped(char typedChar, int modifiers) {
return screen.charTyped(typedChar, modifiers);
}

@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == 0) {
screen.charTyped((char) 0, modifiers);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@
import su.plo.voice.api.client.audio.capture.AudioCapture;
import su.plo.voice.api.client.audio.capture.ClientActivation;
import su.plo.voice.api.client.audio.capture.ClientActivationManager;
import su.plo.voice.api.client.audio.device.AudioDevice;
import su.plo.voice.api.client.audio.device.DeviceManager;
import su.plo.voice.api.client.audio.device.DeviceType;
import su.plo.voice.api.client.audio.device.InputDevice;
import su.plo.voice.api.client.connection.ServerInfo;
import su.plo.voice.api.client.event.audio.capture.*;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureEvent;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureInitializeEvent;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureProcessedEvent;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureStartEvent;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureStopEvent;
import su.plo.voice.api.encryption.Encryption;
import su.plo.voice.api.encryption.EncryptionException;
import su.plo.voice.api.util.AudioUtil;
import su.plo.voice.client.audio.device.JavaxInputDeviceFactory;
import su.plo.voice.client.audio.filter.StereoToMonoFilter;
import su.plo.voice.client.config.VoiceClientConfig;
import su.plo.voice.client.mac.AVAuthorizationStatus;
Expand All @@ -41,7 +44,10 @@
import su.plo.voice.proto.packets.udp.serverbound.PlayerAudioPacket;

import javax.sound.sampled.AudioFormat;
import java.util.*;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

public final class VoiceAudioCapture implements AudioCapture {

Expand Down Expand Up @@ -123,6 +129,7 @@ public void initialize(@NotNull ServerInfo serverInfo) {
devices.setInputDevice(inputDevice);
} catch (Exception e) {
LOGGER.error("Failed to open input device", e);
JavaxInputDeviceFactory.printSupportedLines();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,45 @@
import com.google.common.collect.ImmutableList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.plo.voice.BaseVoice;
import su.plo.voice.api.client.PlasmoVoiceClient;
import su.plo.voice.api.client.audio.device.AudioDevice;
import su.plo.voice.api.client.audio.device.DeviceException;
import su.plo.voice.api.client.audio.device.DeviceFactory;

import javax.sound.sampled.*;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.Line;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.TargetDataLine;
import java.util.ArrayList;
import java.util.List;

import static com.google.common.base.Preconditions.checkNotNull;

public final class JavaxInputDeviceFactory implements DeviceFactory {

public static void printSupportedLines() {
BaseVoice.DEBUG_LOGGER.log("Supported target data lines:");

Mixer.Info[] mixers = AudioSystem.getMixerInfo();
for (Mixer.Info mixerInfo : mixers) {
Mixer mixer = AudioSystem.getMixer(mixerInfo);
Line.Info lineInfo = new Line.Info(TargetDataLine.class);

if (mixer.isLineSupported(lineInfo)) {
for (Line.Info info : mixer.getTargetLineInfo()) {
BaseVoice.DEBUG_LOGGER.log(info.toString());
DataLine.Info dataInfo = (DataLine.Info) info;
for (AudioFormat dataFormat : dataInfo.getFormats()) {
BaseVoice.DEBUG_LOGGER.log(dataFormat.toString());
}
}
}
}
}

private final PlasmoVoiceClient client;

public JavaxInputDeviceFactory(PlasmoVoiceClient client) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ public static class Advanced implements ClientConfig.Advanced {
@ConfigField
private BooleanConfigEntry panning = new BooleanConfigEntry(true);

@ConfigField
private BooleanConfigEntry mutePlayerOnDirect = new BooleanConfigEntry(true);

@ConfigField
private BooleanConfigEntry cameraSoundListener = new BooleanConfigEntry(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ public ModServerConnection(@NotNull BaseVoiceClient voiceClient,
@Override
public void sendPacket(@NotNull Packet<?> packet, boolean checkUdpConnection) {
if (!connection.isConnected()) return;
//#if MC>=12004
//$$ if (Minecraft.getInstance().getConnection() == null) return;
//#endif

if (checkUdpConnection && !voiceClient.getUdpClientManager().isConnected())
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public void init() {
));
addEntry(createStereoToMonoSources());
addEntry(createPanning());
addEntry(createToggleEntry(
McTextComponent.translatable("gui.plasmovoice.advanced.mute_player_on_direct"),
McTextComponent.translatable("gui.plasmovoice.advanced.mute_player_on_direct.tooltip"),
config.getAdvanced().getMutePlayerOnDirect()
));

addEntry(new CategoryEntry(McTextComponent.translatable("gui.plasmovoice.advanced.exponential_volume")));
addEntry(createToggleEntry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

//#if MC>=12002
//$$ import com.mojang.authlib.minecraft.MinecraftSessionService;
//$$ import net.minecraft.client.renderer.texture.TextureManager;
//$$
//$$ import org.spongepowered.asm.mixin.Unique;
//$$ import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -18,6 +17,11 @@
//$$
//$$ import java.nio.file.Path;
//$$ import java.util.concurrent.Executor;

//#if MC<12104
//$$ import net.minecraft.client.renderer.texture.TextureManager;
//#endif

//#else
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -26,7 +30,19 @@
@Mixin(SkinManager.class)
public abstract class MixinSkinManager implements SkinManagerAccessor {

//#if MC>=12002
//#if MC>=12104
//$$ @Unique
//$$ private static File SKINS_DIRECTORY;
//$$ @Inject(at = @At("RETURN"), method = "<init>")
//$$ private void init(Path path, MinecraftSessionService minecraftSessionService, Executor executor, CallbackInfo ci) {
//$$ SKINS_DIRECTORY = path.toFile();
//$$ }
//$$ @NotNull
//$$ @Override
//$$ public File getSkinsCacheFolder() {
//$$ return SKINS_DIRECTORY;
//$$ }
//#elseif MC>=12002
//$$ @Unique
//$$ private static File SKINS_DIRECTORY;
//$$ @Inject(at = @At("RETURN"), method = "<init>")
Expand Down
13 changes: 12 additions & 1 deletion client/src/main/kotlin/gg/essential/universal/DummyPack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import gg.essential.universal.shader.MCShader
import net.minecraft.resources.ResourceLocation
import net.minecraft.server.packs.PackResources
import net.minecraft.server.packs.PackType
import net.minecraft.server.packs.metadata.MetadataSectionSerializer
import net.minecraft.server.packs.resources.IoSupplier
import java.io.InputStream

//#if MC>=12005
//$$ import net.minecraft.server.packs.PackLocationInfo
//#endif

//#if MC>=12104
//$$ import net.minecraft.server.packs.metadata.MetadataSectionType
//#else
import net.minecraft.server.packs.metadata.MetadataSectionSerializer
//#endif

/**
* A dummy resource pack for use in [MCShader], since the [Resource] constructor
* on 1.19.3+ requires a [PackResources] instead of a String name.
Expand Down Expand Up @@ -46,9 +51,15 @@ object DummyPack : PackResources {
throw UnsupportedOperationException()
}

//#if MC>=12104
//$$ override fun <T : Any?> getMetadataSection(metadataSectionType: MetadataSectionType<T>): T? {
//$$ throw UnsupportedOperationException()
//$$ }
//#else
override fun <T : Any?> getMetadataSection(metadataSectionSerializer: MetadataSectionSerializer<T>): T? {
throw UnsupportedOperationException()
}
//#endif

//#if MC>=12005
//$$ override fun location(): PackLocationInfo {
Expand Down
Loading
Loading