Начинающий
- Статус
- Оффлайн
- Регистрация
- 2 Мар 2024
- Сообщения
- 310
- Реакции
- 5
- Выберите загрузчик игры
- Fabric
клод солюшен:
package sweetie.evaware.client.features.modules.render.targetesp.modes;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.RotationAxis;
import org.joml.Matrix4f;
import sweetie.evaware.api.event.events.render.Render3DEvent;
import sweetie.evaware.api.system.files.FileUtil;
import sweetie.evaware.api.utils.color.ColorUtil;
import sweetie.evaware.api.utils.color.UIColors;
import sweetie.evaware.api.utils.render.RenderUtil;
import sweetie.evaware.client.features.modules.render.targetesp.TargetEspMode;
import sweetie.evaware.client.features.modules.render.targetesp.TargetEspModule;
public class TargetEspChain extends TargetEspMode {
private float chainRotationAngle = 0f;
private float prevChainRotationAngle = 0f;
@Override
public void onUpdate() {
updateTarget();
prevChainRotationAngle = chainRotationAngle;
float speed = TargetEspModule.getInstance().getChainSpeed().getValue();
chainRotationAngle += speed;
}
@Override
public void onRender3D(Render3DEvent.Render3DEventData event) {
if (currentTarget == null || !canDraw()) return;
MatrixStack matrixStack = event.matrixStack();
RenderUtil.WORLD.startRender(matrixStack);
double centerX = getTargetX();
double centerY = getTargetY() + currentTarget.getHeight() / 2;
double centerZ = getTargetZ();
Camera camera = mc.getEntityRenderDispatcher().camera;
double renderX = centerX - camera.getPos().getX();
double renderY = centerY - camera.getPos().getY();
double renderZ = centerZ - camera.getPos().getZ();
float partialTicks = event.partialTicks();
renderСhain(matrixStack, renderX, renderY, renderZ, 0, partialTicks);
renderСhain(matrixStack, renderX, renderY, renderZ, 90, partialTicks);
RenderSystem.enableCull();
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderUtil.WORLD.endRender(matrixStack);
}
private void renderСhain(MatrixStack stack, double x, double y, double z, float offsetAngle, float partialTicks) {
stack.push();
stack.translate(x, y, z);
float currentAngle = prevChainRotationAngle + (chainRotationAngle - prevChainRotationAngle) * partialTicks;
stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(currentAngle + offsetAngle));
stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(currentAngle + offsetAngle));
float widthMultiplier = TargetEspModule.getInstance().getChainWidth().getValue();
float radius = currentTarget.getWidth() * widthMultiplier;
int segments = 60;
RenderSystem.setShaderTexture(0, FileUtil.getImage("target/chain"));
Matrix4f matrix = stack.peek().getPositionMatrix();
RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
BufferBuilder buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
float textureRepeat = 4.0f;
float heightMultiplier = TargetEspModule.getInstance().getChainHeight().getValue();
float halfHeight = heightMultiplier / 2;
for (int i = 0; i < segments; i++) {
float angle1 = (float) (2 * Math.PI * i / segments);
float angle2 = (float) (2 * Math.PI * (i + 1) / segments);
float x1 = (float) (Math.cos(angle1) * radius);
float z1 = (float) (Math.sin(angle1) * radius);
float x2 = (float) (Math.cos(angle2) * radius);
float z2 = (float) (Math.sin(angle2) * radius);
float u1 = (float) i / segments * textureRepeat;
float u2 = (float) (i + 1) / segments * textureRepeat;
float[] c = ColorUtil.normalize(ColorUtil.setAlpha(UIColors.gradient((int) (i * 6 + offsetAngle)), (int) (255 * showAnimation.getValue())));
buffer.vertex(matrix, x1, -halfHeight, z1).texture(u1, 1f).color(c[0], c[1], c[2], c[3]);
buffer.vertex(matrix, x2, -halfHeight, z2).texture(u2, 1f).color(c[0], c[1], c[2], c[3]);
buffer.vertex(matrix, x2, halfHeight, z2).texture(u2, 0f).color(c[0], c[1], c[2], c[3]);
buffer.vertex(matrix, x1, halfHeight, z1).texture(u1, 0f).color(c[0], c[1], c[2], c[3]);
}
for (int i = 0; i < segments; i++) {
float angle1 = (float) (2 * Math.PI * i / segments);
float angle2 = (float) (2 * Math.PI * (i + 1) / segments);
float x1 = (float) (Math.cos(angle1) * radius);
float z1 = (float) (Math.sin(angle1) * radius);
float x2 = (float) (Math.cos(angle2) * radius);
float z2 = (float) (Math.sin(angle2) * radius);
float u1 = (float) i / segments * textureRepeat;
float u2 = (float) (i + 1) / segments * textureRepeat;
float[] c = ColorUtil.normalize(ColorUtil.setAlpha(UIColors.gradient((int) (i * 6 + offsetAngle)), (int) (255 * showAnimation.getValue())));
buffer.vertex(matrix, x1, halfHeight, z1).texture(u1, 0f).color(c[0], c[1], c[2], c[3]);
buffer.vertex(matrix, x2, halfHeight, z2).texture(u2, 0f).color(c[0], c[1], c[2], c[3]);
buffer.vertex(matrix, x2, -halfHeight, z2).texture(u2, 1f).color(c[0], c[1], c[2], c[3]);
buffer.vertex(matrix, x1, -halfHeight, z1).texture(u1, 1f).color(c[0], c[1], c[2], c[3]);
}
BufferRenderer.drawWithGlobalProgram(buffer.end());
stack.pop();
}
}
