Skip to content
Open
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
35 changes: 35 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

> **Disclaimer**
>
> We generally only accept PRs with small bug fixes or translations.
> In case you want to implement a new feature, please check if it's possible to do so using the [API](https://modrepo.de/minecraft/voicechat/api/overview).
> If the feature you want to implement is not possible with the API, please visit the `#api-development` channel in our Discord!
> If you deem a feature to be important enough to be included in the base mod/plugin, please get in contact with us first!


<!-- Please fill out this form before opening a pull request -->


<!-- If the following check boxes are not checked, this PR will be rejected -->

- [ ] I confirm that I have implemented the changes in this PR myself.
- [ ] I agree to transfer all rights for the contributed work to the owner of this repository.
- [ ] I confirm I did **not** use any AI tools for this PR.
- [ ] I confirm that I tested all changes made in this PR thoroughly.
- [ ] I confirm that I followed the same code style as the rest of the repository.
- [ ] I confirm that there are no breaking protocol changes in this PR.


### Description

<!-- A short, high-level summary of the change and why it was made -->


### Related issue(s) / PR(s)

<!-- Links to related issues and/or pull requests if applicable -->


### Screenshots / Recordings

<!-- Screenshots or recordings of the changes made in this PR (Only if applicable) -->
12 changes: 8 additions & 4 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ plugins {
id 'maven-publish'
}

sourceCompatibility = JavaLanguageVersion.of(8)
targetCompatibility = JavaLanguageVersion.of(8)
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

archivesBaseName = archives_base_name
base {
archivesName = archives_base_name
}
version = version
group = maven_group

Expand Down Expand Up @@ -44,7 +48,7 @@ publishing {
publications {
voiceChatApi(MavenPublication) {
artifactId archives_base_name
artifact(jar.archivePath) {
artifact(jar) {
builtBy build
classifier null
}
Expand Down
9 changes: 9 additions & 0 deletions api/src/main/java/de/maxhenkel/voicechat/api/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ public interface Entity {
*/
Position getPosition();

/**
* @return the current eye position of the entity
*/
Position getEyePosition();

/**
* @return the level of the entity
*/
ServerLevel getLevel();
}
48 changes: 48 additions & 0 deletions api/src/main/java/de/maxhenkel/voicechat/api/MinecraftServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.maxhenkel.voicechat.api;

import java.util.List;
import java.util.UUID;

public interface MinecraftServer {

/**
* @return the actual server object
*/
Object getMinecraftServer();

/**
* @return the ip of the server, without port
*/
String getIp();

/**
* @return the port of the server
*/
int getPort();

/**
* @param playerUUID the UUID of the player
* @return the corresponding {@link ServerPlayer} object
*/
ServerPlayer getPlayer(UUID playerUUID);

/**
* @return a list of all players in the server
*/
List<ServerPlayer> getPlayers();

/**
* @return whether the server is a dedicated server
*/
boolean isDedicated();

/**
* @return whether the server has 'online-mode' set to true
*/
boolean usesAuthentication();

/**
* @return the permission level at which a user is considered an operator
*/
int getOperatorUserPermissionLevel();
}
5 changes: 0 additions & 5 deletions api/src/main/java/de/maxhenkel/voicechat/api/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@

public interface Player extends Entity {

/**
* @return the actual player object
*/
Object getPlayer();

}
7 changes: 7 additions & 0 deletions api/src/main/java/de/maxhenkel/voicechat/api/ServerLevel.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package de.maxhenkel.voicechat.api;

import java.util.List;

public interface ServerLevel {

/**
* @return the actual level object
*/
Object getServerLevel();

/**
* @return the list of players in the level
*/
List<ServerPlayer> players();

}
22 changes: 20 additions & 2 deletions api/src/main/java/de/maxhenkel/voicechat/api/ServerPlayer.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
package de.maxhenkel.voicechat.api;

import javax.annotation.Nullable;

public interface ServerPlayer extends Player {

/**
* @return the level of the player
* @return the player's name
*/
ServerLevel getServerLevel();
String getName();

/**
* @return the player the user's camera is using
*/
@Nullable
ServerPlayer getCameraPlayer();

/**
* @return whether the player is in spectator mode
*/
boolean isSpectator();

/**
* @param operatorUserPermissionLevel the permission level to check against
* @return whether the player has the permissions
*/
boolean hasPermissions(int operatorUserPermissionLevel);
}
34 changes: 0 additions & 34 deletions api/src/main/java/de/maxhenkel/voicechat/api/VoicechatApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,40 +63,6 @@ public interface VoicechatApi {
*/
AudioConverter getAudioConverter();

/**
* Creates an entity object from an actual entity.
*
* @param entity the entity implementation of your mod/plugin loader
* @return the entity object
*/
Entity fromEntity(Object entity);

/**
* Creates a level object from an actual level.
*
* @param serverLevel the level implementation of your mod/plugin loader
* @return the level
*/
ServerLevel fromServerLevel(Object serverLevel);

/**
* Creates a player object from an actual player.
*
* @param serverPlayer the player implementation of your mod/plugin loader
* @return the player
*/
ServerPlayer fromServerPlayer(Object serverPlayer);

/**
* Creates a new position object.
*
* @param x the X position
* @param y the Y position
* @param z the Z position
* @return the position with the provided coordinates
*/
Position createPosition(double x, double y, double z);

/**
* Don't forget to register your category with {@link VoicechatServerApi#registerVolumeCategory(VolumeCategory)} or {@link VoicechatClientApi#registerClientVolumeCategory(VolumeCategory)}
*
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'com.gradleup.shadow' version "${shadow_version}" apply false
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}" apply false
id 'de.maxhenkel.cursegradle' version "${cursegradle_version}" apply false
id 'com.modrinth.minotaur' version "${minotaur_version}" apply false
id 'mod-update' version "${mod_update_version}" apply false
id 'fabric-loom' version "${fabric_loom_version}" apply false
Expand All @@ -17,7 +17,7 @@ tasks.register('01-publishQuilt', GradleBuild) {
tasks.register('02-publishForge') {
group = 'voicechat'
doLast {
runGradleTasks(['common:clean', 'common-client:clean', 'forge:clean'], ['forge:curseforge', 'forge:modrinth', 'forge:modUpdate'])
runGradleTask('uploadMod', false, file('forge'))
}
}

Expand Down
2 changes: 1 addition & 1 deletion common-client/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod_loader=fabric

included_projects=:api, :common
included_projects=:api, :core, :common

enable_curseforge_upload=false
enable_modrinth_upload=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.Lists;
import de.maxhenkel.voicechat.VoicechatClient;
import de.maxhenkel.voicechat.gui.widgets.ListScreenListBase;
import de.maxhenkel.voicechat.intercompatibility.MinecraftCompatibilityManager;
import de.maxhenkel.voicechat.plugins.impl.VolumeCategoryImpl;
import de.maxhenkel.voicechat.voice.client.ClientManager;
import de.maxhenkel.voicechat.voice.common.PlayerState;
Expand Down Expand Up @@ -79,7 +80,7 @@ public void updateFilter() {
if (volumeEntry instanceof PlayerVolumeEntry playerVolumeEntry) {
return playerVolumeEntry.getState() == null || !playerVolumeEntry.getState().getName().toLowerCase(Locale.ROOT).contains(filter);
} else if (volumeEntry instanceof CategoryVolumeEntry categoryVolumeEntry) {
return !categoryVolumeEntry.getCategory().getSearchName().toLowerCase(Locale.ROOT).contains(filter);
return !MinecraftCompatibilityManager.getCategorySearchName(categoryVolumeEntry.getCategory()).toLowerCase(Locale.ROOT).contains(filter);
}
return true;
});
Expand All @@ -105,7 +106,7 @@ private String volumeEntryToSearchString(VolumeEntry entry) {
if (entry instanceof PlayerVolumeEntry playerVolumeEntry) {
return playerVolumeEntry.getState() == null ? "" : playerVolumeEntry.getState().getName();
} else if (entry instanceof CategoryVolumeEntry categoryVolumeEntry) {
return categoryVolumeEntry.getCategory().getSearchName();
return MinecraftCompatibilityManager.getCategorySearchName(categoryVolumeEntry.getCategory());
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package de.maxhenkel.voicechat.gui.volume;

import de.maxhenkel.voicechat.VoicechatClient;
import de.maxhenkel.voicechat.intercompatibility.MinecraftCompatibilityManager;
import de.maxhenkel.voicechat.plugins.impl.VolumeCategoryImpl;
import de.maxhenkel.voicechat.voice.client.ClientManager;
import de.maxhenkel.voicechat.voice.client.ClientVoicechat;
import de.maxhenkel.voicechat.voice.common.AudioUtils;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

public class CategoryVolumeEntry extends VolumeEntry {
Expand All @@ -27,10 +27,10 @@ public VolumeCategoryImpl getCategory() {
@Override
public void renderElement(GuiGraphics guiGraphics, int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean hovered, float delta, int skinX, int skinY, int textX, int textY) {
guiGraphics.blit(texture, skinX, skinY, SKIN_SIZE, SKIN_SIZE, 16, 16, 16, 16, 16, 16);
renderScrollingString(guiGraphics, category.getDisplayName(), top, left, width, height, PLAYER_NAME_COLOR);
renderScrollingString(guiGraphics, MinecraftCompatibilityManager.getCategoryDisplayName(category), top, left, width, height, PLAYER_NAME_COLOR);
if (hovered && category.getDescription() != null) {
screen.postRender(() -> {
guiGraphics.renderTooltip(minecraft.font, category.getDisplayDescription(), mouseX, mouseY);
guiGraphics.renderTooltip(minecraft.font, MinecraftCompatibilityManager.getCategoryDisplayDescription(category), mouseX, mouseY);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public VoiceThread(Consumer<MicrophoneException> onMicError) throws SpeakerExcep

SoundManager soundManager;
if (client == null) {
soundManager = new SoundManager();
soundManager = SoundManager.create();
ownSoundManager = soundManager;
} else {
soundManager = client.getSoundManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import de.maxhenkel.voicechat.voice.client.ClientManager;
import de.maxhenkel.voicechat.voice.client.ClientVoicechat;
import de.maxhenkel.voicechat.voice.client.ClientVoicechatConnection;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
import de.maxhenkel.voicechat.api.MinecraftServer;

public class ClientCrossSideManager extends CrossSideManager {

Expand Down Expand Up @@ -36,7 +35,7 @@ public boolean useNatives() {

@Override
public boolean shouldRunVoiceChatServer(MinecraftServer server) {
return server instanceof DedicatedServer || VoicechatClient.CLIENT_CONFIG == null || VoicechatClient.CLIENT_CONFIG.runLocalServer.get();
return server.isDedicated() || VoicechatClient.CLIENT_CONFIG == null || VoicechatClient.CLIENT_CONFIG.runLocalServer.get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.resources.ResourceLocation;

public abstract class ClientServerNetManager extends NetManager {

Expand All @@ -13,7 +14,7 @@ public static void sendToServer(Packet<?> packet) {
packet.toBytes(buffer);
ClientPacketListener connection = Minecraft.getInstance().getConnection();
if (connection != null && connection.getLevel() != null) {
connection.send(new ServerboundCustomPayloadPacket(packet.getIdentifier(), buffer));
connection.send(new ServerboundCustomPayloadPacket(new ResourceLocation(packet.getIdentifier().key(), packet.getIdentifier().value()), buffer));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import de.maxhenkel.voicechat.voice.client.ClientUtils;
import de.maxhenkel.voicechat.voice.common.LocationSoundPacket;
import de.maxhenkel.voicechat.voice.common.SoundPacket;
import net.minecraft.world.phys.Vec3;

import java.util.UUID;

Expand All @@ -22,7 +21,7 @@ public ClientLocationalAudioChannelImpl(UUID id, Position position) {

@Override
protected SoundPacket<?> createSoundPacket(short[] rawAudio) {
return new LocationSoundPacket(id, id, rawAudio, new Vec3(position.getX(), position.getY(), position.getZ()), distance, category);
return new LocationSoundPacket(id, id, rawAudio, position, distance, category);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

import de.maxhenkel.voicechat.api.Position;
import de.maxhenkel.voicechat.api.events.OpenALSoundEvent;
import de.maxhenkel.voicechat.plugins.impl.PositionImpl;

import javax.annotation.Nullable;
import java.util.UUID;

public class OpenALSoundEventImpl extends ClientEventImpl implements OpenALSoundEvent, OpenALSoundEvent.Pre, OpenALSoundEvent.Post {

@Nullable
protected PositionImpl position;
protected Position position;
@Nullable
protected UUID channelId;
@Nullable
protected String category;
protected int source;

public OpenALSoundEventImpl(@Nullable UUID channelId, @Nullable PositionImpl position, @Nullable String category, int source) {
public OpenALSoundEventImpl(@Nullable UUID channelId, @Nullable Position position, @Nullable String category, int source) {
this.channelId = channelId;
this.position = position;
this.category = category;
Expand Down
Loading