Начинающий
- Статус
- Оффлайн
- Регистрация
- 26 Сен 2024
- Сообщения
- 15
- Реакции
- 1
- Выберите загрузчик игры
- Прочие моды
Всем привет! Это моя первая тема, так-что не судите строго. Призраки более менее годные, странно, что такое еще не сливали
Code:
Пожалуйста, авторизуйтесь для просмотра ссылки.
Code:
TargetEsp.java:
package im.warners.modules.impl.render;
import static com.mojang.blaze3d.platform.GlStateManager.GL_QUADS;
import static net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_COLOR_TEX;
import static net.minecraft.util.math.MathHelper.cos;
import static net.minecraft.util.math.MathHelper.sin;
import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import im.warners.events.*;
import im.warners.modules.impl.combat.KillAura;
import im.warners.modules.impl.combat.TriggerBot;
import im.warners.utils.math.MathUtil;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.util.math.vector.Quaternion;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import im.warners.events.EventDisplay.Type;
import im.warners.modules.api.Category;
import im.warners.modules.api.Module;
import im.warners.modules.api.ModuleRegister;
import im.warners.modules.settings.impl.ModeSetting;
import im.warners.modules.settings.impl.SliderSetting;
import im.warners.utils.math.Vector4i;
import im.warners.utils.projections.ProjectionUtil;
import im.warners.utils.render.color.ColorUtils;
import im.warners.utils.render.rect.DisplayUtils;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import im.warners.utils.animations.*;
import im.warners.utils.animations.impl.*;
import net.minecraft.util.math.MathHelper;
/**
* Created by WarnersBust (warners)
*/
@ModuleRegister(name = "TargetESP", description = "Рисует метку на цели", category = Category.Render)
public class TargetESP extends Module {
public ModeSetting mode = new ModeSetting("Мод", "Маркер", "Маркер", "Призраки");
private final ModeSetting colorMode = new ModeSetting("Цвет", "Тема", "Тема", "Белый");
private final Animation alpha = new DecelerateAnimation(1000, 255);
private final Animation[] ghostAlphas = new Animation[50];
private final KillAura killAura;
private final TriggerBot triggerBot;
private LivingEntity currentTarget;
private LivingEntity lastTriggerBotTarget;
private long lastTriggerBotTargetTime = 0;
private static final long TARGET_TIMEOUT = 10000;
private static final double MAX_DISTANCE = 5.0;
private static long startTime = System.currentTimeMillis();
private final ModeSetting animationMode = new ModeSetting(
"Анимация", "Души", "Души", "Кольцо"
).setVisible(() -> mode.is("Призраки"));
private final SliderSetting ghostsSize = new SliderSetting(
"Размер призраков", 0.32f, 0.1f, 1.0f, 0.1f
).setVisible(() -> mode.is("Призраки") && animationMode.is("Души"));
private final SliderSetting ghostsSpeed = new SliderSetting(
"Скорость призраков", 27.0f, 10.0f, 50.0f, 1.0f
).setVisible(() -> mode.is("Призраки") && animationMode.is("Души"));
private final SliderSetting ghostsLength = new SliderSetting(
"Длина хвоста", 25.0f, 10.0f, 50.0f, 1.0f
).setVisible(() -> mode.is("Призраки") && animationMode.is("Души"));
private final SliderSetting ghostsAlphaFactor = new SliderSetting(
"Прозрачность хвоста", 15.0f, 5.0f, 30.0f, 1.0f
).setVisible(() -> mode.is("Призраки") && animationMode.is("Души"));
public TargetESP(KillAura killAura, TriggerBot triggerBot) {
this.killAura = killAura;
this.triggerBot = triggerBot;
addSettings(mode, colorMode, animationMode, ghostsSize, ghostsSpeed, ghostsLength, ghostsAlphaFactor);
for (int i = 0; i < ghostAlphas.length; i++) {
ghostAlphas[i] = new DecelerateAnimation(1000, 255);
}
}
private int getColor() {
if (colorMode.is("Белый")) {
return ColorUtils.rgb(255, 255, 255);
} else {
return Theme.mainRectColor;
}
}
@Subscribe
private void onUpdate(EventUpdate e) {
LivingEntity triggerBotTarget = triggerBot.getCurrentTarget();
LivingEntity killAuraTarget = killAura != null ? killAura.getTarget() : null;
if (triggerBotTarget != null) {
currentTarget = triggerBotTarget;
lastTriggerBotTarget = triggerBotTarget;
lastTriggerBotTargetTime = System.currentTimeMillis();
} else if (killAuraTarget != null) {
currentTarget = killAuraTarget;
lastTriggerBotTarget = null;
} else {
long currentTime = System.currentTimeMillis();
boolean shouldKeepTriggerBotTarget = false;
if (lastTriggerBotTarget != null && lastTriggerBotTarget.isAlive()) {
double distanceToLastTarget = mc.player.getDistance(lastTriggerBotTarget);
boolean isWithinDistance = distanceToLastTarget <= MAX_DISTANCE;
boolean isWithinTime = (currentTime - lastTriggerBotTargetTime) <= TARGET_TIMEOUT;
shouldKeepTriggerBotTarget = isWithinDistance || isWithinTime;
}
if (shouldKeepTriggerBotTarget) {
currentTarget = lastTriggerBotTarget;
} else {
currentTarget = null;
lastTriggerBotTarget = null;
}
}
if (!isState() || currentTarget == null) {
alpha.setDuration(0);
for (Animation ghostAlpha : ghostAlphas) {
ghostAlpha.setDuration(0);
}
} else {
alpha.setDirection(Direction.FORWARDS);
for (Animation ghostAlpha : ghostAlphas) {
ghostAlpha.setDirection(Direction.FORWARDS);
}
}
}
@Subscribe
public void onRender(DEngineEvent e) {
if (!isState() || currentTarget == null || alpha.getOutput() == 0 || !mode.is("Призраки")) {
return;
}
MatrixStack matrix = e.getMatrix();
boolean light = GL11.glIsEnabled(GL11.GL_LIGHTING);
RenderSystem.pushMatrix();
matrix.push();
RenderSystem.enableBlend();
RenderSystem.disableAlphaTest();
RenderSystem.depthMask(false);
RenderSystem.disableCull();
if (animationMode.is("Души")) {
RenderSystem.disableDepthTest();
}
if (light)
RenderSystem.disableLighting();
GL11.glShadeModel(GL11.GL_SMOOTH);
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
renderGhosts(matrix);
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.clearCurrentColor();
GL11.glShadeModel(GL11.GL_FLAT);
RenderSystem.enableDepthTest();
if (light)
RenderSystem.enableLighting();
RenderSystem.enableCull();
RenderSystem.depthMask(true);
RenderSystem.enableAlphaTest();
matrix.pop();
RenderSystem.popMatrix();
}
@Subscribe
private void onDisplay(EventDisplay display) {
if (!isState() || alpha.getOutput() == 0 || !mode.is("Маркер")) {
return;
}
if (display.getType() != Type.PRE) {
return;
}
if (this.currentTarget != null && this.currentTarget != mc.player) {
double sin = Math.sin(System.currentTimeMillis() / 1000.0);
double distance = mc.player.getDistance(currentTarget);
float maxSize = (float) getScale(currentTarget.getPositionVec(), 18);
float size = Math.max(maxSize - (float) distance, 20.0F);
Vector3d interpolated = MathUtil.interpolate(currentTarget.getPositionVec(),
new Vector3d(currentTarget.lastTickPosX, currentTarget.lastTickPosY, currentTarget.lastTickPosZ),
display.getPartialTicks());
Vector2f pos = ProjectionUtil.project(interpolated.x, interpolated.y + currentTarget.getHeight() / 2f, interpolated.z);
GlStateManager.pushMatrix();
GlStateManager.translatef(pos.x, pos.y, 0);
GlStateManager.rotatef((float) sin * 360, 0, 0, 1);
GlStateManager.translatef(-pos.x, -pos.y, 0);
if (pos != null) {
int color = getColor();
DisplayUtils.drawImageAlpha(new ResourceLocation("warners/images/target.png"),
pos.x - size / 2f, pos.y - size / 2f, size, size, new Vector4i(
ColorUtils.setAlpha(color, (int) (alpha.getOutput())),
ColorUtils.setAlpha(color, (int) (alpha.getOutput())),
ColorUtils.setAlpha(color, (int) (alpha.getOutput())),
ColorUtils.setAlpha(color, (int) (alpha.getOutput()))
));
}
GlStateManager.popMatrix();
}
}
private void renderGhosts(MatrixStack ms) {
if (this.currentTarget != null && this.currentTarget != mc.player) {
ms.push();
ActiveRenderInfo camera = mc.getRenderManager().info;
ms.translate(-camera.getProjectedView().getX(),
-camera.getProjectedView().getY(),
-camera.getProjectedView().getZ());
Vector3d interpolated = MathUtil.interpolate(currentTarget.getPositionVec(),
new Vector3d(currentTarget.lastTickPosX, currentTarget.lastTickPosY, currentTarget.lastTickPosZ),
mc.getRenderPartialTicks());
interpolated = new Vector3d(interpolated.x, interpolated.y + 0.8f, interpolated.z);
ms.translate(interpolated.x + 0.2f, interpolated.y + 0.5f, interpolated.z);
mc.getTextureManager().bindTexture(new ResourceLocation("warners/images/glow.png"));
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
double x = currentTarget.getPosX();
double y = currentTarget.getPosY() + currentTarget.getHeight() / 2f;
double z = currentTarget.getPosZ();
if (animationMode.is("Кольцо")) {
renderRingAnimation(ms, buffer, camera);
} else {
renderWarnersAnimation(ms, buffer, camera);
}
ms.translate(-x, -y, -z);
ms.pop();
}
}
private void renderRingAnimation(MatrixStack ms, BufferBuilder buffer, ActiveRenderInfo camera) {
float size = 0.4f;
int length = 33;
int maxAlpha = 255;
int alphaFactor = 5;
int baseColor = getColor();
float radius = 0.5f;
float rotationSpeed = 5.0f;
float verticalSpeed = 0.4f;
long currentTime = System.currentTimeMillis() - startTime;
for (int ghostIndex = 0; ghostIndex < 2; ghostIndex++) {
float phaseOffset = ghostIndex * (float) Math.PI;
for (int i = length - 1; i >= 0; i--) {
Quaternion r = camera.getRotation().copy();
buffer.begin(GL_QUADS, POSITION_COLOR_TEX);
double time = (currentTime - (i * 15L)) / 1000.0;
double angle = (time * rotationSpeed) + phaseOffset;
double verticalProgress = getPingPongProgress(time * verticalSpeed);
double verticalOffset = (verticalProgress - 0.5) * 1.1;
double xOffset = cos((float) angle) * radius;
double zOffset = sin((float) angle) * radius;
ms.translate(xOffset, verticalOffset, zOffset);
ms.translate(-size / 2f, -size / 2f, 0);
ms.rotate(r);
ms.translate(size / 2f, size / 2f, 0);
int alpha = MathHelper.clamp(maxAlpha - ((length - 1 - i) * alphaFactor), 0, maxAlpha);
int colorWithAlpha = ColorUtils.setAlpha(baseColor, (int) (alpha * (i < ghostAlphas.length ? ghostAlphas[i].getOutput() : alpha)));
buffer.pos(ms.getLast().getMatrix(), 0, -size, 0).color(colorWithAlpha).tex(0, 0).endVertex();
buffer.pos(ms.getLast().getMatrix(), -size, -size, 0).color(colorWithAlpha).tex(0, 1).endVertex();
buffer.pos(ms.getLast().getMatrix(), -size, 0, 0).color(colorWithAlpha).tex(1, 1).endVertex();
buffer.pos(ms.getLast().getMatrix(), 0, 0, 0).color(colorWithAlpha).tex(1, 0).endVertex();
Tessellator.getInstance().draw();
ms.translate(-size / 2f, -size / 2f, 0);
r.conjugate();
ms.rotate(r);
ms.translate(size / 2f, size / 2f, 0);
ms.translate(-xOffset, -verticalOffset, -zOffset);
}
}
}
private void renderWarnersAnimation(MatrixStack ms, BufferBuilder buffer, ActiveRenderInfo camera) {
double radius = 0.6f;
float speed = ghostsSpeed.get();
float size = ghostsSize.get();
double distance = 15;
int length = ghostsLength.get().intValue();
int maxAlpha = 255;
int alphaFactor = ghostsAlphaFactor.get().intValue();
int baseColor = getColor();
renderGhostStream(ms, buffer, camera, size, length, radius, speed, distance, maxAlpha, alphaFactor, 1, 1, -1, baseColor);
renderGhostStream(ms, buffer, camera, size, length, radius, speed, distance, maxAlpha, alphaFactor, -1, 1, -1, baseColor);
renderGhostStream(ms, buffer, camera, size, length, radius, speed, distance, maxAlpha, alphaFactor, -1, -1, 1, baseColor);
}
private void renderGhostStream(MatrixStack ms, BufferBuilder buffer, ActiveRenderInfo camera,
float size, int length, double radius, float speed,
double distance, int maxAlpha, int alphaFactor,
int xMod, int yMod, int zMod, int baseColor) {
for (int i = length - 1; i >= 0; i--) {
Quaternion r = camera.getRotation().copy();
buffer.begin(GL_QUADS, POSITION_COLOR_TEX);
double angle = 0.15f * (System.currentTimeMillis() - startTime - (i * distance)) / speed;
double s = -sin(angle) * radius;
double c = -cos(angle) * radius;
ms.translate(xMod * s, yMod * (xMod == zMod ? c : s), zMod * -c);
ms.translate(-size / 2f, -size / 2f, 0);
ms.rotate(r);
ms.translate(size / 2f, size / 2f, 0);
int alpha = MathHelper.clamp(maxAlpha - ((length - 1 - i) * alphaFactor), 0, maxAlpha);
int colorWithAlpha = ColorUtils.setAlpha(baseColor, (int) (alpha * (i < ghostAlphas.length ? ghostAlphas[i].getOutput() : alpha)));
buffer.pos(ms.getLast().getMatrix(), 0, -size, 0).color(colorWithAlpha).tex(0, 0).endVertex();
buffer.pos(ms.getLast().getMatrix(), -size, -size, 0).color(colorWithAlpha).tex(0, 1).endVertex();
buffer.pos(ms.getLast().getMatrix(), -size, 0, 0).color(colorWithAlpha).tex(1, 1).endVertex();
buffer.pos(ms.getLast().getMatrix(), 0, 0, 0).color(colorWithAlpha).tex(1, 0).endVertex();
Tessellator.getInstance().draw();
ms.translate(-size / 2f, -size / 2f, 0);
r.conjugate();
ms.rotate(r);
ms.translate(size / 2f, size / 2f, 0);
ms.translate(xMod * -s, yMod * -(xMod == zMod ? c : s), zMod * c);
}
}
private double getPingPongProgress(double time) {
double pingPong = sin(time * Math.PI);
return (pingPong + 1) / 2;
}
public double getScale(Vector3d position, double size) {
Vector3d cam = mc.getRenderManager().info.getProjectedView();
double distance = cam.distanceTo(position);
double fov = mc.gameRenderer.getFOVModifier(mc.getRenderManager().info, mc.getRenderPartialTicks(), true);
return Math.max(10f, 1000 / distance) * (size / 30f) / (fov == 70 ? 1 : fov / 70.0f);
}
}