Начинающий
- Статус
- Оффлайн
- Регистрация
- 17 Ноя 2023
- Сообщения
- 291
- Реакции
- 3
короче в нотифки при нажатии кнопки не выводит, в чат не выводит как не пытался уже.
help
Код:
package eva.ware.modules.impl.misc;
import com.google.common.eventbus.Subscribe;
import eva.ware.Evaware;
import eva.ware.events.EventPacket;
import eva.ware.events.WorldEvent;
import eva.ware.modules.api.Category;
import eva.ware.modules.api.ModuleRegister;
import eva.ware.modules.api.Module;
import eva.ware.modules.settings.Setting;
import eva.ware.modules.settings.impl.BindSetting;
import eva.ware.ui.notify.impl.WarningNotify;
import eva.ware.ui.themes.Theme;
import net.minecraft.block.Blocks;
import net.minecraft.network.play.server.SMultiBlockChangePacket;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.optifine.render.RenderUtils;
import java.util.ArrayList;
import static eva.ware.utils.client.IMinecraft.mc;
@ModuleRegister(name = "AncientXray", category = Category.Misc, server = eva.ware.modules.api.ServerGroup.NO)
public class AncientXray extends Module {
private final ArrayList<BlockPos> ores = new ArrayList<>();
private final int searchRadius = 30;
private boolean isSearching = false;
public final BindSetting keyBind = new BindSetting("Activation Key", 0);
public AncientXray() {
addSettings(keyBind);
}
@Override
public boolean onEnable() {
isSearching = true;
return super.onEnable();
}
@Override
public void onDisable() {
isSearching = false;
ores.clear();
super.onDisable();
}
@Subscribe
public void onPacket(EventPacket e) {
if (!isSearching) return;
if (e.getPacket() instanceof SMultiBlockChangePacket packet) {
packet.func_244310_a((blockPos, blockState) -> {
BlockPos bp = blockPos.toImmutable();
if (blockState.getBlock().equals(Blocks.ANCIENT_DEBRIS) && !ores.contains(bp)) {
if (isWithinRadius(bp)) {
ores.add(bp);
}
}
});
}
}
@Subscribe
public void onRender3D(WorldEvent e) {
if (!isSearching || mc.player == null || mc.world == null) return;
ores.removeIf(pos -> !mc.world.getBlockState(pos).getBlock().equals(Blocks.ANCIENT_DEBRIS) || !isWithinRadius(pos));
ores.forEach(pos -> RenderUtils.drawBlockBox(pos, Theme.mainRectColor));
}
private boolean isWithinRadius(BlockPos pos) {
if (mc.player == null) return false;
BlockPos playerPos = mc.player.getPosition();
double distance = Math.sqrt(playerPos.distanceSq(pos));
return distance <= searchRadius;
}
public void onKeyPress(int key) {
if (key == keyBind.get()) {
toggle();
if (isSearching) {
sendNotification("Найдено обломков: " + ores.size(), 1000);
} else {
sendNotification("Поиск обломков остановлен.", 1000);
}
}
}
private void sendNotification(String message, int duration) {
Evaware.getInstance().getNotifyManager().add(0, new WarningNotify(message, duration));
}
}