Начинающий
- Статус
- Оффлайн
- Регистрация
- 1 Авг 2024
- Сообщения
- 72
- Реакции
- 0
- Выберите загрузчик игры
- Прочие моды
Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:
- бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
- маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
- приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
- обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.
Спасибо!
ss:
она чуток не оч но можно дописать
Код:
package alpha.night.modules.impl.misc;
import com.google.common.eventbus.Subscribe;
import alpha.night.events.AttackEvent;
import alpha.night.modules.api.Category;
import alpha.night.modules.api.Module;
import alpha.night.modules.api.ModuleRegister;
import alpha.night.modules.settings.impl.BooleanSetting;
import alpha.night.modules.settings.impl.ModeSetting;
import alpha.night.modules.settings.impl.SliderSetting;
import alpha.night.utils.math.MathUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector3d;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.FloatControl;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import static java.lang.Math.*;
import static net.minecraft.util.math.MathHelper.wrapDegrees;
@ModuleRegister(name = "Звук", category = Category.Misc)
public class ClientTune extends Module {
public ModeSetting mode = new ModeSetting("Тип", "Обычный", "Обычный", "Поп", "Прикольные", "Лол", "Хефи", "Виндовс", "Дроблет", "Пузырьки");
public SliderSetting volume = new SliderSetting("Громкость", 60.0f, 0.0f, 100.0f, 1.0f);
public BooleanSetting other = new BooleanSetting("Гуи", true);
public BooleanSetting hitSound = new BooleanSetting("HitSound", false);
private final ModeSetting sound = new ModeSetting("Звук", "bell", "bell", "metallic", "bubble", "crime", "uwu", "moan", "custom").setVisible(() -> hitSound.get());
private final ModeSetting customSound = new ModeSetting("Кастомный звук", "none", getCustomSoundFiles()).setVisible(() -> hitSound.get() && sound.is("custom"));
SliderSetting volumeHitSound = new SliderSetting("Громкость HitSound", 35.0f, 5.0f, 100.0f, 5.0f).setVisible(() -> hitSound.get());
private static final File CUSTOM_SOUND_DIR = new File("C:\\skuff\\customsounds");
public ClientTune() {
addSettings(mode, volume, other, hitSound, sound, customSound, volumeHitSound);
initCustomSoundDir();
}
private void initCustomSoundDir() {
try {
if (!CUSTOM_SOUND_DIR.exists()) {
CUSTOM_SOUND_DIR.mkdirs();
System.out.println("Создана папка для кастомных звуков: " + CUSTOM_SOUND_DIR.getAbsolutePath());
} else {
System.out.println("Папка для кастомных звуков уже существует: " + CUSTOM_SOUND_DIR.getAbsolutePath());
}
} catch (SecurityException e) {
System.err.println("Ошибка создания папки для кастомных звуков: " + e.getMessage());
}
}
private String[] getCustomSoundFiles() {
try {
File[] files = CUSTOM_SOUND_DIR.listFiles((dir, name) -> name.toLowerCase().endsWith(".wav"));
if (files == null || files.length == 0) {
System.out.println("В папке " + CUSTOM_SOUND_DIR.getAbsolutePath() + " нет .wav файлов");
return new String[]{"none"};
}
String[] fileNames = new String[files.length];
for (int i = 0; i < files.length; i++) {
fileNames[i] = files[i].getName().replace(".wav", "");
}
System.out.println("Найдены кастомные звуки: " + String.join(", ", fileNames));
return fileNames;
} catch (Exception e) {
System.err.println("Ошибка при чтении кастомных звуков: " + e.getMessage());
return new String[]{"none"};
}
}
public void updateCustomSoundList() {
try {
String[] newModes = getCustomSoundFiles();
customSound.setModes(newModes);
if (!customSound.is("none") && !new File(CUSTOM_SOUND_DIR, customSound.get() + ".wav").exists()) {
System.out.println("Выбранный кастомный звук больше не существует, сброс на 'none'");
customSound.set("none");
}
} catch (Exception e) {
System.err.println("Ошибка при обновлении списка кастомных звуков: " + e.getMessage());
}
}
public String getFileName(boolean state) {
switch (mode.get()) {
case "Пузырьки" -> {
return state ? "enableBubbles" : "disableBubbles";
}
case "Лол" -> {
return state ? "enable2" : "disable2";
}
case "Поп" -> {
return state ? "popenable" : "popdisable";
}
case "Хефи" -> {
return state ? "heavyenable" : "heavydisable";
}
case "Виндовс" -> {
return state ? "winenable" : "windisable";
}
case "Дроблет" -> {
return state ? "dropletenable" : "dropletdisable";
}
case "Прикольные" -> {
return state ? "enablevl" : "disablevl";
}
case "Обычный" -> {
return state ? "slideenable" : "slidedisable";
}
}
return "";
}
@Subscribe
public void onPacket(AttackEvent e) {
if (mc.player == null || mc.world == null) {
System.out.println("AttackEvent: Игрок или мир недоступны");
return;
}
if (hitSound.get()) {
System.out.println("AttackEvent: Событие атаки сработало, пытаемся воспроизвести звук: " + sound.get());
updateCustomSoundList(); // Обновляем список перед воспроизведением
playSound(e.entity);
}
}
public void playSound(Entity e) {
try {
System.out.println("Попытка воспроизведения звука: " + (sound.is("custom") ? "custom: " + customSound.get() : sound.get()));
Clip clip = AudioSystem.getClip();
AudioInputStream audioInputStream;
if (sound.is("custom") && !customSound.is("none")) {
File soundFile = new File(CUSTOM_SOUND_DIR, customSound.get() + ".wav");
if (!soundFile.exists()) {
System.err.println("Кастомный звуковой файл не найден: " + soundFile.getAbsolutePath());
return;
}
if (!soundFile.canRead()) {
System.err.println("Нет прав на чтение файла: " + soundFile.getAbsolutePath());
return;
}
System.out.println("Загрузка кастомного звука: " + soundFile.getAbsolutePath());
try {
audioInputStream = AudioSystem.getAudioInputStream(soundFile);
} catch (Exception ex) {
System.err.println("Ошибка формата кастомного звука: " + ex.getMessage());
return;
}
} else {
String resourceSound = sound.is("moan")
? "alphanight/sounds/moan" + MathUtil.randomInt(1, 4) + ".wav"
: "alphanight/sounds/" + sound.get() + ".wav";
System.out.println("Загрузка встроенного звука: " + resourceSound);
ResourceLocation soundLocation = new ResourceLocation(resourceSound);
InputStream is = mc.getResourceManager().getResource(soundLocation).getInputStream();
if (is == null) {
System.err.println("Ресурс звука не найден: " + resourceSound);
return;
}
BufferedInputStream bis = new BufferedInputStream(is);
audioInputStream = AudioSystem.getAudioInputStream(bis);
}
if (audioInputStream == null) {
System.err.println("AudioInputStream не создан!");
return;
}
clip.open(audioInputStream);
FloatControl floatControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
float volumeValue = volumeHitSound.get().floatValue();
System.out.println("Установка громкости: " + volumeValue);
floatControl.setValue(volumeValue > 0 ? (volumeValue / 100.0f) * 6.0f - 6.0f : -80.0f); // Упрощённая регулировка громкости
if (e != null) {
FloatControl balance = (FloatControl) clip.getControl(FloatControl.Type.BALANCE);
Vector3d vec = e.getPositionVec().subtract(Minecraft.getInstance().player.getPositionVec());
double yaw = wrapDegrees(toDegrees(atan2(vec.z, vec.x)) - 90);
double delta = wrapDegrees(yaw - mc.player.rotationYaw);
if (abs(delta) > 180) delta -= signum(delta) * 360;
try {
balance.setValue((float) delta / 180);
} catch (Exception ex) {
System.err.println("Ошибка установки баланса: " + ex.getMessage());
}
}
clip.start();
System.out.println("Звук воспроизведён: " + (sound.is("custom") ? customSound.get() : sound.get()));
audioInputStream.close();
} catch (Exception exception) {
System.err.println("Ошибка воспроизведения звука: " + exception.getMessage());
exception.printStackTrace();
}
}
}
она чуток не оч но можно дописать