Skip to content

Commit

Permalink
v2.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum committed Jun 13, 2024
2 parents c7bbe3f + 7fcd65a commit 65ceb40
Show file tree
Hide file tree
Showing 40 changed files with 141 additions and 103 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
1.20.3
1.20.4
1.20.5
1.20.6
1.21
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand All @@ -75,6 +77,8 @@ jobs:
1.20.3
1.20.4
1.20.5
1.20.6
1.21
modrinth-unfeature-mode: 'subset'
modrinth-id: 1bZhdhsH
Expand Down
10 changes: 9 additions & 1 deletion api/common/src/main/java/su/plo/voice/api/util/AudioUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ public static short[] floatsToShorts(float[] floats) {
short[] shorts = new short[floats.length];

for(int i = 0; i < floats.length; i++) {
shorts[i] = Float.valueOf(floats[i]).shortValue();
shorts[i] = Float.valueOf(
Math.min( // Clamp to prevent overdrive causing clipping (https://github.com/remjey/mumble/commit/f16b47c81aceaf0c8704b355d9316bf685cb3704)
Short.MAX_VALUE,
Math.max(
Short.MIN_VALUE,
floats[i]
)
)
).shortValue();
}

return shorts;
Expand Down
1 change: 1 addition & 0 deletions client/1.21-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
21 changes: 1 addition & 20 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ plasmoCrowdin {

val shadowCommon by configurations.creating

fun uStatsVersion() = rootProject.libs.versions.ustats.map {
val minecraftVersion = when (platform.mcVersion) {
12001, 12002, 12004, 12006 -> "1.20"
else -> platform.mcVersionStr
}

"${minecraftVersion}-${platform.loaderStr}:$it"
}.get()

repositories {
maven("https://repo.essential.gg/repository/maven-public")
}
Expand All @@ -71,6 +62,7 @@ dependencies {
12002 -> "0.89.1+1.20.2"
12004 -> "0.97.0+1.20.4"
12006 -> "0.97.8+1.20.6"
12100 -> "0.100.1+1.21"
else -> throw GradleException("Unsupported platform $platform")
}

Expand All @@ -89,15 +81,6 @@ dependencies {
}
}

"su.plo.ustats:${uStatsVersion()}".also {
modApi(it) {
isTransitive = false
}
shadowCommon(it) {
isTransitive = false
}
}

val includedProjects = listOf(
":api:common",
":api:client",
Expand Down Expand Up @@ -154,8 +137,6 @@ tasks {
relocate("su.plo.crowdin", "su.plo.voice.libs.crowdin")
relocate("gg.essential.universal", "su.plo.voice.universal")

relocate("su.plo.ustats", "su.plo.voice.ustats")

dependencies {
exclude(dependency("net.java.dev.jna:jna"))
exclude(dependency("org.slf4j:slf4j-api"))
Expand Down
5 changes: 3 additions & 2 deletions client/changelog.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Fixed stacktrace spam on bad packets [#397](https://github.com/plasmoapp/plasmo-voice/issues/397)
- 1.20.5, 1.20.6 support
- Fixed distorted RNNoise output during mono capture [#400](https://github.com/plasmoapp/plasmo-voice/pull/400)
- Fixed "Failed to open device" spam in logs
- 1.21 support
4 changes: 4 additions & 0 deletions client/root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ group = "$mavenGroup.client-root"

preprocess {

val fabric12100 = createNode("1.21-fabric", 12100, "official")

val fabric12006 = createNode("1.20.6-fabric", 12006, "official")
val fabric12004 = createNode("1.20.4-fabric", 12004, "official")

Expand All @@ -22,6 +24,8 @@ preprocess {
val forge11902 = createNode("1.19.2-forge", 11902, "official")
val fabric11902 = createNode("1.19.2-fabric", 11902, "official")

fabric12100.link(fabric12006)

fabric12006.link(fabric12004)

fabric12004.link(fabric12002)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
public interface GuiWidget {

//#if MC>=12005
//$$ ResourceLocation MENU_LIST_BACKGROUND_LOCATION = new ResourceLocation("textures/gui/menu_list_background.png");
//$$ ResourceLocation INWORLD_MENU_LIST_BACKGROUND_LOCATION = new ResourceLocation("textures/gui/inworld_menu_list_background.png");
//$$ ResourceLocation MENU_LIST_BACKGROUND_LOCATION = ResourceLocation.tryParse("textures/gui/menu_list_background.png");
//$$ ResourceLocation INWORLD_MENU_LIST_BACKGROUND_LOCATION = ResourceLocation.tryParse("textures/gui/inworld_menu_list_background.png");
//$$
//$$ ResourceLocation FOOTER_SEPARATOR_LOCATION = new ResourceLocation("textures/gui/footer_separator.png");
//$$ ResourceLocation INWORLD_FOOTER_SEPARATOR_LOCATION = new ResourceLocation("textures/gui/inworld_footer_separator.png");
//$$ ResourceLocation FOOTER_SEPARATOR_LOCATION = ResourceLocation.tryParse("textures/gui/footer_separator.png");
//$$ ResourceLocation INWORLD_FOOTER_SEPARATOR_LOCATION = ResourceLocation.tryParse("textures/gui/inworld_footer_separator.png");
//#else
ResourceLocation BACKGROUND_LOCATION = new ResourceLocation("textures/gui/options_background.png");
ResourceLocation BACKGROUND_LOCATION = ResourceLocation.tryParse("textures/gui/options_background.png");
//#endif

int getWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,11 @@ public static int drawStringLight(UMatrixStack stack, MinecraftTextComponent tex
boolean displayMode = seeThrough;
//#endif

//#if MC>=12100
//$$ MultiBufferSource.BufferSource irendertypebuffer$impl = UMinecraft.getMinecraft().renderBuffers().bufferSource();
//#else
MultiBufferSource.BufferSource irendertypebuffer$impl = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
//#endif
UMinecraft.getFontRenderer().drawInBatch(
formattedText,
(float) x,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static synchronized void loadSkin(@NotNull UUID playerId,
if (skinLocation != null) return;

if (fallback != null) {
ResourceLocation fallbackIdentifier = new ResourceLocation(
ResourceLocation fallbackIdentifier = ResourceLocation.tryBuild(
"plasmovoice",
"skins/" + Hashing.sha1().hashUnencodedChars(nick.toLowerCase())
);
Expand Down Expand Up @@ -72,7 +72,7 @@ public static synchronized void loadSkin(@NotNull UUID playerId,
);
} else {
String hash = Hashing.sha1().hashUnencodedChars(textures.get(MinecraftProfileTexture.Type.SKIN).getHash()).toString();
ResourceLocation identifier = new ResourceLocation("skins/" + hash);
ResourceLocation identifier = ResourceLocation.tryParse("skins/" + hash);
skins.put(profile.getName(), identifier);
}
//#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class ResourceCache {
public ResourceLocation getLocation(@NotNull String resourceLocation) {
return locationByString.computeIfAbsent(
resourceLocation,
ResourceLocation::new
ResourceLocation::tryParse
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ public int hashCode() {

//#if MC>=12005
//$$ private Holder.Reference<GameEvent> parseGameEvent(@NotNull String gameEventName) {
//$$ return BuiltInRegistries.GAME_EVENT.getHolder(new ResourceLocation(gameEventName))
//$$ return BuiltInRegistries.GAME_EVENT.getHolder(ResourceLocation.tryParse(gameEventName))
//$$ .orElseThrow(() -> new IllegalArgumentException("Invalid game event"));
//$$ }
//#else
private GameEvent parseGameEvent(@NotNull String gameEventName) {
//#if MC>=11903
return BuiltInRegistries.GAME_EVENT.get(new ResourceLocation(gameEventName));
return BuiltInRegistries.GAME_EVENT.get(ResourceLocation.tryParse(gameEventName));
//#else
//$$ return Registry.GAME_EVENT.get(new ResourceLocation(gameEventName));
//$$ return Registry.GAME_EVENT.get(ResourceLocation.tryParse(gameEventName));
//#endif
}
//#endif
Expand Down
11 changes: 10 additions & 1 deletion client/src/main/java/su/plo/voice/client/ModVoiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,16 @@ public void onInitializeClient() {
ClientLifecycleEvents.CLIENT_STOPPING.register((minecraft) -> onShutdown());
HudRenderCallback.EVENT.register(hudRenderer::render);
WorldRenderEvents.LAST.register(
(context) -> levelRenderer.render(context.world(), context.matrixStack(), context.camera(), context.tickDelta())
(context) -> levelRenderer.render(
context.world(),
context.matrixStack(),
context.camera(),
//#if MC>=12100
//$$ context.tickCounter().getRealtimeDeltaTicks()
//#else
context.tickDelta()
//#endif
)
);
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> onServerDisconnect());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Optional<ClientActivation> getParentActivation() {

String icon = VoiceIconUtil.INSTANCE.getIcon(
serverActivation.getIcon(),
new ResourceLocation("plasmovoice:textures/addons/activations/" + serverActivation.getName())
ResourceLocation.tryParse("plasmovoice:textures/addons/activations/" + serverActivation.getName())
);

ClientActivation activation = register(new VoiceClientActivation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public final class VoiceDeviceManager implements DeviceManager {

private ScheduledFuture<?> job;

private String failedOutputDevices = "";
private String failedInputDevices = "";

@Override
public void add(@NotNull AudioDevice device) {
checkNotNull(device, "device cannot be null");
Expand Down Expand Up @@ -248,11 +251,16 @@ private void tickJob() throws DeviceException {
.orElseThrow(() -> new IllegalStateException("OpenAL input factory is not registered"));;

if (outputDevices.isEmpty()) {
if (outputFactory.getDeviceNames().size() > 0) {
List<String> deviceNames = outputFactory.getDeviceNames();
String deviceNamesString = String.join("\n", deviceNames);

if (deviceNames.size() > 0 && !deviceNamesString.equals(failedOutputDevices)) {
try {
add(voiceClient.getDeviceManager().openOutputDevice(null, Params.EMPTY));
failedOutputDevices = "";
} catch (Exception e) {
LOGGER.error("Failed to open primary OpenAL output device", e);
failedOutputDevices = deviceNamesString;
}

if (!voiceClient.getAudioCapture().isActive() && !inputDevices.isEmpty()) {
Expand All @@ -271,11 +279,16 @@ private void tickJob() throws DeviceException {
}

if (inputDevices.isEmpty()) {
if (inputFactory.getDeviceNames().size() > 0 && !config.getVoice().getDisableInputDevice().value()) {
List<String> deviceNames = inputFactory.getDeviceNames();
String deviceNamesString = String.join("\n", deviceNames);

if (deviceNames.size() > 0 && !deviceNamesString.equals(failedInputDevices) && !config.getVoice().getDisableInputDevice().value()) {
try {
replace(null, voiceClient.getDeviceManager().openInputDevice(null, Params.EMPTY));
failedInputDevices = "";
} catch (Exception e) {
LOGGER.error("Failed to open input device", e);
failedInputDevices = deviceNamesString;
}

if (!voiceClient.getAudioCapture().isActive()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void clear() {

String icon = VoiceIconUtil.INSTANCE.getIcon(
line.getIcon(),
new ResourceLocation("plasmovoice:textures/addons/source_lines/" + line.getName())
ResourceLocation.tryParse("plasmovoice:textures/addons/source_lines/" + line.getName())
);

DoubleConfigEntry volumeEntry = config.getVoice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void init() {
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/microphone_menu.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/microphone_menu.png"),
true
);

Expand Down Expand Up @@ -142,7 +142,7 @@ public void init() {
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/microphone_menu_disabled.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/microphone_menu_disabled.png"),
true
);

Expand Down Expand Up @@ -181,7 +181,7 @@ public void init() {
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/speaker_menu.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/speaker_menu.png"),
true
);

Expand All @@ -208,7 +208,7 @@ public void init() {
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/speaker_menu_disabled.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/speaker_menu_disabled.png"),
true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,38 +78,38 @@ public void init() {

navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.devices"),
new ResourceLocation("plasmovoice:textures/icons/tabs/devices.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/devices.png"),
new DevicesTabWidget(this, voiceClient, config, testController)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.volume"),
new ResourceLocation("plasmovoice:textures/icons/tabs/volume.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/volume.png"),
new VolumeTabWidget(this, voiceClient, config)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.activation"),
new ResourceLocation("plasmovoice:textures/icons/tabs/activation.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/activation.png"),
new ActivationTabWidget(this, voiceClient, config)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.overlay"),
new ResourceLocation("plasmovoice:textures/icons/tabs/overlay.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/overlay.png"),
new OverlayTabWidget(this, voiceClient, config)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.advanced"),
new ResourceLocation("plasmovoice:textures/icons/tabs/advanced.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/advanced.png"),
new AdvancedTabWidget(this, voiceClient, config)
);
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.hotkeys"),
new ResourceLocation("plasmovoice:textures/icons/tabs/hotkeys.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/hotkeys.png"),
new HotKeysTabWidget(this, voiceClient, config)
);
if (voiceClient.getAddonConfigs().size() > 0) {
navigation.addTab(
MinecraftTextComponent.translatable("gui.plasmovoice.addons"),
new ResourceLocation("plasmovoice:textures/icons/tabs/addons.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/tabs/addons.png"),
new AddonsTabWidget(this, voiceClient, config)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public ActivationToggleStateEntry(@NotNull MinecraftTextComponent text,
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/microphone_menu.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/microphone_menu.png"),
true
);
IconButton enableToggleState = new IconButton(
Expand All @@ -258,7 +258,7 @@ public ActivationToggleStateEntry(@NotNull MinecraftTextComponent text,
).withStyle(MinecraftTextStyle.GRAY)
));
},
new ResourceLocation("plasmovoice:textures/icons/microphone_menu_disabled.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/microphone_menu_disabled.png"),
true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void createOverlaySource(@NotNull ClientSourceLine sourceLine) {
widget,
configEntry,
null,
new ResourceLocation(sourceLine.getIcon()),
ResourceLocation.tryParse(sourceLine.getIcon()),
null
));
} else {
Expand Down Expand Up @@ -142,7 +142,7 @@ private void createOverlaySource(@NotNull ClientSourceLine sourceLine) {
widget,
configEntry,
null,
new ResourceLocation(sourceLine.getIcon()),
ResourceLocation.tryParse(sourceLine.getIcon()),
(button, element) -> element.setText(OVERLAY_DISPLAYS.get(0))
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public OptionEntry(@NotNull MinecraftTextComponent text,
20,
this::onReset,
Button.NO_TOOLTIP,
new ResourceLocation("plasmovoice:textures/icons/reset.png"),
ResourceLocation.tryParse("plasmovoice:textures/icons/reset.png"),
true
);

Expand Down
Loading

0 comments on commit 65ceb40

Please sign in to comment.