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

Вопрос TrapTime дайте плиз

Пожалуйста, зарегистрируйтесь или авторизуйтесь, чтобы увидеть содержимое.


Код:
Expand Collapse Copy
package yt.leyder.modules.impl.render;

import yt.leyder.events.EventUpdate;
import yt.leyder.modules.api.Module;
import yt.leyder.modules.api.ModuleRegister;
import yt.leyder.modules.settings.impl.BooleanSetting;
import yt.leyder.utils.render.RenderUtility;
import yt.leyder.utils.font.FontUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ArmorStandEntity; 
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.StringTextComponent;
import com.mojang.blaze3d.matrix.MatrixStack;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

@ModuleRegister(name = "TrapTime", category = Category.Render, description = "Показывает время до конца трапки на FunTime")
public class TrapTime extends Module {

    private final BooleanSetting shadow = new BooleanSetting("Shadow", true);
    private final BooleanSetting background = new BooleanSetting("Background", false);


    private static final int TRAP_LIFETIME_MS = 25000;  // 25 секунд — подгони под реальность

    private final List<TrapData> activeTraps = new ArrayList<>();

    public TrapTime() {
        addSettings(shadow, background);
    }

    @Override
    public void onEnable() {
        activeTraps.clear();
        super.onEnable();
    }

 
    public void onLivingUpdate(EventUpdate e) {  // или подходящее событие, обычно pre/post player tick
        if (mc.world == null) return;

        for (Entity entity : mc.world.getAllEntities()) {
            if (!(entity instanceof ArmorStandEntity)) continue;

            ArmorStandEntity stand = (ArmorStandEntity) entity;

          
            if (stand.isInvisible() && !stand.hasNoGravity() && stand.getCustomName() != null) {
                String name = stand.getCustomName().getString().toLowerCase();

                if (name.contains("trap") || name.contains("ловушка") || name.contains("web") || /* другие маркеры */) {
                    // Проверяем, новая ли это трапка
                    boolean exists = activeTraps.stream().anyMatch(t -> t.entity == stand);
                    if (!exists) {
                        activeTraps.add(new TrapData(stand, System.currentTimeMillis()));
                    }
                }
            }
        }

      
        activeTraps.removeIf(t -> t.entity.isRemoved() || t.entity.isDead || (System.currentTimeMillis() - t.spawnTime > TRAP_LIFETIME_MS + 5000));
    }

    @Override
    public void onRender2D(MatrixStack stack, float partialTicks) {
        if (!isEnabled()) return;

        for (TrapData trap : activeTraps) {
            if (trap.entity.isRemoved()) continue;

            long lived = System.currentTimeMillis() - trap.spawnTime;
            if (lived > TRAP_LIFETIME_MS) continue;

            float remainingSec = (TRAP_LIFETIME_MS - lived) / 1000f;
            if (remainingSec <= 0) continue;

            String text = String.format("§fTrap: §c%.1f§fs", remainingSec);

            double x = trap.entity.getPosX() - mc.getRenderManager().info.getProjectedView().x;
            double y = trap.entity.getPosY() + 2.2 - mc.getRenderManager().info.getProjectedView().y;
            double z = trap.entity.getPosZ() - mc.getRenderManager().info.getProjectedView().z;

          

            RenderUtility.renderIn3D(stack, () -> {
             
                FontUtil.normal.drawCenteredStringWithShadow(
                        text,
                        (float) x,
                        (float) y,
                        shadow.get() ? Color.WHITE.getRGB() : -1
                );
            });
        }
    }

    // Можно добавить 3D-бокс вокруг трапки, если хочется
    // @Override
    // public void onRender3D(...) { ... }

    private static class TrapData {
        Entity entity;
        long spawnTime;

        TrapData(Entity e, long time) {
            this.entity = e;
            this.spawnTime = time;
        }
    }
}
 
Последнее редактирование:
Последнее редактирование:
Скрытое содержимое
Код:
Expand Collapse Copy
package yt.leyder.modules.impl.render;

import yt.leyder.events.EventUpdate;
import yt.leyder.modules.api.Module;
import yt.leyder.modules.api.ModuleRegister;
import yt.leyder.modules.settings.impl.BooleanSetting;
import yt.leyder.utils.render.RenderUtility;
import yt.leyder.utils.font.FontUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.StringTextComponent;
import com.mojang.blaze3d.matrix.MatrixStack;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

@ModuleRegister(name = "TrapTime", category = Category.Render, description = "Показывает время до конца трапки на FunTime")
public class TrapTime extends Module {

    private final BooleanSetting shadow = new BooleanSetting("Shadow", true);
    private final BooleanSetting background = new BooleanSetting("Background", false);


    private static final int TRAP_LIFETIME_MS = 25000;  // 25 секунд — подгони под реальность

    private final List<TrapData> activeTraps = new ArrayList<>();

    public TrapTime() {
        addSettings(shadow, background);
    }

    @Override
    public void onEnable() {
        activeTraps.clear();
        super.onEnable();
    }

 
    public void onLivingUpdate(EventUpdate e) {  // или подходящее событие, обычно pre/post player tick
        if (mc.world == null) return;

        for (Entity entity : mc.world.getAllEntities()) {
            if (!(entity instanceof ArmorStandEntity)) continue;

            ArmorStandEntity stand = (ArmorStandEntity) entity;

         
            if (stand.isInvisible() && !stand.hasNoGravity() && stand.getCustomName() != null) {
                String name = stand.getCustomName().getString().toLowerCase();

                if (name.contains("trap") || name.contains("ловушка") || name.contains("web") || /* другие маркеры */) {
                    // Проверяем, новая ли это трапка
                    boolean exists = activeTraps.stream().anyMatch(t -> t.entity == stand);
                    if (!exists) {
                        activeTraps.add(new TrapData(stand, System.currentTimeMillis()));
                    }
                }
            }
        }

     
        activeTraps.removeIf(t -> t.entity.isRemoved() || t.entity.isDead || (System.currentTimeMillis() - t.spawnTime > TRAP_LIFETIME_MS + 5000));
    }

    @Override
    public void onRender2D(MatrixStack stack, float partialTicks) {
        if (!isEnabled()) return;

        for (TrapData trap : activeTraps) {
            if (trap.entity.isRemoved()) continue;

            long lived = System.currentTimeMillis() - trap.spawnTime;
            if (lived > TRAP_LIFETIME_MS) continue;

            float remainingSec = (TRAP_LIFETIME_MS - lived) / 1000f;
            if (remainingSec <= 0) continue;

            String text = String.format("§fTrap: §c%.1f§fs", remainingSec);

            double x = trap.entity.getPosX() - mc.getRenderManager().info.getProjectedView().x;
            double y = trap.entity.getPosY() + 2.2 - mc.getRenderManager().info.getProjectedView().y;
            double z = trap.entity.getPosZ() - mc.getRenderManager().info.getProjectedView().z;

         

            RenderUtility.renderIn3D(stack, () -> {
            
                FontUtil.normal.drawCenteredStringWithShadow(
                        text,
                        (float) x,
                        (float) y,
                        shadow.get() ? Color.WHITE.getRGB() : -1
                );
            });
        }
    }

    // Можно добавить 3D-бокс вокруг трапки, если хочется
    // @Override
    // public void onRender3D(...) { ... }

    private static class TrapData {
        Entity entity;
        long spawnTime;

        TrapData(Entity e, long time) {
            this.entity = e;
            this.spawnTime = time;
        }
    }
}
в каком то моменте это смешной код ,не понимаю как он должен работать ,фантайм не создает никаких арморстендов рядом с трапкой с именем "Ловушка"
 
Скрытое содержимое
Код:
Expand Collapse Copy
package yt.leyder.modules.impl.render;

import yt.leyder.events.EventUpdate;
import yt.leyder.modules.api.Module;
import yt.leyder.modules.api.ModuleRegister;
import yt.leyder.modules.settings.impl.BooleanSetting;
import yt.leyder.utils.render.RenderUtility;
import yt.leyder.utils.font.FontUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.StringTextComponent;
import com.mojang.blaze3d.matrix.MatrixStack;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

@ModuleRegister(name = "TrapTime", category = Category.Render, description = "Показывает время до конца трапки на FunTime")
public class TrapTime extends Module {

    private final BooleanSetting shadow = new BooleanSetting("Shadow", true);
    private final BooleanSetting background = new BooleanSetting("Background", false);


    private static final int TRAP_LIFETIME_MS = 25000;  // 25 секунд — подгони под реальность

    private final List<TrapData> activeTraps = new ArrayList<>();

    public TrapTime() {
        addSettings(shadow, background);
    }

    @Override
    public void onEnable() {
        activeTraps.clear();
        super.onEnable();
    }

 
    public void onLivingUpdate(EventUpdate e) {  // или подходящее событие, обычно pre/post player tick
        if (mc.world == null) return;

        for (Entity entity : mc.world.getAllEntities()) {
            if (!(entity instanceof ArmorStandEntity)) continue;

            ArmorStandEntity stand = (ArmorStandEntity) entity;

        
            if (stand.isInvisible() && !stand.hasNoGravity() && stand.getCustomName() != null) {
                String name = stand.getCustomName().getString().toLowerCase();

                if (name.contains("trap") || name.contains("ловушка") || name.contains("web") || /* другие маркеры */) {
                    // Проверяем, новая ли это трапка
                    boolean exists = activeTraps.stream().anyMatch(t -> t.entity == stand);
                    if (!exists) {
                        activeTraps.add(new TrapData(stand, System.currentTimeMillis()));
                    }
                }
            }
        }

    
        activeTraps.removeIf(t -> t.entity.isRemoved() || t.entity.isDead || (System.currentTimeMillis() - t.spawnTime > TRAP_LIFETIME_MS + 5000));
    }

    @Override
    public void onRender2D(MatrixStack stack, float partialTicks) {
        if (!isEnabled()) return;

        for (TrapData trap : activeTraps) {
            if (trap.entity.isRemoved()) continue;

            long lived = System.currentTimeMillis() - trap.spawnTime;
            if (lived > TRAP_LIFETIME_MS) continue;

            float remainingSec = (TRAP_LIFETIME_MS - lived) / 1000f;
            if (remainingSec <= 0) continue;

            String text = String.format("§fTrap: §c%.1f§fs", remainingSec);

            double x = trap.entity.getPosX() - mc.getRenderManager().info.getProjectedView().x;
            double y = trap.entity.getPosY() + 2.2 - mc.getRenderManager().info.getProjectedView().y;
            double z = trap.entity.getPosZ() - mc.getRenderManager().info.getProjectedView().z;

        

            RenderUtility.renderIn3D(stack, () -> {
           
                FontUtil.normal.drawCenteredStringWithShadow(
                        text,
                        (float) x,
                        (float) y,
                        shadow.get() ? Color.WHITE.getRGB() : -1
                );
            });
        }
    }

    // Можно добавить 3D-бокс вокруг трапки, если хочется
    // @Override
    // public void onRender3D(...) { ... }

    private static class TrapData {
        Entity entity;
        long spawnTime;

        TrapData(Entity e, long time) {
            this.entity = e;
            this.spawnTime = time;
        }
    }
}
ChatLGBT код подъехал
 
Скрытое содержимое
Код:
Expand Collapse Copy
package yt.leyder.modules.impl.render;

import yt.leyder.events.EventUpdate;
import yt.leyder.modules.api.Module;
import yt.leyder.modules.api.ModuleRegister;
import yt.leyder.modules.settings.impl.BooleanSetting;
import yt.leyder.utils.render.RenderUtility;
import yt.leyder.utils.font.FontUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.StringTextComponent;
import com.mojang.blaze3d.matrix.MatrixStack;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

@ModuleRegister(name = "TrapTime", category = Category.Render, description = "Показывает время до конца трапки на FunTime")
public class TrapTime extends Module {

    private final BooleanSetting shadow = new BooleanSetting("Shadow", true);
    private final BooleanSetting background = new BooleanSetting("Background", false);


    private static final int TRAP_LIFETIME_MS = 25000;  // 25 секунд — подгони под реальность

    private final List<TrapData> activeTraps = new ArrayList<>();

    public TrapTime() {
        addSettings(shadow, background);
    }

    @Override
    public void onEnable() {
        activeTraps.clear();
        super.onEnable();
    }

 
    public void onLivingUpdate(EventUpdate e) {  // или подходящее событие, обычно pre/post player tick
        if (mc.world == null) return;

        for (Entity entity : mc.world.getAllEntities()) {
            if (!(entity instanceof ArmorStandEntity)) continue;

            ArmorStandEntity stand = (ArmorStandEntity) entity;

        
            if (stand.isInvisible() && !stand.hasNoGravity() && stand.getCustomName() != null) {
                String name = stand.getCustomName().getString().toLowerCase();

                if (name.contains("trap") || name.contains("ловушка") || name.contains("web") || /* другие маркеры */) {
                    // Проверяем, новая ли это трапка
                    boolean exists = activeTraps.stream().anyMatch(t -> t.entity == stand);
                    if (!exists) {
                        activeTraps.add(new TrapData(stand, System.currentTimeMillis()));
                    }
                }
            }
        }

    
        activeTraps.removeIf(t -> t.entity.isRemoved() || t.entity.isDead || (System.currentTimeMillis() - t.spawnTime > TRAP_LIFETIME_MS + 5000));
    }

    @Override
    public void onRender2D(MatrixStack stack, float partialTicks) {
        if (!isEnabled()) return;

        for (TrapData trap : activeTraps) {
            if (trap.entity.isRemoved()) continue;

            long lived = System.currentTimeMillis() - trap.spawnTime;
            if (lived > TRAP_LIFETIME_MS) continue;

            float remainingSec = (TRAP_LIFETIME_MS - lived) / 1000f;
            if (remainingSec <= 0) continue;

            String text = String.format("§fTrap: §c%.1f§fs", remainingSec);

            double x = trap.entity.getPosX() - mc.getRenderManager().info.getProjectedView().x;
            double y = trap.entity.getPosY() + 2.2 - mc.getRenderManager().info.getProjectedView().y;
            double z = trap.entity.getPosZ() - mc.getRenderManager().info.getProjectedView().z;

        

            RenderUtility.renderIn3D(stack, () -> {
           
                FontUtil.normal.drawCenteredStringWithShadow(
                        text,
                        (float) x,
                        (float) y,
                        shadow.get() ? Color.WHITE.getRGB() : -1
                );
            });
        }
    }

    // Можно добавить 3D-бокс вокруг трапки, если хочется
    // @Override
    // public void onRender3D(...) { ... }

    private static class TrapData {
        Entity entity;
        long spawnTime;

        TrapData(Entity e, long time) {
            this.entity = e;
            this.spawnTime = time;
        }
    }
}
тебе надо звук при использовании трапки отслеживать а не эту хуйню что тебе написал гпт
 
Назад
Сверху Снизу