/del

Статус
В этой теме нельзя размещать новые ответы.
Начинающий
Статус
Оффлайн
Регистрация
27 Янв 2023
Сообщения
17
Реакции[?]
1
Поинты[?]
1K
Mega $elfcode

NameTag:
@ModuleInfo(name = "Nametags", description = "", category = Category.RENDER)
public class Nametags extends Module {

    private final MultiBooleanValue ignore = new MultiBooleanValue("Ignore", this) {{
        add(new BooleanValue("Friends", false));
        add(new BooleanValue("Invisible", false));
    }};
    private final Font font = Fonts.INTER_BOLD.get(14);
    private final Listener<RenderNameEvent> renderNameEvent = event -> {
        if (event.getEntity() instanceof PlayerEntity) event.cancel();
    };


    private final Listener<PreBloomEvent> shader = event -> {
        renderTag(event.getMatrix(), true);
    };
    private final Listener<Render2DEvent> render = event -> {
        renderTag(event.getMatrix(), false);
    };

    private void renderTag(MatrixStack matrix, boolean shader) {
        for (PlayerEntity entity : getEntities()) {
            Vector3d iVec = RenderUtil.interpolate(entity, mc.getRenderPartialTicks());
            double posX = iVec.x;
            double posY = iVec.y;
            double posZ = iVec.z;

            Vector2d vec = RenderUtil.project(posX, posY + entity.getHeight() + 0.5F, posZ);
            if (vec != null) {
                String playerName = TextFormatting.getTextWithoutFormattingCodes(entity.getName().getString());
                String title = playerName + (playerName.isEmpty() ? "" : " ") + TextFormatting.GREEN + (int) (mc.getCurrentServerData().serverIP.contains("funtime") ? getHealth(entity) : entity.getHealth());

                double width = font.getWidth(title) + 4;

                GL11.glPushMatrix();

                Color colorFirst = ColorUtil.withAlpha(getTheme().getFirstColor(), 200);
                Color colorSecond = ColorUtil.withAlpha(getTheme().getSecondColor(), 200);

                int color1 = ColorUtil.lerp(5, 0, colorFirst, colorSecond).hashCode();
                int color2 = ColorUtil.lerp(5, 90, colorFirst, colorSecond).hashCode();
                int color3 = ColorUtil.lerp(5, 180, colorFirst, colorSecond).hashCode();
                int color4 = ColorUtil.lerp(5, 270, colorFirst, colorSecond).hashCode();

                if (!shader) {
                    RenderUtil.roundedRect(vec.x - width / 2F, vec.y, width, font.getHeight(), 2, ColorUtil.getColor(20, 20, 20, 64));
                    font.drawCenter(matrix, title, vec.x, vec.y, -1);
                } else {
                    RenderUtil.roundedGradient(vec.x - width / 2F, vec.y, width, font.getHeight(), 2, color1, color2, color3, color4);
                }

                GL11.glPopMatrix();
            }

        }
    }

    private List<AbstractClientPlayerEntity> getEntities() {
        return mc.world.getPlayers().stream().filter(entity -> {
            if (entity.isInvisible() && ignore.get("Invisible").getValue()) return false;
            if (ignore.get("Friends").getValue() && (dissolve.getFriendManager().isFriend(entity.getName().getString())))
                return false;
            if (entity.equals(mc.player) && mc.gameSettings.getPointOfView().equals(PointOfView.FIRST_PERSON))
                return false;
            if (!AntiBot.checkBot(entity)) return false;

            return !entity.isInvisible() || !ignore.get("Invisible").getValue();
        }).toList();
    }

    public float getHealth(PlayerEntity ent) {
        ScoreObjective scoreBoard = null;
        String resolvedHp = "";

        if ((ent.getWorldScoreboard()).getObjectiveInDisplaySlot(Scoreboard.getObjectiveDisplaySlotNumber("belowName")) != null) {
            scoreBoard = (ent.getWorldScoreboard()).getObjectiveInDisplaySlot(Scoreboard.getObjectiveDisplaySlotNumber("belowName"));
            if (scoreBoard != null) {
                Score scoreboardScore = ent.getWorldScoreboard().getOrCreateScore(ent.getName().getString(), scoreBoard);
                resolvedHp = String.valueOf(scoreboardScore.getScorePoints());
            }
        }

        float numValue = 0;

        try {
            numValue = Float.parseFloat(resolvedHp);
        } catch (NumberFormatException ignored) {
        }

        return numValue;
    }

}


TargetHud:
@ModuleInfo(name = "Target Hud", description = "", category = Category.RENDER)
public class TargetHud extends Module {

    public final DragValue positionValue = new DragValue("Position", this, new Vector2d(200, 200));
    public final BooleanValue followPlayer = new BooleanValue("Entity tracking", this, false);

    public Vector2d position = new Vector2d(0, 0);
    public Counter counter = Counter.create();
    public Entity target;
    public boolean inWorld;
    public final Listener<MotionEvent> onMotion = event -> {
        if (mc.currentScreen instanceof ChatScreen) {
            counter.reset();
            target = mc.player;
        }
        if (target == null) {
            inWorld = false;
            return;
        }
        inWorld = StreamSupport.stream(mc.world.getAllEntities().spliterator(), true).filter(entity -> entity == target).isParallel();
    };

    public final Listener<AttackEvent> onAttack = event -> {
        if (event.getTarget() instanceof AbstractClientPlayerEntity) {
            target = event.getTarget();
            counter.reset();
        }
    };

    private final Animation openingAnimation = new Animation(Easing.EASE_OUT_ELASTIC, 500);
    private final Animation healthAnimation = new Animation(Easing.EASE_OUT_SINE, 500);
    private final Font interbold20 = Fonts.INTER_BOLD.get(16);
    private final Font intermedium14 = Fonts.INTER_BOLD.get(12);
    private final int INDENT = 4;

    public final Listener<PreBloomEvent> onBloom = event -> {
        Entity target = this.target;
        if (target == null) {
            return;
        }
        boolean out = (!this.inWorld || this.counter.hasReached(1000));
        openingAnimation.setDuration(out ? 400 : 300);
        openingAnimation.setEasing(out ? Easing.EASE_IN_BACK : Easing.EASE_OUT_BACK);
        openingAnimation.run(out ? 0 : 1);
        if (openingAnimation.getValue() <= 0) return;
        String name = target.getName().getString();
        double x = this.position.x;
        double y = this.position.y;
        double nameWidth = interbold20.getWidth(name);
        int faceScale = 16;
        double healthBarWidth = Math.max(faceScale + nameWidth + INDENT, 80);
        double width = INDENT * 3F + healthBarWidth;
        double height = faceScale + INDENT * 4;
        double scale = openingAnimation.getValue();
        GlStateManager.pushMatrix();
        GlStateManager.translated((x + width / 2) * (1 - scale), (y + height / 2) * (1 - scale), 0);
        GlStateManager.scaled(scale, scale, 0);
        Color colorFirst = ColorUtil.withAlpha(getTheme().getFirstColor(), 255).brighter();
        Color colorSecond = ColorUtil.withAlpha(getTheme().getSecondColor(), 255).brighter();

        int color1 = ColorUtil.lerp(5, 0, colorFirst, colorSecond).hashCode();
        int color2 = ColorUtil.lerp(5, 90, colorFirst, colorSecond).hashCode();
        int color3 = ColorUtil.lerp(5, 180, colorFirst, colorSecond).hashCode();
        int color4 = ColorUtil.lerp(5, 270, colorFirst, colorSecond).hashCode();

        RenderUtil.roundedGradient(x, y, width, height, 3, color1, color2, color3, color4);
        GlStateManager.popMatrix();
    };
    public final Listener<ShaderEvent> onShader = event -> {
        if (event.isBlur()) {
            Entity target = this.target;
            if (target == null) {
                return;
            }
            if (openingAnimation.getValue() <= 0) return;
            String name = target.getName().getString();
            double x = this.position.x;
            double y = this.position.y;
            double nameWidth = interbold20.getWidth(name);
            int faceScale = 16;
            double healthBarWidth = Math.max(faceScale + nameWidth + INDENT, 80);
            double width = INDENT * 3F + healthBarWidth;
            double height = faceScale + INDENT * 4;
            double scale = openingAnimation.getValue();
            GlStateManager.pushMatrix();
            GlStateManager.translated((x + width / 2) * (1 - scale), (y + height / 2) * (1 - scale), 0);
            GlStateManager.scaled(scale, scale, 0);
            Color colorFirst = ColorUtil.withAlpha(getTheme().getFirstColor(), 255).brighter();
            Color colorSecond = ColorUtil.withAlpha(getTheme().getSecondColor(), 255).brighter();

            int color1 = ColorUtil.lerp(5, 0, colorFirst, colorSecond).hashCode();
            int color2 = ColorUtil.lerp(5, 90, colorFirst, colorSecond).hashCode();
            int color3 = ColorUtil.lerp(5, 180, colorFirst, colorSecond).hashCode();
            int color4 = ColorUtil.lerp(5, 270, colorFirst, colorSecond).hashCode();

            RenderUtil.roundedGradient(x, y, width, height, 3, color1, color2, color3, color4);
            GlStateManager.popMatrix();
        }
    };

    private void setPosition(Entity target, double width, double height) {
        if (!followPlayer.getValue()) {
            this.position.x = positionValue.position.x;
            this.position.y = positionValue.position.y;
            return;
        }
        if (target.equals(mc.player)) {
            this.position.x = (mw.getScaledWidth() / 2F) - (positionValue.size.x / 2F);
            this.position.y = (mw.getScaledHeight() / 2F) + (positionValue.size.y * 2F);
        } else {
            Vector3d interpolatedPosition = RenderUtil.interpolate(target, mc.getRenderPartialTicks());
            double posX = interpolatedPosition.x;
            double posY = interpolatedPosition.y;
            double posZ = interpolatedPosition.z;
            Vector2d position = RenderUtil.project(posX, posY + ((target.getHeight() + 0.4F) * 0.5F), posZ);
            if (position == null) return;

            this.position.x = position.x - (positionValue.size.x / 2F);
            this.position.y = position.y;
        }
        this.positionValue.setSize(new Vector2d(width, height));
    }

    public final Listener<Render2DEvent> onRender2D = event -> {

        Entity target = this.target;
        if (target == null) {
            healthAnimation.setValue(0);
            return;
        }
        boolean out = (!this.inWorld || this.counter.hasReached(1000));
        openingAnimation.setDuration(out ? 400 : 300);
        openingAnimation.setEasing(out ? Easing.EASE_IN_BACK : Easing.EASE_OUT_BACK);
        openingAnimation.run(out ? 0 : 1);
        if (openingAnimation.getValue() <= 0) return;
        String name = target.getName().getString();
        int faceScale = 16;
        double x = this.position.x;
        double y = this.position.y;
        double nameWidth = interbold20.getWidth(name);
        double health = !this.inWorld ? 0 : Mathf.round(mc.getCurrentServerData().serverIP.contains("funtime") ? getHealth((PlayerEntity) target) : ((AbstractClientPlayerEntity) target).getHealth(), 1);
        double healthBarWidth = Math.max(faceScale + nameWidth + INDENT, 80);
        healthAnimation.setEasing(Easing.EASE_OUT_QUAD);
        healthAnimation.setDuration(250);
        healthAnimation.run((health / Math.max(health, ((AbstractClientPlayerEntity) target).getMaxHealth())) * healthBarWidth);
        double healthRemainingWidth = healthAnimation.getValue();
        double width = INDENT * 3F + healthBarWidth;
        double height = faceScale + INDENT * 4;

        double scale = openingAnimation.getValue();
        GlStateManager.pushMatrix();
        GlStateManager.translated((x + width / 2) * (1 - scale), (y + height / 2) * (1 - scale), 0);
        GlStateManager.scaled(scale, scale, 0);

        Color colorFirst = ColorUtil.withAlpha(getTheme().getFirstColor(), 128);
        Color colorSecond = ColorUtil.withAlpha(getTheme().getSecondColor(), 128);

        int color1 = ColorUtil.lerp(5, 0, colorFirst, colorSecond).hashCode();
        int color2 = ColorUtil.lerp(5, 90, colorFirst, colorSecond).hashCode();
        int color3 = ColorUtil.lerp(5, 180, colorFirst, colorSecond).hashCode();
        int color4 = ColorUtil.lerp(5, 270, colorFirst, colorSecond).hashCode();


        RenderUtil.roundedOutline(x, y, width, height, 3 + 0.5F, 0.5, new Color(255, 255, 255, 128).hashCode());
        RenderUtil.roundedGradient(x, y, width, height, 3, color1, color2, color3, color4);

        int OFFSET = 8;
        interbold20.draw(event.getMatrix(), name, x + OFFSET + INDENT / 2F + faceScale, y + INDENT + (faceScale / 2F) - (interbold20.getHeight() / 2F), -1);

        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        GlStateManager.translated((x + width / 2) * (1 - scale), (y + height / 2) * (1 - scale), 0);
        GlStateManager.scaled(scale, scale, 0);
        renderTargetHead(event.getMatrix(), target, x + INDENT * 1.5F, y + INDENT * 1.5F, faceScale);

        String hpText = String.valueOf(health).replace(".0", "") + "HP";
        double hpX = Mathf.clamp(x + OFFSET + INDENT / 2F + faceScale + intermedium14.getWidth(hpText) / 2F, x + INDENT * 1.5F + healthBarWidth - intermedium14.getWidth(hpText) / 2F, x + INDENT * 1.5F + healthRemainingWidth);

        intermedium14.drawCenter(event.getMatrix(), hpText, hpX, y + faceScale, -1);

        if (!healthAnimation.isFinished()) {
            Fonts.ICON.get(12).drawCenter(event.getMatrix(), Icon.DOWN.getCharacter(), x + INDENT * 1.5F + healthRemainingWidth - 0.5F, y + OFFSET + faceScale - INDENT / 1.5F - 0.5, -1);
        }

        RenderUtil.roundedRect(x + INDENT * 1.5F, y + OFFSET + faceScale + INDENT / 2F,
                healthBarWidth, 2, 0.5, new Color(150, 150, 150).hashCode());
        RenderUtil.roundedRect(x + INDENT * 1.5F, y + OFFSET + faceScale + INDENT / 2F,
                healthRemainingWidth, 2, 0.5, Color.WHITE.hashCode());
        GlStateManager.popMatrix();

        setPosition(target, width, height);
    };

    private void renderTargetHead(MatrixStack matrixStack, final Entity entity, final double x, final double y, final int size) {
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.0F);
        GlStateManager.enableTexture();
        final ResourceLocation resourceLocation = ((AbstractClientPlayerEntity) entity).getLocationSkin();
        mc.getTextureManager().bindTexture(resourceLocation);
        GlStateManager.color4f(1F, 1F, 1F, 1F);
        AbstractGui.blit(matrixStack, (float) x, (float) y, size, size, 4, 4, 4, 4, 32, 32);
        GLUtils.scaleStart((float) (x + size / 2F), (float) (y + size / 2F), 1.1F);
        AbstractGui.blit(matrixStack, (float) x, (float) y, size, size, 20, 4, 4, 4, 32, 32);
        GLUtils.scaleEnd();
        GlStateManager.disableBlend();
    }

    public float getHealth(PlayerEntity ent) {
        ScoreObjective scoreBoard = null;
        String resolvedHp = "";

        if ((ent.getWorldScoreboard()).getObjectiveInDisplaySlot(Scoreboard.getObjectiveDisplaySlotNumber("belowName")) != null) {
            scoreBoard = (ent.getWorldScoreboard()).getObjectiveInDisplaySlot(Scoreboard.getObjectiveDisplaySlotNumber("belowName"));
            if (scoreBoard != null) {
                Score scoreboardScore = ent.getWorldScoreboard().getOrCreateScore(ent.getName().getString(), scoreBoard);
                resolvedHp = String.valueOf(scoreboardScore.getScorePoints());
            }
        }

        float numValue = 0;

        try {
            numValue = Float.parseFloat(resolvedHp);
        } catch (NumberFormatException ignored) {
        }

        return numValue;
    }
}
не благодарите
 
Начинающий
Статус
Оффлайн
Регистрация
9 Июл 2023
Сообщения
77
Реакции[?]
0
Поинты[?]
0
Mega $elfcode

NameTag:
@ModuleInfo(name = "Nametags", description = "", category = Category.RENDER)
public class Nametags extends Module {

    private final MultiBooleanValue ignore = new MultiBooleanValue("Ignore", this) {{
        add(new BooleanValue("Friends", false));
        add(new BooleanValue("Invisible", false));
    }};
    private final Font font = Fonts.INTER_BOLD.get(14);
    private final Listener<RenderNameEvent> renderNameEvent = event -> {
        if (event.getEntity() instanceof PlayerEntity) event.cancel();
    };


    private final Listener<PreBloomEvent> shader = event -> {
        renderTag(event.getMatrix(), true);
    };
    private final Listener<Render2DEvent> render = event -> {
        renderTag(event.getMatrix(), false);
    };

    private void renderTag(MatrixStack matrix, boolean shader) {
        for (PlayerEntity entity : getEntities()) {
            Vector3d iVec = RenderUtil.interpolate(entity, mc.getRenderPartialTicks());
            double posX = iVec.x;
            double posY = iVec.y;
            double posZ = iVec.z;

            Vector2d vec = RenderUtil.project(posX, posY + entity.getHeight() + 0.5F, posZ);
            if (vec != null) {
                String playerName = TextFormatting.getTextWithoutFormattingCodes(entity.getName().getString());
                String title = playerName + (playerName.isEmpty() ? "" : " ") + TextFormatting.GREEN + (int) (mc.getCurrentServerData().serverIP.contains("funtime") ? getHealth(entity) : entity.getHealth());

                double width = font.getWidth(title) + 4;

                GL11.glPushMatrix();

                Color colorFirst = ColorUtil.withAlpha(getTheme().getFirstColor(), 200);
                Color colorSecond = ColorUtil.withAlpha(getTheme().getSecondColor(), 200);

                int color1 = ColorUtil.lerp(5, 0, colorFirst, colorSecond).hashCode();
                int color2 = ColorUtil.lerp(5, 90, colorFirst, colorSecond).hashCode();
                int color3 = ColorUtil.lerp(5, 180, colorFirst, colorSecond).hashCode();
                int color4 = ColorUtil.lerp(5, 270, colorFirst, colorSecond).hashCode();

                if (!shader) {
                    RenderUtil.roundedRect(vec.x - width / 2F, vec.y, width, font.getHeight(), 2, ColorUtil.getColor(20, 20, 20, 64));
                    font.drawCenter(matrix, title, vec.x, vec.y, -1);
                } else {
                    RenderUtil.roundedGradient(vec.x - width / 2F, vec.y, width, font.getHeight(), 2, color1, color2, color3, color4);
                }

                GL11.glPopMatrix();
            }

        }
    }

    private List<AbstractClientPlayerEntity> getEntities() {
        return mc.world.getPlayers().stream().filter(entity -> {
            if (entity.isInvisible() && ignore.get("Invisible").getValue()) return false;
            if (ignore.get("Friends").getValue() && (dissolve.getFriendManager().isFriend(entity.getName().getString())))
                return false;
            if (entity.equals(mc.player) && mc.gameSettings.getPointOfView().equals(PointOfView.FIRST_PERSON))
                return false;
            if (!AntiBot.checkBot(entity)) return false;

            return !entity.isInvisible() || !ignore.get("Invisible").getValue();
        }).toList();
    }

    public float getHealth(PlayerEntity ent) {
        ScoreObjective scoreBoard = null;
        String resolvedHp = "";

        if ((ent.getWorldScoreboard()).getObjectiveInDisplaySlot(Scoreboard.getObjectiveDisplaySlotNumber("belowName")) != null) {
            scoreBoard = (ent.getWorldScoreboard()).getObjectiveInDisplaySlot(Scoreboard.getObjectiveDisplaySlotNumber("belowName"));
            if (scoreBoard != null) {
                Score scoreboardScore = ent.getWorldScoreboard().getOrCreateScore(ent.getName().getString(), scoreBoard);
                resolvedHp = String.valueOf(scoreboardScore.getScorePoints());
            }
        }

        float numValue = 0;

        try {
            numValue = Float.parseFloat(resolvedHp);
        } catch (NumberFormatException ignored) {
        }

        return numValue;
    }

}


TargetHud:
@ModuleInfo(name = "Target Hud", description = "", category = Category.RENDER)
public class TargetHud extends Module {

    public final DragValue positionValue = new DragValue("Position", this, new Vector2d(200, 200));
    public final BooleanValue followPlayer = new BooleanValue("Entity tracking", this, false);

    public Vector2d position = new Vector2d(0, 0);
    public Counter counter = Counter.create();
    public Entity target;
    public boolean inWorld;
    public final Listener<MotionEvent> onMotion = event -> {
        if (mc.currentScreen instanceof ChatScreen) {
            counter.reset();
            target = mc.player;
        }
        if (target == null) {
            inWorld = false;
            return;
        }
        inWorld = StreamSupport.stream(mc.world.getAllEntities().spliterator(), true).filter(entity -> entity == target).isParallel();
    };

    public final Listener<AttackEvent> onAttack = event -> {
        if (event.getTarget() instanceof AbstractClientPlayerEntity) {
            target = event.getTarget();
            counter.reset();
        }
    };

    private final Animation openingAnimation = new Animation(Easing.EASE_OUT_ELASTIC, 500);
    private final Animation healthAnimation = new Animation(Easing.EASE_OUT_SINE, 500);
    private final Font interbold20 = Fonts.INTER_BOLD.get(16);
    private final Font intermedium14 = Fonts.INTER_BOLD.get(12);
    private final int INDENT = 4;

    public final Listener<PreBloomEvent> onBloom = event -> {
        Entity target = this.target;
        if (target == null) {
            return;
        }
        boolean out = (!this.inWorld || this.counter.hasReached(1000));
        openingAnimation.setDuration(out ? 400 : 300);
        openingAnimation.setEasing(out ? Easing.EASE_IN_BACK : Easing.EASE_OUT_BACK);
        openingAnimation.run(out ? 0 : 1);
        if (openingAnimation.getValue() <= 0) return;
        String name = target.getName().getString();
        double x = this.position.x;
        double y = this.position.y;
        double nameWidth = interbold20.getWidth(name);
        int faceScale = 16;
        double healthBarWidth = Math.max(faceScale + nameWidth + INDENT, 80);
        double width = INDENT * 3F + healthBarWidth;
        double height = faceScale + INDENT * 4;
        double scale = openingAnimation.getValue();
        GlStateManager.pushMatrix();
        GlStateManager.translated((x + width / 2) * (1 - scale), (y + height / 2) * (1 - scale), 0);
        GlStateManager.scaled(scale, scale, 0);
        Color colorFirst = ColorUtil.withAlpha(getTheme().getFirstColor(), 255).brighter();
        Color colorSecond = ColorUtil.withAlpha(getTheme().getSecondColor(), 255).brighter();

        int color1 = ColorUtil.lerp(5, 0, colorFirst, colorSecond).hashCode();
        int color2 = ColorUtil.lerp(5, 90, colorFirst, colorSecond).hashCode();
        int color3 = ColorUtil.lerp(5, 180, colorFirst, colorSecond).hashCode();
        int color4 = ColorUtil.lerp(5, 270, colorFirst, colorSecond).hashCode();

        RenderUtil.roundedGradient(x, y, width, height, 3, color1, color2, color3, color4);
        GlStateManager.popMatrix();
    };
    public final Listener<ShaderEvent> onShader = event -> {
        if (event.isBlur()) {
            Entity target = this.target;
            if (target == null) {
                return;
            }
            if (openingAnimation.getValue() <= 0) return;
            String name = target.getName().getString();
            double x = this.position.x;
            double y = this.position.y;
            double nameWidth = interbold20.getWidth(name);
            int faceScale = 16;
            double healthBarWidth = Math.max(faceScale + nameWidth + INDENT, 80);
            double width = INDENT * 3F + healthBarWidth;
            double height = faceScale + INDENT * 4;
            double scale = openingAnimation.getValue();
            GlStateManager.pushMatrix();
            GlStateManager.translated((x + width / 2) * (1 - scale), (y + height / 2) * (1 - scale), 0);
            GlStateManager.scaled(scale, scale, 0);
            Color colorFirst = ColorUtil.withAlpha(getTheme().getFirstColor(), 255).brighter();
            Color colorSecond = ColorUtil.withAlpha(getTheme().getSecondColor(), 255).brighter();

            int color1 = ColorUtil.lerp(5, 0, colorFirst, colorSecond).hashCode();
            int color2 = ColorUtil.lerp(5, 90, colorFirst, colorSecond).hashCode();
            int color3 = ColorUtil.lerp(5, 180, colorFirst, colorSecond).hashCode();
            int color4 = ColorUtil.lerp(5, 270, colorFirst, colorSecond).hashCode();

            RenderUtil.roundedGradient(x, y, width, height, 3, color1, color2, color3, color4);
            GlStateManager.popMatrix();
        }
    };

    private void setPosition(Entity target, double width, double height) {
        if (!followPlayer.getValue()) {
            this.position.x = positionValue.position.x;
            this.position.y = positionValue.position.y;
            return;
        }
        if (target.equals(mc.player)) {
            this.position.x = (mw.getScaledWidth() / 2F) - (positionValue.size.x / 2F);
            this.position.y = (mw.getScaledHeight() / 2F) + (positionValue.size.y * 2F);
        } else {
            Vector3d interpolatedPosition = RenderUtil.interpolate(target, mc.getRenderPartialTicks());
            double posX = interpolatedPosition.x;
            double posY = interpolatedPosition.y;
            double posZ = interpolatedPosition.z;
            Vector2d position = RenderUtil.project(posX, posY + ((target.getHeight() + 0.4F) * 0.5F), posZ);
            if (position == null) return;

            this.position.x = position.x - (positionValue.size.x / 2F);
            this.position.y = position.y;
        }
        this.positionValue.setSize(new Vector2d(width, height));
    }

    public final Listener<Render2DEvent> onRender2D = event -> {

        Entity target = this.target;
        if (target == null) {
            healthAnimation.setValue(0);
            return;
        }
        boolean out = (!this.inWorld || this.counter.hasReached(1000));
        openingAnimation.setDuration(out ? 400 : 300);
        openingAnimation.setEasing(out ? Easing.EASE_IN_BACK : Easing.EASE_OUT_BACK);
        openingAnimation.run(out ? 0 : 1);
        if (openingAnimation.getValue() <= 0) return;
        String name = target.getName().getString();
        int faceScale = 16;
        double x = this.position.x;
        double y = this.position.y;
        double nameWidth = interbold20.getWidth(name);
        double health = !this.inWorld ? 0 : Mathf.round(mc.getCurrentServerData().serverIP.contains("funtime") ? getHealth((PlayerEntity) target) : ((AbstractClientPlayerEntity) target).getHealth(), 1);
        double healthBarWidth = Math.max(faceScale + nameWidth + INDENT, 80);
        healthAnimation.setEasing(Easing.EASE_OUT_QUAD);
        healthAnimation.setDuration(250);
        healthAnimation.run((health / Math.max(health, ((AbstractClientPlayerEntity) target).getMaxHealth())) * healthBarWidth);
        double healthRemainingWidth = healthAnimation.getValue();
        double width = INDENT * 3F + healthBarWidth;
        double height = faceScale + INDENT * 4;

        double scale = openingAnimation.getValue();
        GlStateManager.pushMatrix();
        GlStateManager.translated((x + width / 2) * (1 - scale), (y + height / 2) * (1 - scale), 0);
        GlStateManager.scaled(scale, scale, 0);

        Color colorFirst = ColorUtil.withAlpha(getTheme().getFirstColor(), 128);
        Color colorSecond = ColorUtil.withAlpha(getTheme().getSecondColor(), 128);

        int color1 = ColorUtil.lerp(5, 0, colorFirst, colorSecond).hashCode();
        int color2 = ColorUtil.lerp(5, 90, colorFirst, colorSecond).hashCode();
        int color3 = ColorUtil.lerp(5, 180, colorFirst, colorSecond).hashCode();
        int color4 = ColorUtil.lerp(5, 270, colorFirst, colorSecond).hashCode();


        RenderUtil.roundedOutline(x, y, width, height, 3 + 0.5F, 0.5, new Color(255, 255, 255, 128).hashCode());
        RenderUtil.roundedGradient(x, y, width, height, 3, color1, color2, color3, color4);

        int OFFSET = 8;
        interbold20.draw(event.getMatrix(), name, x + OFFSET + INDENT / 2F + faceScale, y + INDENT + (faceScale / 2F) - (interbold20.getHeight() / 2F), -1);

        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        GlStateManager.translated((x + width / 2) * (1 - scale), (y + height / 2) * (1 - scale), 0);
        GlStateManager.scaled(scale, scale, 0);
        renderTargetHead(event.getMatrix(), target, x + INDENT * 1.5F, y + INDENT * 1.5F, faceScale);

        String hpText = String.valueOf(health).replace(".0", "") + "HP";
        double hpX = Mathf.clamp(x + OFFSET + INDENT / 2F + faceScale + intermedium14.getWidth(hpText) / 2F, x + INDENT * 1.5F + healthBarWidth - intermedium14.getWidth(hpText) / 2F, x + INDENT * 1.5F + healthRemainingWidth);

        intermedium14.drawCenter(event.getMatrix(), hpText, hpX, y + faceScale, -1);

        if (!healthAnimation.isFinished()) {
            Fonts.ICON.get(12).drawCenter(event.getMatrix(), Icon.DOWN.getCharacter(), x + INDENT * 1.5F + healthRemainingWidth - 0.5F, y + OFFSET + faceScale - INDENT / 1.5F - 0.5, -1);
        }

        RenderUtil.roundedRect(x + INDENT * 1.5F, y + OFFSET + faceScale + INDENT / 2F,
                healthBarWidth, 2, 0.5, new Color(150, 150, 150).hashCode());
        RenderUtil.roundedRect(x + INDENT * 1.5F, y + OFFSET + faceScale + INDENT / 2F,
                healthRemainingWidth, 2, 0.5, Color.WHITE.hashCode());
        GlStateManager.popMatrix();

        setPosition(target, width, height);
    };

    private void renderTargetHead(MatrixStack matrixStack, final Entity entity, final double x, final double y, final int size) {
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.0F);
        GlStateManager.enableTexture();
        final ResourceLocation resourceLocation = ((AbstractClientPlayerEntity) entity).getLocationSkin();
        mc.getTextureManager().bindTexture(resourceLocation);
        GlStateManager.color4f(1F, 1F, 1F, 1F);
        AbstractGui.blit(matrixStack, (float) x, (float) y, size, size, 4, 4, 4, 4, 32, 32);
        GLUtils.scaleStart((float) (x + size / 2F), (float) (y + size / 2F), 1.1F);
        AbstractGui.blit(matrixStack, (float) x, (float) y, size, size, 20, 4, 4, 4, 32, 32);
        GLUtils.scaleEnd();
        GlStateManager.disableBlend();
    }

    public float getHealth(PlayerEntity ent) {
        ScoreObjective scoreBoard = null;
        String resolvedHp = "";

        if ((ent.getWorldScoreboard()).getObjectiveInDisplaySlot(Scoreboard.getObjectiveDisplaySlotNumber("belowName")) != null) {
            scoreBoard = (ent.getWorldScoreboard()).getObjectiveInDisplaySlot(Scoreboard.getObjectiveDisplaySlotNumber("belowName"));
            if (scoreBoard != null) {
                Score scoreboardScore = ent.getWorldScoreboard().getOrCreateScore(ent.getName().getString(), scoreBoard);
                resolvedHp = String.valueOf(scoreboardScore.getScorePoints());
            }
        }

        float numValue = 0;

        try {
            numValue = Float.parseFloat(resolvedHp);
        } catch (NumberFormatException ignored) {
        }

        return numValue;
    }
}
не благодарите
иду пастить в свой Night reborn nova expensive nurik next gen reloaded recode
 
Статус
В этой теме нельзя размещать новые ответы.
Похожие темы
Сверху Снизу