Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Вопрос Фикс Client Sounds Exp 3.1

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
3 Июн 2024
Сообщения
19
Реакции
0
Не слышно звуков при включение/выключения модуля. Функция была включена. Чё может быть. Код не менялся
 
Не слышно звуков при включение/выключения модуля. Функция была включена. Чё может быть. Код не менялся
я нашел способ фикса, хз актуально или нет то для будуших пастеров. для начала ты можешь с папки ассетс\майнкрафт (срц) скопиировать папку своего клиента и вставить ее в папку ассетс (та в которой майнкрафт и реалмс) потом у тебя в папке ассетс (папка с клиентом НЕ СРЦ) должно быть только skins. потом билди софт, потом достать ассеты с папки с тлаунчера вставь из нее все кроме скинс и вставь в ассеты (папка с клиентом) после делай версию или что там хочешь, запускай пасту и кайфуй от звуков. если после такого их нету то нужно сидеть над clientutil.java у кого руки не из одного места можете взять мои коды с моей пасты (noad) и переписать под свой клиент. сделано на базе exp 3.1
ClientUtil:
Expand Collapse Copy
package wtf.lose.utils.client;

import lombok.experimental.UtilityClass;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.network.play.server.SUpdateBossInfoPacket;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import net.minecraft.util.math.vector.Vector3d;
import org.apache.commons.lang3.SystemUtils;

import javax.sound.sampled.*;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.UUID;

import static java.lang.Math.*;
import static java.lang.Math.signum;
import static net.minecraft.util.math.MathHelper.wrapDegrees;

@UtilityClass
public class ClientUtil implements IMinecraft {

    private static Clip currentClip = null;
    private static boolean pvpMode;
    private static UUID uuid;

    public void updateBossInfo(SUpdateBossInfoPacket packet) {
        if (packet.getOperation() == SUpdateBossInfoPacket.Operation.ADD) {
            if (StringUtils.stripControlCodes(packet.getName().getString()).toLowerCase().contains("pvp")) {
                pvpMode = true;
                uuid = packet.getUniqueId();
            }
        } else if (packet.getOperation() == SUpdateBossInfoPacket.Operation.REMOVE) {
            if (packet.getUniqueId().equals(uuid))
                pvpMode = false;
        }
    }
    public boolean isConnectedToServer(String ip) {
        return mc.getCurrentServerData() != null && mc.getCurrentServerData().serverIP != null && mc.getCurrentServerData().serverIP.contains(ip);
    }
    public boolean isPvP() {
        return pvpMode;
    }

    public void playSound(String sound, float value, boolean nonstop) {
        if (currentClip != null && currentClip.isRunning()) {
            currentClip.stop();
        }
        try {
            currentClip = AudioSystem.getClip();
            InputStream is = mc.getResourceManager().getResource(new ResourceLocation("lose/sounds/" + sound + ".wav")).getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is);
            AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(bis);
            if (audioInputStream == null) {
                System.out.println("Sound not found!");
                return;
            }

            currentClip.open(audioInputStream);
            currentClip.start();
            FloatControl floatControl = (FloatControl) currentClip.getControl(FloatControl.Type.MASTER_GAIN);
            float min = floatControl.getMinimum();
            float max = floatControl.getMaximum();
            float volumeInDecibels = (float) (min * (1 - (value / 100.0)) + max * (value / 100.0));
            floatControl.setValue(volumeInDecibels);
            if (nonstop) {
                currentClip.addLineListener(event -> {
                    if (event.getType() == LineEvent.Type.STOP) {
                        currentClip.setFramePosition(0);
                        currentClip.start();
                    }
                });
            }
        } catch (Exception exception) {
            // Обработка исключения
            exception.printStackTrace();
        }
    }

    public void stopSound() {
        if (currentClip != null) {
            currentClip.stop();
            currentClip.close();
            currentClip = null;
        }
    }

    public int calc(int value) {
        MainWindow rs = mc.getMainWindow();
        return (int) (value * rs.getGuiScaleFactor() / 2);
    }

    public Vec2i getMouse(int mouseX, int mouseY) {
        return new Vec2i((int) (mouseX * Minecraft.getInstance().getMainWindow().getGuiScaleFactor() / 2), (int) (mouseY * Minecraft.getInstance().getMainWindow().getGuiScaleFactor() / 2));
    }
}
ClientSounds:
Expand Collapse Copy
package wtf.lose.functions.impl.misc;

import wtf.lose.functions.api.Category;
import wtf.lose.functions.api.Function;
import wtf.lose.functions.api.FunctionRegister;
import wtf.lose.functions.settings.impl.ModeSetting;
import wtf.lose.functions.settings.impl.SliderSetting;

@FunctionRegister(name = "ClientSounds", type = Category.Misc)
public class ClientSounds extends Function {

    public ModeSetting mode = new ModeSetting("Тип", "Мод 1", "Мод 1", "Мод 2", "Мод 3");
    public SliderSetting volume = new SliderSetting("Громкость", 70.0f, 0.0f, 100.0f, 1.0f);

    public ClientSounds() {
        addSettings(mode, volume);
    }


    public String getFileName(boolean state) {
        switch (mode.get()) {
            case "Мод 1" -> {
                return state ? "enable" : "disable".toString();
            }
            case "Мод 2" -> {
                return state ? "enable1" : "disable1";
            }
            case "Мод 3" -> {
                return state ? "enable2" : "disable2";
            }
        }
        return "";
    }
}
Function:
Expand Collapse Copy
package wtf.lose.functions.api;

import wtf.lose.Lose;
import wtf.lose.functions.impl.misc.ClientSounds;
import wtf.lose.functions.settings.Setting;
import wtf.lose.ui.display.impl.NotifRenderer;
import wtf.lose.utils.client.ClientUtil;
import wtf.lose.utils.client.IMinecraft;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.StringTextComponent;
import ru.hogoshi.Animation;
import ru.hogoshi.util.Easings;
import wtf.lose.utils.text.GradientUtil;

import java.util.List;

@FieldDefaults(level = AccessLevel.PRIVATE)
@Getter
public abstract class Function implements IMinecraft {

    final String name;
    final Category category;

    boolean state;
    @Setter
    int bind;
    final List<Setting<?>> settings = new ObjectArrayList<>();

    final Animation animation = new Animation();

    public Function() {
        this.name = getClass().getAnnotation(FunctionRegister.class).name();
        this.category = getClass().getAnnotation(FunctionRegister.class).type();
        this.bind = getClass().getAnnotation(FunctionRegister.class).key();
    }

    public Function(String name) {
        this.name = name;
        this.category = Category.Combat;
    }

    public void addSettings(Setting<?>... settings) {
        this.settings.addAll(List.of(settings));
    }

    public void onEnable() {
        animation.animate(1, 0.25f, Easings.CIRC_OUT);
        Lose.getInstance().getEventBus().register(this);
    }

    public void onDisable() {
        animation.animate(0, 0.25f, Easings.CIRC_OUT);
        Lose.getInstance().getEventBus().unregister(this);
    }

    public final void toggle() {
        setState(!state, false);
    }

    public final void setState(boolean newState, boolean config) {
        if (state == newState) {
            return;
        }

        state = newState;


        try {
            if (state) {
                onEnable();
            } else {
                onDisable();
            }
            if (!config) {
                FunctionRegistry functionRegistry = Lose.getInstance().getFunctionRegistry();
                ClientSounds clientSounds = functionRegistry.getClientSounds();

                if (clientSounds != null && clientSounds.isState()) {
                    String fileName = clientSounds.getFileName(state);
                    float volume = clientSounds.volume.get();
                    ClientUtil.playSound(fileName, volume, false);
                }
            }
            StringTextComponent text = GradientUtil.gradient("Функция");
            String var10000 = this.name;
            NotifRenderer.addNotification(var10000 + " была " + (this.state ? "включена" : "выключена"), text, 3);
        } catch (Exception e) {
            handleException(state ? "onEnable" : "onDisable", e);
        }

    }

    private void handleException(String methodName, Exception e) {
        if (mc.player != null) {
            print("[" + name + "] Произошла ошибка в методе " + TextFormatting.RED + methodName + TextFormatting.WHITE
                    + "() Предоставьте это сообщение разработчику: " + TextFormatting.GRAY + e.getMessage());
            e.printStackTrace();
        } else {
            System.out.println("[" + name + " Error" + methodName + "() Message: " + e.getMessage());
            e.printStackTrace();
        }
    }
}
 
я нашел способ фикса, хз актуально или нет то для будуших пастеров. для начала ты можешь с папки ассетс\майнкрафт (срц) скопиировать папку своего клиента и вставить ее в папку ассетс (та в которой майнкрафт и реалмс) потом у тебя в папке ассетс (папка с клиентом НЕ СРЦ) должно быть только skins. потом билди софт, потом достать ассеты с папки с тлаунчера вставь из нее все кроме скинс и вставь в ассеты (папка с клиентом) после делай версию или что там хочешь, запускай пасту и кайфуй от звуков. если после такого их нету то нужно сидеть над clientutil.java у кого руки не из одного места можете взять мои коды с моей пасты (noad) и переписать под свой клиент. сделано на базе exp 3.1
ClientUtil:
Expand Collapse Copy
package wtf.lose.utils.client;

import lombok.experimental.UtilityClass;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.network.play.server.SUpdateBossInfoPacket;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import net.minecraft.util.math.vector.Vector3d;
import org.apache.commons.lang3.SystemUtils;

import javax.sound.sampled.*;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.UUID;

import static java.lang.Math.*;
import static java.lang.Math.signum;
import static net.minecraft.util.math.MathHelper.wrapDegrees;

@UtilityClass
public class ClientUtil implements IMinecraft {

    private static Clip currentClip = null;
    private static boolean pvpMode;
    private static UUID uuid;

    public void updateBossInfo(SUpdateBossInfoPacket packet) {
        if (packet.getOperation() == SUpdateBossInfoPacket.Operation.ADD) {
            if (StringUtils.stripControlCodes(packet.getName().getString()).toLowerCase().contains("pvp")) {
                pvpMode = true;
                uuid = packet.getUniqueId();
            }
        } else if (packet.getOperation() == SUpdateBossInfoPacket.Operation.REMOVE) {
            if (packet.getUniqueId().equals(uuid))
                pvpMode = false;
        }
    }
    public boolean isConnectedToServer(String ip) {
        return mc.getCurrentServerData() != null && mc.getCurrentServerData().serverIP != null && mc.getCurrentServerData().serverIP.contains(ip);
    }
    public boolean isPvP() {
        return pvpMode;
    }

    public void playSound(String sound, float value, boolean nonstop) {
        if (currentClip != null && currentClip.isRunning()) {
            currentClip.stop();
        }
        try {
            currentClip = AudioSystem.getClip();
            InputStream is = mc.getResourceManager().getResource(new ResourceLocation("lose/sounds/" + sound + ".wav")).getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is);
            AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(bis);
            if (audioInputStream == null) {
                System.out.println("Sound not found!");
                return;
            }

            currentClip.open(audioInputStream);
            currentClip.start();
            FloatControl floatControl = (FloatControl) currentClip.getControl(FloatControl.Type.MASTER_GAIN);
            float min = floatControl.getMinimum();
            float max = floatControl.getMaximum();
            float volumeInDecibels = (float) (min * (1 - (value / 100.0)) + max * (value / 100.0));
            floatControl.setValue(volumeInDecibels);
            if (nonstop) {
                currentClip.addLineListener(event -> {
                    if (event.getType() == LineEvent.Type.STOP) {
                        currentClip.setFramePosition(0);
                        currentClip.start();
                    }
                });
            }
        } catch (Exception exception) {
            // Обработка исключения
            exception.printStackTrace();
        }
    }

    public void stopSound() {
        if (currentClip != null) {
            currentClip.stop();
            currentClip.close();
            currentClip = null;
        }
    }

    public int calc(int value) {
        MainWindow rs = mc.getMainWindow();
        return (int) (value * rs.getGuiScaleFactor() / 2);
    }

    public Vec2i getMouse(int mouseX, int mouseY) {
        return new Vec2i((int) (mouseX * Minecraft.getInstance().getMainWindow().getGuiScaleFactor() / 2), (int) (mouseY * Minecraft.getInstance().getMainWindow().getGuiScaleFactor() / 2));
    }
}
ClientSounds:
Expand Collapse Copy
package wtf.lose.functions.impl.misc;

import wtf.lose.functions.api.Category;
import wtf.lose.functions.api.Function;
import wtf.lose.functions.api.FunctionRegister;
import wtf.lose.functions.settings.impl.ModeSetting;
import wtf.lose.functions.settings.impl.SliderSetting;

@FunctionRegister(name = "ClientSounds", type = Category.Misc)
public class ClientSounds extends Function {

    public ModeSetting mode = new ModeSetting("Тип", "Мод 1", "Мод 1", "Мод 2", "Мод 3");
    public SliderSetting volume = new SliderSetting("Громкость", 70.0f, 0.0f, 100.0f, 1.0f);

    public ClientSounds() {
        addSettings(mode, volume);
    }


    public String getFileName(boolean state) {
        switch (mode.get()) {
            case "Мод 1" -> {
                return state ? "enable" : "disable".toString();
            }
            case "Мод 2" -> {
                return state ? "enable1" : "disable1";
            }
            case "Мод 3" -> {
                return state ? "enable2" : "disable2";
            }
        }
        return "";
    }
}
Function:
Expand Collapse Copy
package wtf.lose.functions.api;

import wtf.lose.Lose;
import wtf.lose.functions.impl.misc.ClientSounds;
import wtf.lose.functions.settings.Setting;
import wtf.lose.ui.display.impl.NotifRenderer;
import wtf.lose.utils.client.ClientUtil;
import wtf.lose.utils.client.IMinecraft;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.StringTextComponent;
import ru.hogoshi.Animation;
import ru.hogoshi.util.Easings;
import wtf.lose.utils.text.GradientUtil;

import java.util.List;

@FieldDefaults(level = AccessLevel.PRIVATE)
@Getter
public abstract class Function implements IMinecraft {

    final String name;
    final Category category;

    boolean state;
    @Setter
    int bind;
    final List<Setting<?>> settings = new ObjectArrayList<>();

    final Animation animation = new Animation();

    public Function() {
        this.name = getClass().getAnnotation(FunctionRegister.class).name();
        this.category = getClass().getAnnotation(FunctionRegister.class).type();
        this.bind = getClass().getAnnotation(FunctionRegister.class).key();
    }

    public Function(String name) {
        this.name = name;
        this.category = Category.Combat;
    }

    public void addSettings(Setting<?>... settings) {
        this.settings.addAll(List.of(settings));
    }

    public void onEnable() {
        animation.animate(1, 0.25f, Easings.CIRC_OUT);
        Lose.getInstance().getEventBus().register(this);
    }

    public void onDisable() {
        animation.animate(0, 0.25f, Easings.CIRC_OUT);
        Lose.getInstance().getEventBus().unregister(this);
    }

    public final void toggle() {
        setState(!state, false);
    }

    public final void setState(boolean newState, boolean config) {
        if (state == newState) {
            return;
        }

        state = newState;


        try {
            if (state) {
                onEnable();
            } else {
                onDisable();
            }
            if (!config) {
                FunctionRegistry functionRegistry = Lose.getInstance().getFunctionRegistry();
                ClientSounds clientSounds = functionRegistry.getClientSounds();

                if (clientSounds != null && clientSounds.isState()) {
                    String fileName = clientSounds.getFileName(state);
                    float volume = clientSounds.volume.get();
                    ClientUtil.playSound(fileName, volume, false);
                }
            }
            StringTextComponent text = GradientUtil.gradient("Функция");
            String var10000 = this.name;
            NotifRenderer.addNotification(var10000 + " была " + (this.state ? "включена" : "выключена"), text, 3);
        } catch (Exception e) {
            handleException(state ? "onEnable" : "onDisable", e);
        }

    }

    private void handleException(String methodName, Exception e) {
        if (mc.player != null) {
            print("[" + name + "] Произошла ошибка в методе " + TextFormatting.RED + methodName + TextFormatting.WHITE
                    + "() Предоставьте это сообщение разработчику: " + TextFormatting.GRAY + e.getMessage());
            e.printStackTrace();
        } else {
            System.out.println("[" + name + " Error" + methodName + "() Message: " + e.getMessage());
            e.printStackTrace();
        }
    }
}
спасибо за ответ!!!!!!
 
Назад
Сверху Снизу