Вопрос NameProtectFriend

Начинающий
Статус
Онлайн
Регистрация
8 Мар 2024
Сообщения
598
Реакции[?]
2
Поинты[?]
2K

Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:

  • бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
  • маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
  • приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
  • обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.

Спасибо!

крч пытался перенести код с 2.0 на 3.1 и перенёс но вот хз почему не скрывает имя друзей ,помогите
NameProtect.java:
package im.expensive.functions.impl.misc;

import com.google.common.eventbus.Subscribe;
import im.expensive.Expensive;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.StringSetting;
import im.expensive.utils.client.ClientUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.ITextComponent;

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

private final StringSetting name = new StringSetting(
"Заменяемое Имя",
"Shadow",
"Укажите текст для замены вашего игрового ника"
    );
private final BooleanSetting friends = new BooleanSetting("Друзья", true);

public NameProtect() {
addSettings(name, friends);
}

@Subscribe
    private void onUpdate(EventUpdate e) {
}

public static String getReplaced(String input) {
Expensive expensiveInstance = Expensive.getInstance();
if (expensiveInstance != null && expensiveInstance.getFunctionRegistry().getNameProtect().isState()) {
return input.replace(Minecraft.getInstance().session.getUsername(), expensiveInstance.getFunctionRegistry().getNameProtect().name.get());
}
return input;
}

public ITextComponent patchFriendTextComponent(ITextComponent text, String name) {
if (this.friends.get() && Expensive.getInstance().getFunctionRegistry().getNameProtect().isState()) {
return ClientUtil.replace(text, name, this.name.getDescription());
}
return text;
}
}
ClientUtil.java:
package im.expensive.utils.client;

import im.expensive.utils.render.ColorUtils;
import lombok.experimental.UtilityClass;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.network.play.server.SUpdateBossInfoPacket;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import net.minecraft.util.text.Color;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.Style;

import javax.sound.sampled.*;

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

@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("expensive/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));
}
public static StringTextComponent gradient(String message, int first, int end) {

StringTextComponent text = new StringTextComponent("");
for (int i = 0; i < message.length(); i++) {
text.append(new StringTextComponent(String.valueOf(message.charAt(i))).setStyle(Style.EMPTY.setColor(new Color(ColorUtils.interpolate(first, end, (float) i / message.length())))));
}

return text;

}

public static ITextComponent replace(ITextComponent original, String find, String replaceWith) {
if (original == null || find == null || replaceWith == null) {
return original;
}

String originalText = original.getString();
String replacedText = originalText.replace(find, replaceWith);
return new StringTextComponent(replacedText);
}
}
 
Последнее редактирование:
Сверху Снизу