Вот вам 4 завоз ! EXP 3.1 ! TargetInfoRenderer

Начинающий
Статус
Оффлайн
Регистрация
20 Апр 2023
Сообщения
133
Реакции[?]
1
Поинты[?]
1K
// By KaTrec
  1. package im.expensive.ui.display.impl;
    1. import com.mojang.blaze3d.platform.GlStateManager;
    2. import im.expensive.Expensive;
    3. import im.expensive.events.EventDisplay;
    4. import im.expensive.ui.display.ElementRenderer;
    5. import im.expensive.ui.styles.Style;
    6. import im.expensive.utils.animations.Animation;
    7. import im.expensive.utils.animations.Direction;
    8. import im.expensive.utils.animations.impl.EaseBackIn;
    9. import im.expensive.utils.drag.Dragging;
    10. import im.expensive.utils.math.MathUtil;
    11. import im.expensive.utils.math.StopWatch;
    12. import im.expensive.utils.math.Vector4i;
    13. import im.expensive.utils.render.ColorUtils;
    14. import im.expensive.utils.render.DisplayUtils;
    15. import im.expensive.utils.render.Scissor;
    16. import im.expensive.utils.render.Stencil;
    17. import im.expensive.utils.render.font.Fonts;
    18. import lombok.AccessLevel;
    19. import lombok.RequiredArgsConstructor;
    20. import lombok.experimental.FieldDefaults;
    21. import net.minecraft.client.gui.AbstractGui;
    22. import net.minecraft.client.gui.screen.ChatScreen;
    23. import net.minecraft.client.renderer.entity.EntityRenderer;
    24. import net.minecraft.entity.LivingEntity;
    25. import net.minecraft.entity.player.PlayerEntity;
    26. import net.minecraft.scoreboard.Score;
    27. import net.minecraft.util.ResourceLocation;
    28. import net.minecraft.util.math.MathHelper;
    29. import net.minecraft.util.math.vector.Vector4f;
    30. import org.lwjgl.opengl.GL11;
    31. @FieldDefaults(level = AccessLevel.PRIVATE)
    32. @RequiredArgsConstructor
    33. public class TargetInfoRenderer implements ElementRenderer {
    34. final StopWatch stopWatch = new StopWatch();
    35. final Dragging drag;
    36. LivingEntity entity = null;
    37. boolean allow;
    38. final Animation animation = new EaseBackIn(400, 1, 1);
    39. final Animation textAnimation = new EaseBackIn(300, 1, 1);
    40. float healthAnimation = 0.0f;
    41. float absorptionAnimation = 0.0f;
      override
    42. public void render(EventDisplay eventDisplay) {
    43. entity = getTarget(entity);
    44. float rounding = 8; //
    45. boolean out = !allow || stopWatch.isReached(1000);
    46. animation.setDuration(out ? 400 : 300);
    47. animation.setDirection(out ? Direction.BACKWARDS : Direction.FORWARDS);
    48. if (animation.getOutput() == 0.0f) {
    49. entity = null;
    50. }
    51. if (entity != null) {
    52. String name = entity.getName().getString();
    53. float posX = drag.getX();
    54. float posY = drag.getY();
    55. float headSize = 28;
    56. float spacing = 6;
    57. float width = 200;
    58. float height = 80;
    59. drag.setWidth(width);
    60. drag.setHeight(height);
    61. float hp = entity.getHealth();
    62. float maxHp = entity.getMaxHealth();
    63. // Фикс HP для Funtime и ReallyWorld
    64. if (isCustomServer()) {
    65. Score score = mc.world.getScoreboard().getOrCreateScore(entity.getScoreboardName(), mc.world.getScoreboard().getObjectiveInDisplaySlot(2));
    66. hp = score != null ? score.getScorePoints() : 0;
    67. maxHp = 20;
    68. }
    69. healthAnimation = MathUtil.fast(healthAnimation, MathHelper.clamp(hp / maxHp, 0, 1), 10);
    70. absorptionAnimation = MathUtil.fast(absorptionAnimation, MathHelper.clamp(entity.getAbsorptionAmount() / maxHp, 0, 1), 10);
    71. float animationValue = (float) animation.getOutput();
    72. GlStateManager.pushMatrix();
    73. Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();
    74. sizeAnimation(posX + (width / 2), posY + (height / 2), animation.getOutput());
    75. drawStyledRect(posX, posY, width, height, rounding, 230);
    76. // KaTrec
    77. DisplayUtils.drawRoundedRectOutline(posX, posY, width, height, rounding, 2, ColorUtils.rgb(128, 0, 128));
    78. Stencil.initStencilToWrite();
    79. DisplayUtils.drawRoundedRect(posX + spacing, posY + spacing, headSize, headSize, 8, ColorUtils.rgba(25, 26, 40, 165));
    80. Stencil.readStencilBuffer(1);
    81. drawTargetHead(entity, posX + spacing, posY + spacing, headSize, headSize);
    82. Stencil.uninitStencilBuffer();
    83. // Текст анимация
    84. textAnimation.setDirection(hp < maxHp / 2 ? Direction.FORWARDS : Direction.BACKWARDS);
    85. float textAnimValue = (float) textAnimation.getOutput();
    86. // Победа/Проигрыш
    87. String resultText = hp >= maxHp ? "Проигрыш" : "Победа";
    88. int resultColor = hp >= maxHp ? ColorUtils.rgb(255, 0, 0) : ColorUtils.rgb(0, 255, 0);
    89. Scissor.push();
    90. Fonts.sfui.drawText(eventDisplay.getMatrixStack(), name, posX + headSize + spacing * 2, posY + 10, -1, 12);
    91. Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), "HP: " + (int) hp + " / " + (int) maxHp, posX + headSize + spacing * 2, posY + 30, ColorUtils.rgb(255, 255, 255), 9);
    92. Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), resultText, posX + width / 2, posY + height - 20 + textAnimValue * 10, resultColor, 12);
    93. Scissor.pop();
    94. Vector4i gradientColor = new Vector4i(style.getFirstColor().getRGB(), style.getFirstColor().getRGB(), style.getSecondColor().getRGB(), style.getSecondColor().getRGB());
    95. DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, width - headSize - spacing * 3, 5, new Vector4f(3, 3, 3, 3), ColorUtils.rgb(50, 50, 50));
    96. DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, (width - headSize - spacing * 3) * healthAnimation, 5, new Vector4f(3, 3, 3, 3), gradientColor);
    97. GlStateManager.popMatrix();
    98. }
    99. }
    100. private boolean isCustomServer() {
    101. String serverIP = mc.getCurrentServerData() != null ? mc.getCurrentServerData().serverIP : "";
    102. String header = mc.ingameGUI.getTabList().header != null ? mc.ingameGUI.getTabList().header.getString().toLowerCase() : "";
    103. return (serverIP.contains("reallyworld") || serverIP.contains("funtime")) && (header.contains("анархия") || header.contains("гриф"));
    104. }
    105. private LivingEntity getTarget(LivingEntity nullTarget) {
    106. LivingEntity auraTarget = Expensive.getInstance().getFunctionRegistry().getKillAura().getTarget();
    107. LivingEntity target = nullTarget;
    108. if (auraTarget != null) {
    109. stopWatch.reset();
    110. allow = true;
    111. target = auraTarget;
    112. } else if (mc.currentScreen instanceof ChatScreen) {
    113. stopWatch.reset();
    114. allow = true;
    115. target = mc.player;
    116. } else {
    117. allow = false;
    118. }
    119. return target;
    120. }
    121. public void drawTargetHead(LivingEntity entity, float x, float y, float width, float height) {
    122. if (entity != null) {
    123. EntityRenderer<? super LivingEntity> rendererManager = mc.getRenderManager().getRenderer(entity);
    124. drawFace(rendererManager.getEntityTexture(entity), x, y, 8F, 8F, 8F, 8F, width, height, 64F, 64F, entity);
    125. }
    126. }
    127. public static void sizeAnimation(double width, double height, double scale) {
    128. GlStateManager.translated(width, height, 0);
    129. GlStateManager.scaled(scale, scale, scale);
    130. GlStateManager.translated(-width, -height, 0);
    131. }
    132. public void drawFace(ResourceLocation res, float d, float y, float u, float v, float uWidth, float vHeight, float width, float height, float tileWidth, float tileHeight, LivingEntity target) {
    133. GL11.glPushMatrix();
    134. GL11.glEnable(GL11.GL_BLEND);
    135. mc.getTextureManager().bindTexture(res);
    136. float hurtPercent = (target.hurtTime - (target.hurtTime != 0 ? mc.timer.renderPartialTicks : 0.0f)) / 10.0f;
    137. GL11.glColor4f(1, 1 - hurtPercent, 1 - hurtPercent, 1);
    138. AbstractGui.drawScaledCustomSizeModalRect(d, y, u, v, uWidth, vHeight, width, height, tileWidth, tileHeight);
    139. GL11.glColor4f(1, 1, 1, 1);
    140. GL11.glPopMatrix();
    141. }
    142. private void drawStyledRect(float x, float y, float width, float height, float radius, int alpha) {
    143. DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgba(21, 21, 21, alpha));
    144. DisplayUtils.drawShadow(x + 5, y + 5, width, height, 5, ColorUtils.rgba(10, 15, 13, 15));
    145. }
    146. }
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
20 Апр 2023
Сообщения
133
Реакции[?]
1
Поинты[?]
1K
Топизна:
// By KaTrec
package im.expensive.ui.display.impl;
import com.mojang.blaze3d.platform.GlStateManager;
import im.expensive.Expensive;
import im.expensive.events.EventDisplay;
import im.expensive.ui.display.ElementRenderer;
import im.expensive.ui.styles.Style;
import im.expensive.utils.animations.Animation;
import im.expensive.utils.animations.Direction;
import im.expensive.utils.animations.impl.EaseBackIn;
import im.expensive.utils.drag.Dragging;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.StopWatch;
import im.expensive.utils.math.Vector4i;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.Scissor;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.scoreboard.Score;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector4f;
import org.lwjgl.opengl.GL11;
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class TargetInfoRenderer implements ElementRenderer {
final StopWatch stopWatch = new StopWatch();
final Dragging drag;
LivingEntity entity = null;
boolean allow;
final Animation animation = new EaseBackIn(400, 1, 1);
final Animation textAnimation = new EaseBackIn(300, 1, 1);
float healthAnimation = 0.0f;
float absorptionAnimation = 0.0f;
override
public void render(EventDisplay eventDisplay) {
entity = getTarget(entity);
float rounding = 8; //
boolean out = !allow || stopWatch.isReached(1000);
animation.setDuration(out ? 400 : 300);
animation.setDirection(out ? Direction.BACKWARDS : Direction.FORWARDS);
if (animation.getOutput() == 0.0f) {
entity = null;
}
if (entity != null) {
String name = entity.getName().getString();
float posX = drag.getX();
float posY = drag.getY();
float headSize = 28;
float spacing = 6;
float width = 200;
float height = 80;
drag.setWidth(width);
drag.setHeight(height);
float hp = entity.getHealth();
float maxHp = entity.getMaxHealth();
// Фикс HP для Funtime и ReallyWorld
if (isCustomServer()) {
Score score = mc.world.getScoreboard().getOrCreateScore(entity.getScoreboardName(), mc.world.getScoreboard().getObjectiveInDisplaySlot(2));
hp = score != null ? score.getScorePoints() : 0;
maxHp = 20;
}
healthAnimation = MathUtil.fast(healthAnimation, MathHelper.clamp(hp / maxHp, 0, 1), 10);
absorptionAnimation = MathUtil.fast(absorptionAnimation, MathHelper.clamp(entity.getAbsorptionAmount() / maxHp, 0, 1), 10);
float animationValue = (float) animation.getOutput();
GlStateManager.pushMatrix();
Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();
sizeAnimation(posX + (width / 2), posY + (height / 2), animation.getOutput());
drawStyledRect(posX, posY, width, height, rounding, 230);
// KaTrec
DisplayUtils.drawRoundedRectOutline(posX, posY, width, height, rounding, 2, ColorUtils.rgb(128, 0, 128));
Stencil.initStencilToWrite();
DisplayUtils.drawRoundedRect(posX + spacing, posY + spacing, headSize, headSize, 8, ColorUtils.rgba(25, 26, 40, 165));
Stencil.readStencilBuffer(1);
drawTargetHead(entity, posX + spacing, posY + spacing, headSize, headSize);
Stencil.uninitStencilBuffer();
// Текст анимация
textAnimation.setDirection(hp < maxHp / 2 ? Direction.FORWARDS : Direction.BACKWARDS);
float textAnimValue = (float) textAnimation.getOutput();
// Победа/Проигрыш
String resultText = hp >= maxHp ? "Проигрыш" : "Победа";
int resultColor = hp >= maxHp ? ColorUtils.rgb(255, 0, 0) : ColorUtils.rgb(0, 255, 0);
Scissor.push();
Fonts.sfui.drawText(eventDisplay.getMatrixStack(), name, posX + headSize + spacing * 2, posY + 10, -1, 12);
Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), "HP: " + (int) hp + " / " + (int) maxHp, posX + headSize + spacing * 2, posY + 30, ColorUtils.rgb(255, 255, 255), 9);
Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), resultText, posX + width / 2, posY + height - 20 + textAnimValue * 10, resultColor, 12);
Scissor.pop();
Vector4i gradientColor = new Vector4i(style.getFirstColor().getRGB(), style.getFirstColor().getRGB(), style.getSecondColor().getRGB(), style.getSecondColor().getRGB());
DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, width - headSize - spacing * 3, 5, new Vector4f(3, 3, 3, 3), ColorUtils.rgb(50, 50, 50));
DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, (width - headSize - spacing * 3) * healthAnimation, 5, new Vector4f(3, 3, 3, 3), gradientColor);
GlStateManager.popMatrix();
}
}
private boolean isCustomServer() {
String serverIP = mc.getCurrentServerData() != null ? mc.getCurrentServerData().serverIP : "";
String header = mc.ingameGUI.getTabList().header != null ? mc.ingameGUI.getTabList().header.getString().toLowerCase() : "";
return (serverIP.contains("reallyworld") || serverIP.contains("funtime")) && (header.contains("анархия") || header.contains("гриф"));
}
private LivingEntity getTarget(LivingEntity nullTarget) {
LivingEntity auraTarget = Expensive.getInstance().getFunctionRegistry().getKillAura().getTarget();
LivingEntity target = nullTarget;
if (auraTarget != null) {
stopWatch.reset();
allow = true;
target = auraTarget;
} else if (mc.currentScreen instanceof ChatScreen) {
stopWatch.reset();
allow = true;
target = mc.player;
} else {
allow = false;
}
return target;
}
public void drawTargetHead(LivingEntity entity, float x, float y, float width, float height) {
if (entity != null) {
EntityRenderer<? super LivingEntity> rendererManager = mc.getRenderManager().getRenderer(entity);
drawFace(rendererManager.getEntityTexture(entity), x, y, 8F, 8F, 8F, 8F, width, height, 64F, 64F, entity);
}
}
public static void sizeAnimation(double width, double height, double scale) {
GlStateManager.translated(width, height, 0);
GlStateManager.scaled(scale, scale, scale);
GlStateManager.translated(-width, -height, 0);
}
public void drawFace(ResourceLocation res, float d, float y, float u, float v, float uWidth, float vHeight, float width, float height, float tileWidth, float tileHeight, LivingEntity target) {
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
mc.getTextureManager().bindTexture(res);
float hurtPercent = (target.hurtTime - (target.hurtTime != 0 ? mc.timer.renderPartialTicks : 0.0f)) / 10.0f;
GL11.glColor4f(1, 1 - hurtPercent, 1 - hurtPercent, 1);
AbstractGui.drawScaledCustomSizeModalRect(d, y, u, v, uWidth, vHeight, width, height, tileWidth, tileHeight);
GL11.glColor4f(1, 1, 1, 1);
GL11.glPopMatrix();
}
private void drawStyledRect(float x, float y, float width, float height, float radius, int alpha) {
DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgba(21, 21, 21, alpha));
DisplayUtils.drawShadow(x + 5, y + 5, width, height, 5, ColorUtils.rgba(10, 15, 13, 15));
}
}
кто знает как вставил но как то так сами подправите если надо(:
 
Забаненный
Статус
Оффлайн
Регистрация
16 Апр 2024
Сообщения
351
Реакции[?]
3
Поинты[?]
1K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
// By KaTrec
  1. package im.expensive.ui.display.impl;
    1. import com.mojang.blaze3d.platform.GlStateManager;
    2. import im.expensive.Expensive;
    3. import im.expensive.events.EventDisplay;
    4. import im.expensive.ui.display.ElementRenderer;
    5. import im.expensive.ui.styles.Style;
    6. import im.expensive.utils.animations.Animation;
    7. import im.expensive.utils.animations.Direction;
    8. import im.expensive.utils.animations.impl.EaseBackIn;
    9. import im.expensive.utils.drag.Dragging;
    10. import im.expensive.utils.math.MathUtil;
    11. import im.expensive.utils.math.StopWatch;
    12. import im.expensive.utils.math.Vector4i;
    13. import im.expensive.utils.render.ColorUtils;
    14. import im.expensive.utils.render.DisplayUtils;
    15. import im.expensive.utils.render.Scissor;
    16. import im.expensive.utils.render.Stencil;
    17. import im.expensive.utils.render.font.Fonts;
    18. import lombok.AccessLevel;
    19. import lombok.RequiredArgsConstructor;
    20. import lombok.experimental.FieldDefaults;
    21. import net.minecraft.client.gui.AbstractGui;
    22. import net.minecraft.client.gui.screen.ChatScreen;
    23. import net.minecraft.client.renderer.entity.EntityRenderer;
    24. import net.minecraft.entity.LivingEntity;
    25. import net.minecraft.entity.player.PlayerEntity;
    26. import net.minecraft.scoreboard.Score;
    27. import net.minecraft.util.ResourceLocation;
    28. import net.minecraft.util.math.MathHelper;
    29. import net.minecraft.util.math.vector.Vector4f;
    30. import org.lwjgl.opengl.GL11;
    31. @FieldDefaults(level = AccessLevel.PRIVATE)
    32. @RequiredArgsConstructor
    33. public class TargetInfoRenderer implements ElementRenderer {
    34. final StopWatch stopWatch = new StopWatch();
    35. final Dragging drag;
    36. LivingEntity entity = null;
    37. boolean allow;
    38. final Animation animation = new EaseBackIn(400, 1, 1);
    39. final Animation textAnimation = new EaseBackIn(300, 1, 1);
    40. float healthAnimation = 0.0f;
    41. float absorptionAnimation = 0.0f;
      override
    42. public void render(EventDisplay eventDisplay) {
    43. entity = getTarget(entity);
    44. float rounding = 8; //
    45. boolean out = !allow || stopWatch.isReached(1000);
    46. animation.setDuration(out ? 400 : 300);
    47. animation.setDirection(out ? Direction.BACKWARDS : Direction.FORWARDS);
    48. if (animation.getOutput() == 0.0f) {
    49. entity = null;
    50. }
    51. if (entity != null) {
    52. String name = entity.getName().getString();
    53. float posX = drag.getX();
    54. float posY = drag.getY();
    55. float headSize = 28;
    56. float spacing = 6;
    57. float width = 200;
    58. float height = 80;
    59. drag.setWidth(width);
    60. drag.setHeight(height);
    61. float hp = entity.getHealth();
    62. float maxHp = entity.getMaxHealth();
    63. // Фикс HP для Funtime и ReallyWorld
    64. if (isCustomServer()) {
    65. Score score = mc.world.getScoreboard().getOrCreateScore(entity.getScoreboardName(), mc.world.getScoreboard().getObjectiveInDisplaySlot(2));
    66. hp = score != null ? score.getScorePoints() : 0;
    67. maxHp = 20;
    68. }
    69. healthAnimation = MathUtil.fast(healthAnimation, MathHelper.clamp(hp / maxHp, 0, 1), 10);
    70. absorptionAnimation = MathUtil.fast(absorptionAnimation, MathHelper.clamp(entity.getAbsorptionAmount() / maxHp, 0, 1), 10);
    71. float animationValue = (float) animation.getOutput();
    72. GlStateManager.pushMatrix();
    73. Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();
    74. sizeAnimation(posX + (width / 2), posY + (height / 2), animation.getOutput());
    75. drawStyledRect(posX, posY, width, height, rounding, 230);
    76. // KaTrec
    77. DisplayUtils.drawRoundedRectOutline(posX, posY, width, height, rounding, 2, ColorUtils.rgb(128, 0, 128));
    78. Stencil.initStencilToWrite();
    79. DisplayUtils.drawRoundedRect(posX + spacing, posY + spacing, headSize, headSize, 8, ColorUtils.rgba(25, 26, 40, 165));
    80. Stencil.readStencilBuffer(1);
    81. drawTargetHead(entity, posX + spacing, posY + spacing, headSize, headSize);
    82. Stencil.uninitStencilBuffer();
    83. // Текст анимация
    84. textAnimation.setDirection(hp < maxHp / 2 ? Direction.FORWARDS : Direction.BACKWARDS);
    85. float textAnimValue = (float) textAnimation.getOutput();
    86. // Победа/Проигрыш
    87. String resultText = hp >= maxHp ? "Проигрыш" : "Победа";
    88. int resultColor = hp >= maxHp ? ColorUtils.rgb(255, 0, 0) : ColorUtils.rgb(0, 255, 0);
    89. Scissor.push();
    90. Fonts.sfui.drawText(eventDisplay.getMatrixStack(), name, posX + headSize + spacing * 2, posY + 10, -1, 12);
    91. Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), "HP: " + (int) hp + " / " + (int) maxHp, posX + headSize + spacing * 2, posY + 30, ColorUtils.rgb(255, 255, 255), 9);
    92. Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), resultText, posX + width / 2, posY + height - 20 + textAnimValue * 10, resultColor, 12);
    93. Scissor.pop();
    94. Vector4i gradientColor = new Vector4i(style.getFirstColor().getRGB(), style.getFirstColor().getRGB(), style.getSecondColor().getRGB(), style.getSecondColor().getRGB());
    95. DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, width - headSize - spacing * 3, 5, new Vector4f(3, 3, 3, 3), ColorUtils.rgb(50, 50, 50));
    96. DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, (width - headSize - spacing * 3) * healthAnimation, 5, new Vector4f(3, 3, 3, 3), gradientColor);
    97. GlStateManager.popMatrix();
    98. }
    99. }
    100. private boolean isCustomServer() {
    101. String serverIP = mc.getCurrentServerData() != null ? mc.getCurrentServerData().serverIP : "";
    102. String header = mc.ingameGUI.getTabList().header != null ? mc.ingameGUI.getTabList().header.getString().toLowerCase() : "";
    103. return (serverIP.contains("reallyworld") || serverIP.contains("funtime")) && (header.contains("анархия") || header.contains("гриф"));
    104. }
    105. private LivingEntity getTarget(LivingEntity nullTarget) {
    106. LivingEntity auraTarget = Expensive.getInstance().getFunctionRegistry().getKillAura().getTarget();
    107. LivingEntity target = nullTarget;
    108. if (auraTarget != null) {
    109. stopWatch.reset();
    110. allow = true;
    111. target = auraTarget;
    112. } else if (mc.currentScreen instanceof ChatScreen) {
    113. stopWatch.reset();
    114. allow = true;
    115. target = mc.player;
    116. } else {
    117. allow = false;
    118. }
    119. return target;
    120. }
    121. public void drawTargetHead(LivingEntity entity, float x, float y, float width, float height) {
    122. if (entity != null) {
    123. EntityRenderer<? super LivingEntity> rendererManager = mc.getRenderManager().getRenderer(entity);
    124. drawFace(rendererManager.getEntityTexture(entity), x, y, 8F, 8F, 8F, 8F, width, height, 64F, 64F, entity);
    125. }
    126. }
    127. public static void sizeAnimation(double width, double height, double scale) {
    128. GlStateManager.translated(width, height, 0);
    129. GlStateManager.scaled(scale, scale, scale);
    130. GlStateManager.translated(-width, -height, 0);
    131. }
    132. public void drawFace(ResourceLocation res, float d, float y, float u, float v, float uWidth, float vHeight, float width, float height, float tileWidth, float tileHeight, LivingEntity target) {
    133. GL11.glPushMatrix();
    134. GL11.glEnable(GL11.GL_BLEND);
    135. mc.getTextureManager().bindTexture(res);
    136. float hurtPercent = (target.hurtTime - (target.hurtTime != 0 ? mc.timer.renderPartialTicks : 0.0f)) / 10.0f;
    137. GL11.glColor4f(1, 1 - hurtPercent, 1 - hurtPercent, 1);
    138. AbstractGui.drawScaledCustomSizeModalRect(d, y, u, v, uWidth, vHeight, width, height, tileWidth, tileHeight);
    139. GL11.glColor4f(1, 1, 1, 1);
    140. GL11.glPopMatrix();
    141. }
    142. private void drawStyledRect(float x, float y, float width, float height, float radius, int alpha) {
    143. DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgba(21, 21, 21, alpha));
    144. DisplayUtils.drawShadow(x + 5, y + 5, width, height, 5, ColorUtils.rgba(10, 15, 13, 15));
    145. }
    146. }
1734911326385.pngПИЗДЕЦ НАХУЙ
 
Начинающий
Статус
Оффлайн
Регистрация
5 Авг 2024
Сообщения
15
Реакции[?]
0
Поинты[?]
0
// By KaTrec
  1. package im.expensive.ui.display.impl;
    1. import com.mojang.blaze3d.platform.GlStateManager;
    2. import im.expensive.Expensive;
    3. import im.expensive.events.EventDisplay;
    4. import im.expensive.ui.display.ElementRenderer;
    5. import im.expensive.ui.styles.Style;
    6. import im.expensive.utils.animations.Animation;
    7. import im.expensive.utils.animations.Direction;
    8. import im.expensive.utils.animations.impl.EaseBackIn;
    9. import im.expensive.utils.drag.Dragging;
    10. import im.expensive.utils.math.MathUtil;
    11. import im.expensive.utils.math.StopWatch;
    12. import im.expensive.utils.math.Vector4i;
    13. import im.expensive.utils.render.ColorUtils;
    14. import im.expensive.utils.render.DisplayUtils;
    15. import im.expensive.utils.render.Scissor;
    16. import im.expensive.utils.render.Stencil;
    17. import im.expensive.utils.render.font.Fonts;
    18. import lombok.AccessLevel;
    19. import lombok.RequiredArgsConstructor;
    20. import lombok.experimental.FieldDefaults;
    21. import net.minecraft.client.gui.AbstractGui;
    22. import net.minecraft.client.gui.screen.ChatScreen;
    23. import net.minecraft.client.renderer.entity.EntityRenderer;
    24. import net.minecraft.entity.LivingEntity;
    25. import net.minecraft.entity.player.PlayerEntity;
    26. import net.minecraft.scoreboard.Score;
    27. import net.minecraft.util.ResourceLocation;
    28. import net.minecraft.util.math.MathHelper;
    29. import net.minecraft.util.math.vector.Vector4f;
    30. import org.lwjgl.opengl.GL11;
    31. @FieldDefaults(level = AccessLevel.PRIVATE)
    32. @RequiredArgsConstructor
    33. public class TargetInfoRenderer implements ElementRenderer {
    34. final StopWatch stopWatch = new StopWatch();
    35. final Dragging drag;
    36. LivingEntity entity = null;
    37. boolean allow;
    38. final Animation animation = new EaseBackIn(400, 1, 1);
    39. final Animation textAnimation = new EaseBackIn(300, 1, 1);
    40. float healthAnimation = 0.0f;
    41. float absorptionAnimation = 0.0f;
      override
    42. public void render(EventDisplay eventDisplay) {
    43. entity = getTarget(entity);
    44. float rounding = 8; //
    45. boolean out = !allow || stopWatch.isReached(1000);
    46. animation.setDuration(out ? 400 : 300);
    47. animation.setDirection(out ? Direction.BACKWARDS : Direction.FORWARDS);
    48. if (animation.getOutput() == 0.0f) {
    49. entity = null;
    50. }
    51. if (entity != null) {
    52. String name = entity.getName().getString();
    53. float posX = drag.getX();
    54. float posY = drag.getY();
    55. float headSize = 28;
    56. float spacing = 6;
    57. float width = 200;
    58. float height = 80;
    59. drag.setWidth(width);
    60. drag.setHeight(height);
    61. float hp = entity.getHealth();
    62. float maxHp = entity.getMaxHealth();
    63. // Фикс HP для Funtime и ReallyWorld
    64. if (isCustomServer()) {
    65. Score score = mc.world.getScoreboard().getOrCreateScore(entity.getScoreboardName(), mc.world.getScoreboard().getObjectiveInDisplaySlot(2));
    66. hp = score != null ? score.getScorePoints() : 0;
    67. maxHp = 20;
    68. }
    69. healthAnimation = MathUtil.fast(healthAnimation, MathHelper.clamp(hp / maxHp, 0, 1), 10);
    70. absorptionAnimation = MathUtil.fast(absorptionAnimation, MathHelper.clamp(entity.getAbsorptionAmount() / maxHp, 0, 1), 10);
    71. float animationValue = (float) animation.getOutput();
    72. GlStateManager.pushMatrix();
    73. Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();
    74. sizeAnimation(posX + (width / 2), posY + (height / 2), animation.getOutput());
    75. drawStyledRect(posX, posY, width, height, rounding, 230);
    76. // KaTrec
    77. DisplayUtils.drawRoundedRectOutline(posX, posY, width, height, rounding, 2, ColorUtils.rgb(128, 0, 128));
    78. Stencil.initStencilToWrite();
    79. DisplayUtils.drawRoundedRect(posX + spacing, posY + spacing, headSize, headSize, 8, ColorUtils.rgba(25, 26, 40, 165));
    80. Stencil.readStencilBuffer(1);
    81. drawTargetHead(entity, posX + spacing, posY + spacing, headSize, headSize);
    82. Stencil.uninitStencilBuffer();
    83. // Текст анимация
    84. textAnimation.setDirection(hp < maxHp / 2 ? Direction.FORWARDS : Direction.BACKWARDS);
    85. float textAnimValue = (float) textAnimation.getOutput();
    86. // Победа/Проигрыш
    87. String resultText = hp >= maxHp ? "Проигрыш" : "Победа";
    88. int resultColor = hp >= maxHp ? ColorUtils.rgb(255, 0, 0) : ColorUtils.rgb(0, 255, 0);
    89. Scissor.push();
    90. Fonts.sfui.drawText(eventDisplay.getMatrixStack(), name, posX + headSize + spacing * 2, posY + 10, -1, 12);
    91. Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), "HP: " + (int) hp + " / " + (int) maxHp, posX + headSize + spacing * 2, posY + 30, ColorUtils.rgb(255, 255, 255), 9);
    92. Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), resultText, posX + width / 2, posY + height - 20 + textAnimValue * 10, resultColor, 12);
    93. Scissor.pop();
    94. Vector4i gradientColor = new Vector4i(style.getFirstColor().getRGB(), style.getFirstColor().getRGB(), style.getSecondColor().getRGB(), style.getSecondColor().getRGB());
    95. DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, width - headSize - spacing * 3, 5, new Vector4f(3, 3, 3, 3), ColorUtils.rgb(50, 50, 50));
    96. DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, (width - headSize - spacing * 3) * healthAnimation, 5, new Vector4f(3, 3, 3, 3), gradientColor);
    97. GlStateManager.popMatrix();
    98. }
    99. }
    100. private boolean isCustomServer() {
    101. String serverIP = mc.getCurrentServerData() != null ? mc.getCurrentServerData().serverIP : "";
    102. String header = mc.ingameGUI.getTabList().header != null ? mc.ingameGUI.getTabList().header.getString().toLowerCase() : "";
    103. return (serverIP.contains("reallyworld") || serverIP.contains("funtime")) && (header.contains("анархия") || header.contains("гриф"));
    104. }
    105. private LivingEntity getTarget(LivingEntity nullTarget) {
    106. LivingEntity auraTarget = Expensive.getInstance().getFunctionRegistry().getKillAura().getTarget();
    107. LivingEntity target = nullTarget;
    108. if (auraTarget != null) {
    109. stopWatch.reset();
    110. allow = true;
    111. target = auraTarget;
    112. } else if (mc.currentScreen instanceof ChatScreen) {
    113. stopWatch.reset();
    114. allow = true;
    115. target = mc.player;
    116. } else {
    117. allow = false;
    118. }
    119. return target;
    120. }
    121. public void drawTargetHead(LivingEntity entity, float x, float y, float width, float height) {
    122. if (entity != null) {
    123. EntityRenderer<? super LivingEntity> rendererManager = mc.getRenderManager().getRenderer(entity);
    124. drawFace(rendererManager.getEntityTexture(entity), x, y, 8F, 8F, 8F, 8F, width, height, 64F, 64F, entity);
    125. }
    126. }
    127. public static void sizeAnimation(double width, double height, double scale) {
    128. GlStateManager.translated(width, height, 0);
    129. GlStateManager.scaled(scale, scale, scale);
    130. GlStateManager.translated(-width, -height, 0);
    131. }
    132. public void drawFace(ResourceLocation res, float d, float y, float u, float v, float uWidth, float vHeight, float width, float height, float tileWidth, float tileHeight, LivingEntity target) {
    133. GL11.glPushMatrix();
    134. GL11.glEnable(GL11.GL_BLEND);
    135. mc.getTextureManager().bindTexture(res);
    136. float hurtPercent = (target.hurtTime - (target.hurtTime != 0 ? mc.timer.renderPartialTicks : 0.0f)) / 10.0f;
    137. GL11.glColor4f(1, 1 - hurtPercent, 1 - hurtPercent, 1);
    138. AbstractGui.drawScaledCustomSizeModalRect(d, y, u, v, uWidth, vHeight, width, height, tileWidth, tileHeight);
    139. GL11.glColor4f(1, 1, 1, 1);
    140. GL11.glPopMatrix();
    141. }
    142. private void drawStyledRect(float x, float y, float width, float height, float radius, int alpha) {
    143. DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgba(21, 21, 21, alpha));
    144. DisplayUtils.drawShadow(x + 5, y + 5, width, height, 5, ColorUtils.rgba(10, 15, 13, 15));
    145. }
    146. }
пизда
 
Начинающий
Статус
Оффлайн
Регистрация
24 Фев 2024
Сообщения
268
Реакции[?]
4
Поинты[?]
4K
// By KaTrec
  1. package im.expensive.ui.display.impl;
    1. import com.mojang.blaze3d.platform.GlStateManager;
    2. import im.expensive.Expensive;
    3. import im.expensive.events.EventDisplay;
    4. import im.expensive.ui.display.ElementRenderer;
    5. import im.expensive.ui.styles.Style;
    6. import im.expensive.utils.animations.Animation;
    7. import im.expensive.utils.animations.Direction;
    8. import im.expensive.utils.animations.impl.EaseBackIn;
    9. import im.expensive.utils.drag.Dragging;
    10. import im.expensive.utils.math.MathUtil;
    11. import im.expensive.utils.math.StopWatch;
    12. import im.expensive.utils.math.Vector4i;
    13. import im.expensive.utils.render.ColorUtils;
    14. import im.expensive.utils.render.DisplayUtils;
    15. import im.expensive.utils.render.Scissor;
    16. import im.expensive.utils.render.Stencil;
    17. import im.expensive.utils.render.font.Fonts;
    18. import lombok.AccessLevel;
    19. import lombok.RequiredArgsConstructor;
    20. import lombok.experimental.FieldDefaults;
    21. import net.minecraft.client.gui.AbstractGui;
    22. import net.minecraft.client.gui.screen.ChatScreen;
    23. import net.minecraft.client.renderer.entity.EntityRenderer;
    24. import net.minecraft.entity.LivingEntity;
    25. import net.minecraft.entity.player.PlayerEntity;
    26. import net.minecraft.scoreboard.Score;
    27. import net.minecraft.util.ResourceLocation;
    28. import net.minecraft.util.math.MathHelper;
    29. import net.minecraft.util.math.vector.Vector4f;
    30. import org.lwjgl.opengl.GL11;
    31. @FieldDefaults(level = AccessLevel.PRIVATE)
    32. @RequiredArgsConstructor
    33. public class TargetInfoRenderer implements ElementRenderer {
    34. final StopWatch stopWatch = new StopWatch();
    35. final Dragging drag;
    36. LivingEntity entity = null;
    37. boolean allow;
    38. final Animation animation = new EaseBackIn(400, 1, 1);
    39. final Animation textAnimation = new EaseBackIn(300, 1, 1);
    40. float healthAnimation = 0.0f;
    41. float absorptionAnimation = 0.0f;
      override
    42. public void render(EventDisplay eventDisplay) {
    43. entity = getTarget(entity);
    44. float rounding = 8; //
    45. boolean out = !allow || stopWatch.isReached(1000);
    46. animation.setDuration(out ? 400 : 300);
    47. animation.setDirection(out ? Direction.BACKWARDS : Direction.FORWARDS);
    48. if (animation.getOutput() == 0.0f) {
    49. entity = null;
    50. }
    51. if (entity != null) {
    52. String name = entity.getName().getString();
    53. float posX = drag.getX();
    54. float posY = drag.getY();
    55. float headSize = 28;
    56. float spacing = 6;
    57. float width = 200;
    58. float height = 80;
    59. drag.setWidth(width);
    60. drag.setHeight(height);
    61. float hp = entity.getHealth();
    62. float maxHp = entity.getMaxHealth();
    63. // Фикс HP для Funtime и ReallyWorld
    64. if (isCustomServer()) {
    65. Score score = mc.world.getScoreboard().getOrCreateScore(entity.getScoreboardName(), mc.world.getScoreboard().getObjectiveInDisplaySlot(2));
    66. hp = score != null ? score.getScorePoints() : 0;
    67. maxHp = 20;
    68. }
    69. healthAnimation = MathUtil.fast(healthAnimation, MathHelper.clamp(hp / maxHp, 0, 1), 10);
    70. absorptionAnimation = MathUtil.fast(absorptionAnimation, MathHelper.clamp(entity.getAbsorptionAmount() / maxHp, 0, 1), 10);
    71. float animationValue = (float) animation.getOutput();
    72. GlStateManager.pushMatrix();
    73. Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();
    74. sizeAnimation(posX + (width / 2), posY + (height / 2), animation.getOutput());
    75. drawStyledRect(posX, posY, width, height, rounding, 230);
    76. // KaTrec
    77. DisplayUtils.drawRoundedRectOutline(posX, posY, width, height, rounding, 2, ColorUtils.rgb(128, 0, 128));
    78. Stencil.initStencilToWrite();
    79. DisplayUtils.drawRoundedRect(posX + spacing, posY + spacing, headSize, headSize, 8, ColorUtils.rgba(25, 26, 40, 165));
    80. Stencil.readStencilBuffer(1);
    81. drawTargetHead(entity, posX + spacing, posY + spacing, headSize, headSize);
    82. Stencil.uninitStencilBuffer();
    83. // Текст анимация
    84. textAnimation.setDirection(hp < maxHp / 2 ? Direction.FORWARDS : Direction.BACKWARDS);
    85. float textAnimValue = (float) textAnimation.getOutput();
    86. // Победа/Проигрыш
    87. String resultText = hp >= maxHp ? "Проигрыш" : "Победа";
    88. int resultColor = hp >= maxHp ? ColorUtils.rgb(255, 0, 0) : ColorUtils.rgb(0, 255, 0);
    89. Scissor.push();
    90. Fonts.sfui.drawText(eventDisplay.getMatrixStack(), name, posX + headSize + spacing * 2, posY + 10, -1, 12);
    91. Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), "HP: " + (int) hp + " / " + (int) maxHp, posX + headSize + spacing * 2, posY + 30, ColorUtils.rgb(255, 255, 255), 9);
    92. Fonts.sfMedium.drawText(eventDisplay.getMatrixStack(), resultText, posX + width / 2, posY + height - 20 + textAnimValue * 10, resultColor, 12);
    93. Scissor.pop();
    94. Vector4i gradientColor = new Vector4i(style.getFirstColor().getRGB(), style.getFirstColor().getRGB(), style.getSecondColor().getRGB(), style.getSecondColor().getRGB());
    95. DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, width - headSize - spacing * 3, 5, new Vector4f(3, 3, 3, 3), ColorUtils.rgb(50, 50, 50));
    96. DisplayUtils.drawRoundedRect(posX + headSize + spacing * 2, posY + height - 15, (width - headSize - spacing * 3) * healthAnimation, 5, new Vector4f(3, 3, 3, 3), gradientColor);
    97. GlStateManager.popMatrix();
    98. }
    99. }
    100. private boolean isCustomServer() {
    101. String serverIP = mc.getCurrentServerData() != null ? mc.getCurrentServerData().serverIP : "";
    102. String header = mc.ingameGUI.getTabList().header != null ? mc.ingameGUI.getTabList().header.getString().toLowerCase() : "";
    103. return (serverIP.contains("reallyworld") || serverIP.contains("funtime")) && (header.contains("анархия") || header.contains("гриф"));
    104. }
    105. private LivingEntity getTarget(LivingEntity nullTarget) {
    106. LivingEntity auraTarget = Expensive.getInstance().getFunctionRegistry().getKillAura().getTarget();
    107. LivingEntity target = nullTarget;
    108. if (auraTarget != null) {
    109. stopWatch.reset();
    110. allow = true;
    111. target = auraTarget;
    112. } else if (mc.currentScreen instanceof ChatScreen) {
    113. stopWatch.reset();
    114. allow = true;
    115. target = mc.player;
    116. } else {
    117. allow = false;
    118. }
    119. return target;
    120. }
    121. public void drawTargetHead(LivingEntity entity, float x, float y, float width, float height) {
    122. if (entity != null) {
    123. EntityRenderer<? super LivingEntity> rendererManager = mc.getRenderManager().getRenderer(entity);
    124. drawFace(rendererManager.getEntityTexture(entity), x, y, 8F, 8F, 8F, 8F, width, height, 64F, 64F, entity);
    125. }
    126. }
    127. public static void sizeAnimation(double width, double height, double scale) {
    128. GlStateManager.translated(width, height, 0);
    129. GlStateManager.scaled(scale, scale, scale);
    130. GlStateManager.translated(-width, -height, 0);
    131. }
    132. public void drawFace(ResourceLocation res, float d, float y, float u, float v, float uWidth, float vHeight, float width, float height, float tileWidth, float tileHeight, LivingEntity target) {
    133. GL11.glPushMatrix();
    134. GL11.glEnable(GL11.GL_BLEND);
    135. mc.getTextureManager().bindTexture(res);
    136. float hurtPercent = (target.hurtTime - (target.hurtTime != 0 ? mc.timer.renderPartialTicks : 0.0f)) / 10.0f;
    137. GL11.glColor4f(1, 1 - hurtPercent, 1 - hurtPercent, 1);
    138. AbstractGui.drawScaledCustomSizeModalRect(d, y, u, v, uWidth, vHeight, width, height, tileWidth, tileHeight);
    139. GL11.glColor4f(1, 1, 1, 1);
    140. GL11.glPopMatrix();
    141. }
    142. private void drawStyledRect(float x, float y, float width, float height, float radius, int alpha) {
    143. DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgba(21, 21, 21, alpha));
    144. DisplayUtils.drawShadow(x + 5, y + 5, width, height, 5, ColorUtils.rgba(10, 15, 13, 15));
    145. }
    146. }
/del
 
Сверху Снизу