Simple Voice Radio

Simple Voice Radio

684k Downloads

gradle build issues

Salpertio opened this issue ยท 1 comments

commented

vscode
gradle installed
java installed.
using powershell to start commands.

cd Desktop/SimpleRadio-1.20.1
./gradlew build > fail

SimpleRadio-1.20.1\fabric\src\main\java\com\codinglitch\simpleradio\compat\InteractionCompat.java:35: error: incompatible types: Entity cannot be converted to UUID
if (setCooldown(channel.owner, location.level)) {
^

hmmm...
./gradlew :fabric:build --info > fail

SimpleRadio-1.20.1\fabric\src\main\java\com\codinglitch\simpleradio\compat\InteractionCompat.java:35: error: incompatible types: Entity cannot be converted to UUID
if (setCooldown(channel.owner, location.level)) {
^

original InteractionCompat.java

package com.codinglitch.simpleradio.compat;

import com.codinglitch.simpleradio.CommonSimpleRadio;
import com.codinglitch.simpleradio.core.central.WorldlyPosition;
import com.codinglitch.simpleradio.radio.CommonRadioPlugin;
import com.codinglitch.simpleradio.radio.RadioSpeaker;
import com.codinglitch.simpleradio.radio.RadioSource;
import de.maxhenkel.vcinteraction.AudioUtils;
import de.maxhenkel.vcinteraction.VoicechatInteraction;
import de.maxhenkel.voicechat.api.VoicechatConnection;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;

import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public class InteractionCompat {
    private static ConcurrentHashMap<UUID, Long> cooldowns = new ConcurrentHashMap<>();

    public static void onData(RadioSpeaker channel, RadioSource source, short[] decodedData) {
        UUID sourceOwner = source.getRealOwner();
        VoicechatConnection connection = CommonRadioPlugin.serverApi.getConnectionOf(sourceOwner);

        if (AudioUtils.calculateAudioLevel(decodedData) < VoicechatInteraction.SERVER_CONFIG.minActivationThreshold.get().doubleValue()) {
            return;
        }

        if (connection == null) {
            if (channel.location == null) return;

            WorldlyPosition location = channel.location;
            location.level.getServer().execute(() -> {
                if (setCooldown(channel.owner.getUUID(), location.level)) {
                    BlockState state = location.level.getBlockState(location.blockPos());

                    location.level.gameEvent(VoicechatInteraction.VOICE_GAME_EVENT, location.blockPos(), GameEvent.Context.of(state));
                }
            });
        } else {
            if (!(connection.getPlayer().getPlayer() instanceof ServerPlayer player)) {
                CommonSimpleRadio.warn("Received microphone packets from non-player");
                return;
            }

            if (setCooldown(player.getUUID(), player.level())) {
                player.gameEvent(VoicechatInteraction.VOICE_GAME_EVENT);
            }
        }
    }

    private static boolean setCooldown(UUID uuid, Level level) {
        Long lastTimestamp = cooldowns.get(uuid);
        long currentTime = level.getGameTime();
        if (lastTimestamp == null || currentTime - lastTimestamp > 20L) {
            cooldowns.put(uuid, currentTime);
            return true;
        }
        return false;
    }
}

addition

package com.codinglitch.simpleradio.compat;

import com.codinglitch.simpleradio.CommonSimpleRadio;
import com.codinglitch.simpleradio.core.central.WorldlyPosition;
import com.codinglitch.simpleradio.radio.CommonRadioPlugin;
import com.codinglitch.simpleradio.radio.RadioSpeaker;
import com.codinglitch.simpleradio.radio.RadioSource;
import de.maxhenkel.vcinteraction.AudioUtils;
import de.maxhenkel.vcinteraction.VoicechatInteraction;
import de.maxhenkel.voicechat.api.VoicechatConnection;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;

import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public class InteractionCompat {
    private static ConcurrentHashMap<UUID, Long> cooldowns = new ConcurrentHashMap<>();

    public static void onData(RadioSpeaker channel, RadioSource source, short[] decodedData) {
        UUID sourceOwner = source.getRealOwner();
        VoicechatConnection connection = CommonRadioPlugin.serverApi.getConnectionOf(sourceOwner);

        if (AudioUtils.calculateAudioLevel(decodedData) < VoicechatInteraction.SERVER_CONFIG.minActivationThreshold.get().doubleValue()) {
            return;
        }

        if (connection == null) {
            if (channel.location == null) return;

            WorldlyPosition location = channel.location;
            location.level.getServer().execute(() -> {
                // Ensure channel.owner is a UUID
                if (setCooldown(channel.owner.getUUID(), location.level)) {
                    BlockState state = location.level.getBlockState(location.blockPos());
                    location.level.gameEvent(VoicechatInteraction.VOICE_GAME_EVENT, location.blockPos(), GameEvent.Context.of(state));
                }
            });
        } else {
            if (!(connection.getPlayer().getPlayer() instanceof ServerPlayer player)) {
                CommonSimpleRadio.warn("Received microphone packets from non-player");
                return;
            }

            if (setCooldown(player.getUUID(), player.level())) {
                player.gameEvent(VoicechatInteraction.VOICE_GAME_EVENT);
            }
        }
    }

    private static boolean setCooldown(UUID uuid, Level level) {
        Long lastTimestamp = cooldowns.get(uuid);
        long currentTime = level.getGameTime();
        if (lastTimestamp == null || currentTime - lastTimestamp > 20L) {
            cooldowns.put(uuid, currentTime);
            return true;
        }
        return false;
    }
}

then it spits out missing dependencies

  • What went wrong:
    Execution failed for task ':common:compileJava'.

Could not resolve all files for configuration ':common:compileClasspath'.
Could not find org.spongepowered:mixin:0.8.5.
Required by:
project :common
Could not find io.github.llamalad7:mixinextras-common:0.3.6.
Required by:
project :common
Could not find org.valkyrienskies.core:api:1.1.0.
Required by:
project :common
Could not find net.minecraftforge:mergetool:1.2.3.
Required by:
project :common
Could not find com.google.code.findbugs:jsr305:3.0.1.
Required by:
project :common
Could not find de.maxhenkel.voicechat:voicechat-api:2.4.11.
Required by:
project :common
Could not find com.codinglitch.lexiconfig:lexiconfig-api:1.3.11.
Required by:
project :common
Could not find com.codinglitch.vibrativevoice:vibrativevoice-api:1.0.0.
Required by:
project :common
Could not resolve net.minecraft:joined:1.20.1.
Required by:
project :common
> Could not resolve all files for configuration ':common:mergetool'.
> Could not find net.minecraftforge:mergetool:1.2.3.
Required by:
project :common

          do i need to find then add these to a lib folder in the root folder of the project?
commented

added the Mixin dependency: implementation "org.spongepowered:mixin:0.8.5"

added the Mixin Extras dependency: implementation "io.github.llamalad7:mixinextras-fabric:0.4.1"

to fabric/gradle

added - to common/gradle
compileOnly annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1") // Update to the correct version

the creator had a similar issue. unsure what caused it.

run --refresh-dependencies just to be safe (i never know when that actually works)