package wtf.sqwezz.utils; import TickEvent.Phase;...

Создано: 16 мая 2025 г.

Отвечено с использованием O3 от Chat01

Вопрос

package wtf.sqwezz.utils;

import TickEvent.Phase;
import com.jagrosh.discordipc.IPCClient;
import com.jagrosh.discordipc.IPCListener;
import com.jagrosh.discordipc.entities.RichPresence;
import com.jagrosh.discordipc.exceptions.NoDiscordClientException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import wtf.sqwezz.functions.api.FunctionRegister;

import java.time.OffsetDateTime;

public class DiscordRPC {
private static final Minecraft mc = Minecraft.getInstance();
public static IPCClient client;
private static boolean running = false;
private static long lastUpdateTime = 0;
private static final String APPLICATION_ID = "1372950028167155866";
private static final long UPDATE_INTERVAL = 15000;

text
// Инициализация static { startRPC(); } public static void startRPC() { if (running) return; try { client = new IPCClient(APPLICATION_ID); client.setListener(new IPCListener() { @Override public void onReady(IPCClient client) { running = true; System.out.println("[DiscordRPC] Подключено к Discord"); updatePresence(); } @Override public void onDisconnect(IPCClient client, Throwable t) { running = false; System.out.println("[DiscordRPC] Отключено от Discord"); } }); client.connect(); } catch (NoDiscordClientException e) { System.out.println("[DiscordRPC] Discord не запущен"); } catch (Exception e) { System.err.println("[DiscordRPC] Ошибка подключения:"); e.printStackTrace(); } } private static void updatePresence() { if (!running || System.currentTimeMillis() - lastUpdateTime < UPDATE_INTERVAL) return; try { String playerName = mc.player != null ? mc.player.getName().getString() : "Не в игре"; ServerData server = mc.getCurrentServerData(); String gameMode = mc.isSingleplayer() ? "Одиночная игра" : server != null ? "Сервер: " + server.serverIP : "Меню"; RichPresence presence = new RichPresence.Builder() .setDetails(playerName) .setState(gameMode) .setStartTimestamp(OffsetDateTime.now()) .setLargeImage("main", "Minecraft 1.12.2") .setSmallImage(mc.isSingleplayer() ? "single" : "multi", mc.isSingleplayer() ? "Одиночная" : "Мультиплеер") .build(); client.sendRichPresence(presence); lastUpdateTime = System.currentTimeMillis(); } catch (Exception e) { System.err.println("[DiscordRPC] Ошибка обновления:"); e.printStackTrace(); } } @SubscribeEvent public static void onClientTick(TickEvent.ClientTickEvent event) { Object TickEvent = null; if (event.phase == Phase.END) { updatePresence(); } }

}
вырежи
try {
String playerName = mc.player != null ? mc.player.getName().getString() : "Не в игре";
ServerData server = mc.getCurrentServerData();
String gameMode = mc.isSingleplayer() ? "Одиночная игра" :
server != null ? "Сервер: " + server.serverIP : "Меню";

text
RichPresence presence = new RichPresence.Builder() .setDetails(playerName) .setState(gameMode) .setStartTimestamp(OffsetDateTime.now()) .setLargeImage("main", "Minecraft 1.12.2") .setSmallImage(mc.isSingleplayer() ? "single" : "multi", mc.isSingleplayer() ? "Одиночная" : "Мультиплеер") .build();

Мысль

Interpreting the request

The user posted a block of Java code and used the word "вырежи," which means "cut out" or "remove" in Russian. It seems they're asking me to remove that section of code from the rest. The context suggests they might want this block in the updatePresence method to be extracted or deleted from the file DiscordRPC.java.

I'll proceed with this understanding.

Interpreting the user's request

The user wrote "вырежи," which means "cut out" in Russian, followed by a Java code snippet. It seems they want to remove or extract this specific block of code from the file, possibly from the updatePresence method. Since "вырежи" implies they want it cut out, they may either want it deleted or shown separately. Given that the canvas tool is disabled, I'll provide the modified version of the code directly in the response, excluding that block.

Clarifying the user's request

The user wrote "вырежи" (cut out) alongside a Java code snippet, which indicates they want that block extracted. It seems they don't need the full file modified but just the snippet removed. I'll simplify the update without complicating it further.

I'll present the requested code snippet on its own and show the updated updatePresence() method, reflecting the removal of only the block they flagged. Given the context, I don’t need to modify the file more.

Thought for 45 seconds

Ответ

Вот класс DiscordRPC с полностью вырезанным блоком построения RichPresence — как вы просили.
(Внутри updatePresence() я оставил «заглушку»‑комментарий и обновление lastUpdateTime, чтобы метод по‑прежнему ограничивал частоту вызовов. Если потребуется другая логика, вставьте её вместо комментария.)

java
package wtf.sqwezz.utils; import TickEvent.Phase; import com.jagrosh.discordipc.IPCClient; import com.jagrosh.discordipc.IPCListener; import com.jagrosh.discordipc.entities.RichPresence; import com.jagrosh.discordipc.exceptions.NoDiscordClientException; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ServerData; import wtf.sqwezz.functions.api.FunctionRegister; import java.time.OffsetDateTime; public class DiscordRPC { private static final Minecraft mc = Minecraft.getInstance(); public static IPCClient client; private static boolean running = false; private static long lastUpdateTime = 0; private static final String APPLICATION_ID = "1372950028167155866"; private static final long UPDATE_INTERVAL = 15000; // Инициализация static { startRPC(); } public static void startRPC() { if (running) return; try { client = new IPCClient(APPLICATION_ID); client.setListener(new IPCListener() { @Override public void onReady(IPCClient client) { running = true; System.out.println("[DiscordRPC] Подключено к Discord"); updatePresence(); } @Override public void onDisconnect(IPCClient client, Throwable t) { running = false; System.out.println("[DiscordRPC] Отключено от Discord"); } }); client.connect(); } catch (NoDiscordClientException e) { System.out.println("[DiscordRPC] Discord не запущен"); } catch (Exception e) { System.err.println("[DiscordRPC] Ошибка подключения:"); e.printStackTrace(); } } /** * Обновление RPC‑статуса. * Блок построения RichPresence удалён по запросу («вырезан»). */ private static void updatePresence() { if (!running || System.currentTimeMillis() - lastUpdateTime < UPDATE_INTERVAL) return; // TODO: добавьте здесь свою логику формирования RichPresence lastUpdateTime = System.currentTimeMillis(); } @SubscribeEvent public static void onClientTick(TickEvent.ClientTickEvent event) { if (event.phase == Phase.END) { updatePresence(); } } }

Вопрос

сделай так же но только на подобие вот этого
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package dev.akven.utils;

import com.jagrosh.discordipc.IPCClient;
import com.jagrosh.discordipc.IPCListener;
import com.jagrosh.discordipc.entities.Packet;
import com.jagrosh.discordipc.entities.RichPresence;
import java.time.OffsetDateTime;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;

class DiscordRPC1 implements IPCListener { DiscordRPC1() {
}

text
public void onPacketReceived(IPCClient client, Packet packet) { super.onPacketReceived(client, packet); } public void onReady(IPCClient client) { Minecraft var10000 = DiscordRPC.mc; PlayerEntity player = Minecraft.player; String playerName = null; if (player != null) { playerName = player.getName().getString(); } RichPresence.Builder builder = new RichPresence.Builder(); builder.setDetails("★ User: » UID: ").setStartTimestamp(OffsetDateTime.now()).setLargeImage("https://postimg.su/image/RKq697js/Safeimagekit.gif", "TESTING FUNCTIONS").setState("★ Build: 0.0.1 BETA"); client.sendRichPresence(builder.build()); }

}

Мысль

Interpreting User's Request

The user seems to want a similar modification applied to their DiscordRPC class, specifically mimicking the style of the provided example. They probably want to replace the current builder logic with one resembling what’s in the code snippet, possibly integrating an anonymous inner class for IPCListener, similar to the DiscordRPC$1 class.

I'll first think about how to match the style and avoid overcomplicating the implementation while keeping it aligned with the user’s example. Let's go step-by-step!

Clarifying User's Request

The user wants to replicate the style of the code snippet they provided. It seems like they're asking to integrate a builder inside the onReady method, similar to the example, which sets the RichPresence once upon connection. Since they asked to remove the previous updatePresence block, we should create a new version where we remove the periodic update and instead directly set the presence once using the builder. I'll focus on replicating the style with the changes they’ve requested.

Thought for 23 seconds

Ответ

Ниже приведён облегчённый класс DiscordRPC, построенный «в стиле» вашего примера: состояние Discord-RPC формируется сразу в onReady() анонимного IPCListener и отправляется один раз при подключении. Периодического обновления (updatePresence) больше нет — всё, как в decompiler-файле, что вы показали.

java
// // Source code written по мотивам примера из FernFlower // package wtf.sqwezz.utils; import com.jagrosh.discordipc.IPCClient; import com.jagrosh.discordipc.IPCListener; import com.jagrosh.discordipc.entities.Packet; import com.jagrosh.discordipc.entities.RichPresence; import com.jagrosh.discordipc.exceptions.NoDiscordClientException; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import java.time.OffsetDateTime; public class DiscordRPC { // ──────────────────────────── Константы ──────────────────────────── private static final Minecraft MC = Minecraft.getInstance(); private static final String APPLICATION_ID = "1372950028167155866"; // ──────────────────────────── Поля ──────────────────────────────── private static IPCClient client; private static boolean running; // ──────────────────────────── Статический блок ──────────────────── static { startRPC(); } // автозапуск // ──────────────────────────── RPC-инициализация ─────────────────── public static void startRPC() { if (running) return; try { client = new IPCClient(APPLICATION_ID); client.setListener(new IPCListener() { // ——— пакеты можем игнорировать, но оставим override для полноты @Override public void onPacketReceived(IPCClient client, Packet packet) { /* no-op */ } // ——— успешно подключились к Discord @Override public void onReady(IPCClient client) { running = true; // Берём имя игрока, если он в мире PlayerEntity player = MC.player; String playerName = player != null ? player.getName().getString() : "Unknown"; // Строим presence «как в образце» RichPresence presence = new RichPresence.Builder() .setDetails("★ User: " + playerName + " » UID: " + MC.getSession().getPlayerID()) .setState("★ Build: 0.0.1 BETA") .setStartTimestamp(OffsetDateTime.now()) .setLargeImage("https://postimg.su/image/RKq697js/Safeimagekit.gif", "TESTING FUNCTIONS") .build(); client.sendRichPresence(presence); System.out.println("[DiscordRPC] Connected — presence sent"); } // ——— отключение @Override public void onDisconnect(IPCClient client, Throwable t) { running = false; System.out.println("[DiscordRPC] Disconnected from Discord"); } }); client.connect(); } catch (NoDiscordClientException e) { System.out.println("[DiscordRPC] Discord не запущен"); } catch (Exception e) { System.err.println("[DiscordRPC] Ошибка подключения:"); e.printStackTrace(); } } }

Теперь класс делает ровно то, что показано в вашем примере: устанавливает Rich Presence один раз при успешном подключении к Discord IPC, без периодических обновлений. Если нужно вернуть таймер и динамическое изменение статуса — дайте знать!

Вопрос

image.pngimage.png

//
// Source code written по мотивам примера из FernFlower
//

package wtf.sqwezz.utils;

import com.jagrosh.discordipc.IPCClient;
import com.jagrosh.discordipc.IPCListener;
import com.jagrosh.discordipc.entities.Packet;
import com.jagrosh.discordipc.entities.RichPresence;
import com.jagrosh.discordipc.exceptions.NoDiscordClientException;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;

import java.time.OffsetDateTime;

public class DiscordRPC {

text
// ──────────────────────────── Константы ──────────────────────────── private static final Minecraft MC = Minecraft.getInstance(); private static final String APPLICATION_ID = "1372950028167155866"; // ──────────────────────────── Поля ──────────────────────────────── private static IPCClient client; private static boolean running; // ──────────────────────────── Статический блок ──────────────────── static { startRPC(); } // автозапуск // ──────────────────────────── RPC-инициализация ─────────────────── public static void startRPC() { if (running) return; try { client = new IPCClient(APPLICATION_ID); client.setListener(new IPCListener() { // ——— пакеты можем игнорировать, но оставим override для полноты @Override public void onPacketReceived(IPCClient client, Packet packet) { /* no-op */ } // ——— успешно подключились к Discord @Override public void onReady(IPCClient client) { running = true; // Берём имя игрока, если он в мире PlayerEntity player = MC.player; String playerName = player != null ? player.getName().getString() : "Unknown"; // Строим presence &laquo;как в образце&raquo; RichPresence presence = new RichPresence.Builder() .setDetails("★ User: " + " 74IQ; UID: 1488" + MC.getSession().getPlayerID()) .setState("★ Build: BETA") .setStartTimestamp(OffsetDateTime.now()) .setLargeImage("http://postimg.su/image/gk6EgWj8/ава.png", "★ dev: 74IQ ★") .build(); client.sendRichPresence(presence); System.out.println("[DiscordRPC] Connected — presence sent"); } // ——— отключение @Override public void onDisconnect(IPCClient client, Throwable t) { running = false; System.out.println("[DiscordRPC] Disconnected from Discord"); } }); client.connect(); } catch (NoDiscordClientException e) { System.out.println("[DiscordRPC] Discord не запущен"); } catch (Exception e) { System.err.println("[DiscordRPC] Ошибка подключения:"); e.printStackTrace(); } }

}
убери в UID

Мысль

Clarifying "убери в UID" request

The user asked to "убери в UID", which is likely short for "убери UID," meaning "remove UID". They seem to be asking to remove the "UID" portion, particularly the player ID (e.g., MC.getSession().getPlayerID()) from the setDetails string.

It seems they want to keep the player name but remove the player ID from the string. So, I'll modify the code to ensure that the UID isn't included in the details.

Simplifying the code for UID removal

The user wants to remove the "UID" part from the code. They’re likely asking to replace the static "74IQ; UID: 1488" with just the player name.

I’ll modify the code to remove the session ID by using the playerName variable like this:

java
.setDetails("★ User: " + playerName) `` Thought for 22 seconds

Ответ

Ниже тот же класс, но строка UID полностью убрана из Rich Presence – теперь в details выводится только ник игрока (или «Unknown», если игрок ещё не загружен).

java
// // Source code written по мотивам примера из FernFlower // package wtf.sqwezz.utils; import com.jagrosh.discordipc.IPCClient; import com.jagrosh.discordipc.IPCListener; import com.jagrosh.discordipc.entities.Packet; import com.jagrosh.discordipc.entities.RichPresence; import com.jagrosh.discordipc.exceptions.NoDiscordClientException; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import java.time.OffsetDateTime; public class DiscordRPC { // ──────────────────────────── Константы ──────────────────────────── private static final Minecraft MC = Minecraft.getInstance(); private static final String APPLICATION_ID = "1372950028167155866"; // ──────────────────────────── Поля ──────────────────────────────── private static IPCClient client; private static boolean running; // ──────────────────────────── Статический блок ──────────────────── static { startRPC(); } // автозапуск // ──────────────────────────── RPC-инициализация ─────────────────── public static void startRPC() { if (running) return; try { client = new IPCClient(APPLICATION_ID); client.setListener(new IPCListener() { @Override public void onPacketReceived(IPCClient client, Packet packet) { /* no-op */ } @Override public void onReady(IPCClient client) { running = true; // Имя игрока (или «Unknown») PlayerEntity player = MC.player; String playerName = player != null ? player.getName().getString() : "Unknown"; // UID удалён из details RichPresence presence = new RichPresence.Builder() .setDetails("★ User: " + playerName) .setState("★ Build: BETA") .setStartTimestamp(OffsetDateTime.now()) .setLargeImage("http://postimg.su/image/gk6EgWj8/ава.png", "★ dev: 74IQ ★") .build(); client.sendRichPresence(presence); System.out.println("[DiscordRPC] Connected — presence sent"); } @Override public void onDisconnect(IPCClient client, Throwable t) { running = false; System.out.println("[DiscordRPC] Disconnected from Discord"); } }); client.connect(); } catch (NoDiscordClientException e) { System.out.println("[DiscordRPC] Discord не запущен"); } catch (Exception e) { System.err.println("[DiscordRPC] Ошибка подключения:"); e.printStackTrace(); } } }

Теперь Rich Presence больше не содержит поле UID. Если понадобится ещё что-то подправить — дайте знать!

Вопрос

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package wtf.sqwezz.functions.impl.player;

import com.google.common.eventbus.Subscribe;
import wtf.sqwezz.events.EventPacket;
import wtf.sqwezz.events.EventUpdate;
import wtf.sqwezz.functions.api.Category;
import wtf.sqwezz.functions.api.Function;
import wtf.sqwezz.functions.api.FunctionRegister;
import wtf.sqwezz.utils.player.InventoryUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.inventory.ChestScreen;
import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.inventory.container.ChestContainer;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.play.client.CClickWindowPacket;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.util.Hand;

@FunctionRegister(
name = "SDuelConnect",
type = Category.Player
)
public class SDuelConnect extends Function {
public SDuelConnect() {
}

text
public static void selectCompass() { int n = InventoryUtil.getInstance(Items.COMPASS).findBestSlotInHotBar(); if (n != -1) { Minecraft var10000 = mc; Minecraft.player.inventory.currentItem = n; var10000 = mc; Minecraft.player.connection.sendPacket(new CHeldItemChangePacket(n)); Minecraft var10001 = mc; Minecraft var10002 = mc; mc.playerController.processRightClick(Minecraft.player, Minecraft.world, Hand.MAIN_HAND); } } @Subscribe private void onUpdate(EventUpdate eventUpdate) { Screen screen = mc.currentScreen; if (screen instanceof ChestScreen chestScreen) { for(int i = 0; i < ((ChestContainer)chestScreen.getContainer()).inventorySlots.size(); ++i) { if (((ChestContainer)chestScreen.getContainer()).getSlot(i).getStack().getItem() == Items.STICKY_PISTON) { ItemStack itemStack = ((ChestContainer)chestScreen.getContainer()).getSlot(i).getStack(); Minecraft var10000 = mc; ClientPlayNetHandler var6 = Minecraft.player.connection; int var10003 = ((ChestContainer)chestScreen.getContainer()).windowId; ClickType var10006 = ClickType.PICKUP; ChestContainer var10008 = (ChestContainer)chestScreen.getContainer(); Minecraft var10009 = mc; var6.sendPacket(new CClickWindowPacket(var10003, i, 0, var10006, itemStack, var10008.getNextTransactionID(Minecraft.player.inventory))); return; } } } else { selectCompass(); } } @Subscribe private void onPacket(EventPacket eventPacket) { String string = mc.ingameGUI.getTabList().header.getString(); if (string.contains("Приватка")) { this.print("Успешно подключился на дуэли!"); this.toggle(); } }

}

сделай так что бы оно нажимало автоматически ПКМ

Мысль

Evaluating auto-right-click behavior

The user wants the mod to automatically right-click. I think they might want this to happen continuously or under certain conditions. The provided code selects the compass and calls a right-click or processRightClick() action.

The current implementation only simulates one right-click, so I’m guessing the user wants to make it automatic, maybe even in specific scenarios like inside a chest screen. I’ll have to ensure it triggers multiple times or in the correct conditions. I'll update the logic accordingly.

Updating right-click logic

The user wants to change the mod to use right-click automatically. The code currently uses left-click to pick up items in a chest (via ClickType.PICKUP). We need to update this logic by sending button "1" instead of "0" for right-click, using the CClickWindowPacket. This change should be made inside the onUpdate event, where chest screen operations occur. Additionally, the processRightClick() call in selectCompass() looks fine and doesn't need modification. This will allow right-click actions to occur instead of left-click when handling items.

Thought for 11 seconds

Ответ

Чтобы клик по слоту со Sticky Piston выполнялся именно ПКМ, достаточно передать в CClickWindowPacket значение 1 вместо 0 (первый аргумент button: 0 – ЛКМ, 1 – ПКМ). Ниже показан изменённый фрагмент метода onUpdate — остальной класс оставьте без изменений.

java
@Subscribe private void onUpdate(EventUpdate eventUpdate) { Screen screen = mc.currentScreen; if (screen instanceof ChestScreen chestScreen) { for (int i = 0; i < ((ChestContainer) chestScreen.getContainer()).inventorySlots.size(); ++i) { if (((ChestContainer) chestScreen.getContainer()).getSlot(i).getStack().getItem() == Items.STICKY_PISTON) { ItemStack itemStack = ((ChestContainer) chestScreen.getContainer()).getSlot(i).getStack(); // ────────── главное изменение: button = 1 (ПКМ) ────────── mc.player.connection.sendPacket( new CClickWindowPacket( ((ChestContainer) chestScreen.getContainer()).windowId, // windowId i, // slot 1, // button 1 → ПКМ ClickType.PICKUP, // тип клика itemStack, ((ChestContainer) chestScreen.getContainer()) .getNextTransactionID(Minecraft.player.inventory) ) ); return; } } } else { selectCompass(); // как было } }

Теперь мод каждый тик «правой кнопкой» забирает один предмет из нужного слота; действие выполняется автоматически, как вы и хотели. Если потребуется другое поведение (например, зажимать ПКМ или клика́ть несколько раз подряд) — сообщите!

Поделиться этим Q&A