Начинающий
- Статус
- Оффлайн
- Регистрация
- 27 Окт 2024
- Сообщения
- 59
- Реакции
- 3
- Выберите загрузчик игры
- Fabric
добрый день добрый вечер доброе утро.
на моём диске заволялся очень красивые визуалы вот я вам и сливаю
ss-
на моём диске заволялся очень красивые визуалы вот я вам и сливаю
ss-
wawplayer:
package dev.client.modules.core.render;
import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.systems.RenderSystem;
import dev.client.api.nullcry.events.core.game.TickEvent;
import dev.client.api.nullcry.events.core.render.RenderEvent;
import dev.client.api.nullcry.modules.Module;
import dev.client.api.nullcry.modules.ModuleCategory;
import dev.client.api.nullcry.modules.settings.ColorPicker;
import dev.client.api.nullcry.modules.settings.ModeElement;
import dev.client.api.nullcry.modules.settings.Slider;
import dev.client.api.nullcry.render.core.DrawUtil;
import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import org.joml.Matrix4f;
import java.awt.*;
import java.util.concurrent.CopyOnWriteArrayList;
public class Shadow extends Module {
public static Shadow INSTANCE;
public Shadow() {
super("Shadow", ModuleCategory.Visuals, "Отображает призрачные копии в прошлых позициях");
INSTANCE = this;
}
Slider interval = new Slider("Интервал (тики)", () -> true)
.set(10, 100, 5)
.defaultValue(40)
.register(this);
Slider maxShadows = new Slider("Максимум теней", () -> true)
.set(1, 10, 1)
.defaultValue(5)
.register(this);
Slider fadeTime = new Slider("Время затухания (сек)", () -> true)
.set(1, 10, 1)
.defaultValue(3)
.register(this);
ModeElement colorMode = new ModeElement("Режим цвета", () -> true)
.set("Клиентский", "Кастомный", "Радужный")
.defaultValue("Клиентский")
.register(this);
ColorPicker customColor = new ColorPicker("Цвет", () -> colorMode.isSelected("Кастомный"))
.set(new Color(0, 255, 0, 200).getRGB())
.defaultValue(new Color(0, 255, 0, 200).getRGB())
.register(this);
private final CopyOnWriteArrayList<ShadowData> shadows = new CopyOnWriteArrayList<>();
private int tickCounter = 0;
private Vec3d lastPos = null;
@Subscribe
public void onTick(TickEvent event) {
if (mc.player == null) return;
Vec3d currentPos = mc.player.getPos();
boolean isMoving = lastPos == null || currentPos.distanceTo(lastPos) > 0.01;
tickCounter++;
if (tickCounter >= interval.getValue().intValue() && isMoving) {
tickCounter = 0;
float yaw = mc.player.getYaw();
float pitch = mc.player.getPitch();
float bodyYaw = mc.player.bodyYaw;
float limbAngle = mc.player.limbAnimator.getPos();
float limbDistance = mc.player.limbAnimator.getSpeed();
shadows.add(new ShadowData(currentPos, yaw, pitch, bodyYaw, limbAngle, limbDistance, System.currentTimeMillis()));
while (shadows.size() > maxShadows.getValue().intValue()) {
shadows.remove(0);
}
}
lastPos = currentPos;
long fadeTimeMs = fadeTime.getValue().intValue() * 1000L;
shadows.removeIf(shadow -> System.currentTimeMillis() - shadow.time > fadeTimeMs);
}
@Subscribe
public void onRender3D(RenderEvent.Draw3D event) {
if (mc.player == null || shadows.isEmpty()) return;
if (mc.options.getPerspective().isFirstPerson()) {
return;
}
MatrixStack matrices = event.getMatrices();
Camera camera = mc.getEntityRenderDispatcher().camera;
long fadeTimeMs = fadeTime.getValue().intValue() * 1000L;
matrices.push();
DrawUtil.setupRender();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.disableCull();
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
boolean hasDrawn = false;
for (ShadowData shadow : shadows) {
float progress = (System.currentTimeMillis() - shadow.time) / (float) fadeTimeMs;
if (progress > 1.0f) continue;
float alpha = 1.0f - (progress * progress);
Color color = getShadowColor(progress);
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
int a = (int) (alpha * 255);
Vec3d cameraPos = camera.getPos();
double x = shadow.pos.x - cameraPos.x;
double y = shadow.pos.y - cameraPos.y;
double z = shadow.pos.z - cameraPos.z;
matrices.push();
matrices.translate(x, y, z);
matrices.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(0, 1, 0, -shadow.bodyYaw));
float limbSwing = shadow.limbAngle;
float limbSwingAmount = shadow.limbDistance;
limbSwingAmount = Math.min(limbSwingAmount, 1.0f);
float rightArmAngle = (float) (Math.cos(limbSwing * 0.6662f) * 2.0f * limbSwingAmount * 0.5f);
float leftArmAngle = (float) (Math.cos(limbSwing * 0.6662f + Math.PI) * 2.0f * limbSwingAmount * 0.5f);
float rightLegAngle = (float) (Math.cos(limbSwing * 0.6662f + Math.PI) * 1.4f * limbSwingAmount * 0.5f);
float leftLegAngle = (float) (Math.cos(limbSwing * 0.6662f) * 1.4f * limbSwingAmount * 0.5f);
matrices.push();
matrices.translate(0, 1.5, 0);
float headYaw = shadow.yaw - shadow.bodyYaw;
matrices.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(0, 1, 0, -headYaw));
matrices.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(1, 0, 0, shadow.pitch));
Matrix4f matrix = matrices.peek().getPositionMatrix();
drawPlayerPart(bufferBuilder, matrix, 0, 0, 0, 0.5, 0.5, 0.5, r, g, b, a);
matrices.pop();
matrices.push();
matrix = matrices.peek().getPositionMatrix();
drawPlayerPart(bufferBuilder, matrix, 0, 0.75, 0, 0.5, 0.75, 0.25, r, g, b, a);
matrices.pop();
matrices.push();
matrices.translate(-0.375, 1.5, 0);
matrices.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(1, 0, 0, (float) Math.toDegrees(rightArmAngle)));
matrix = matrices.peek().getPositionMatrix();
drawPlayerPartLocal(bufferBuilder, matrix, 0, -0.75, 0, 0.25, 0.75, 0.25, r, g, b, a);
matrices.pop();
matrices.push();
matrices.translate(0.375, 1.5, 0);
matrices.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(1, 0, 0, (float) Math.toDegrees(leftArmAngle)));
matrix = matrices.peek().getPositionMatrix();
drawPlayerPartLocal(bufferBuilder, matrix, 0, -0.75, 0, 0.25, 0.75, 0.25, r, g, b, a);
matrices.pop();
matrices.push();
matrices.translate(-0.125, 0.75, 0);
matrices.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(1, 0, 0, (float) Math.toDegrees(rightLegAngle)));
matrix = matrices.peek().getPositionMatrix();
drawPlayerPartLocal(bufferBuilder, matrix, 0, -0.75, 0, 0.25, 0.75, 0.25, r, g, b, a);
matrices.pop();
matrices.push();
matrices.translate(0.125, 0.75, 0);
matrices.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(1, 0, 0, (float) Math.toDegrees(leftLegAngle)));
matrix = matrices.peek().getPositionMatrix();
drawPlayerPartLocal(bufferBuilder, matrix, 0, -0.75, 0, 0.25, 0.75, 0.25, r, g, b, a);
matrices.pop();
matrices.pop();
hasDrawn = true;
}
if (hasDrawn) {
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
}
RenderSystem.enableCull();
RenderSystem.disableBlend();
DrawUtil.endRender();
matrices.pop();
}
private Color getShadowColor(float progress) {
if (colorMode.isSelected("Радужный")) {
float hue = (System.currentTimeMillis() % 3000) / 3000.0f;
return Color.getHSBColor(hue, 1.0f, 1.0f);
} else if (colorMode.isSelected("Клиентский")) {
return new Color(Interface.INSTANCE.getMainColor(), true);
} else {
return new Color(customColor.getColorRGBA(), true);
}
}
private void drawPlayerPart(BufferBuilder bufferBuilder, Matrix4f matrix, double x, double y, double z, double width, double height, double depth, int r, int g, int b, int a) {
Box box = new Box(
x - width / 2, y, z - depth / 2,
x + width / 2, y + height, z + depth / 2
);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
}
private void drawPlayerPartLocal(BufferBuilder bufferBuilder, Matrix4f matrix, double x, double y, double z, double width, double height, double depth, int r, int g, int b, int a) {
Box box = new Box(
x - width / 2, y, z - depth / 2,
x + width / 2, y + height, z + depth / 2
);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.minZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.maxZ).color(r, g, b, a);
bufferBuilder.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.maxZ).color(r, g, b, a);
}
@Override
public void onDisabled() {
shadows.clear();
tickCounter = 0;
lastPos = null;
}
private static class ShadowData {
private final Vec3d pos;
private final float yaw;
private final float pitch;
private final float bodyYaw;
private final float limbAngle;
private final float limbDistance;
private final long time;
public ShadowData(Vec3d pos, float yaw, float pitch, float bodyYaw, float limbAngle, float limbDistance, long time) {
this.pos = pos;
this.yaw = yaw;
this.pitch = pitch;
this.bodyYaw = bodyYaw;
this.limbAngle = limbAngle;
this.limbDistance = limbDistance;
this.time = time;
}
}
}
Последнее редактирование: