Начинающий
- Статус
- Оффлайн
- Регистрация
- 9 Мар 2025
- Сообщения
- 145
- Реакции
- 9
- Выберите загрузчик игры
- Fabric
gosts2:
public static void drawGhosts2(LivingEntity lastTarget, float anim, float red, float speed, MatrixStack passedMatrix, float tickDelta) {
if (lastTarget == null || anim <= 0.01f) return;
if (ghostPhysics.isEmpty()) initGhosts();
MinecraftClient mc = MinecraftClient.getInstance();
Camera camera = mc.gameRenderer.getCamera();
Vec3d cameraPos = camera.getPos();
double targetX = MathHelper.lerp(tickDelta, lastTarget.lastRenderX, lastTarget.getX());
double targetY = MathHelper.lerp(tickDelta, lastTarget.lastRenderY, lastTarget.getY());
double targetZ = MathHelper.lerp(tickDelta, lastTarget.lastRenderZ, lastTarget.getZ());
targetY += lastTarget.getHeight() / 2.0D;
long currentTime = System.currentTimeMillis();
if (lastGhostUpdateTimestamp == 0) {
lastGhostUpdateTimestamp = currentTime;
lastTrailUpdateTime = currentTime;
}
long deltaTime = currentTime - lastGhostUpdateTimestamp;
lastGhostUpdateTimestamp = currentTime;
float rotationSpeed = (deltaTime * 0.003f) * speed;
float baseSize = 0.20f;
float radius = 0.45f;
float verticalAmp = 0.4f;
int maxTrailSize = 20;
for (int i = 0; i < ghostPhysics.size(); i++) {
GhostPhysics ghost = ghostPhysics.get(i);
float direction = (i % 2 == 0) ? 1f : -1f; // Разные стороны или в одну, можно убрать условие если хочешь синхронно
ghost.angle += rotationSpeed; // Постоянное вращение
float offset = (float) (i * (Math.PI * 2 / 3));
float currentAngle = ghost.angle + offset;
double orbitX = Math.sin(currentAngle) * radius;
double orbitZ = Math.cos(currentAngle) * radius;
double waveY = Math.sin(currentAngle * 2.0) * verticalAmp;
ghost.position = new Vec3d(
targetX + orbitX,
targetY + waveY, // Двигаемся и по Y
targetZ + orbitZ // И по Z/X
);
}
long trailInterval = 30;
if (currentTime - lastTrailUpdateTime >= trailInterval) {
lastTrailUpdateTime = currentTime;
for (GhostPhysics ghost : ghostPhysics) {
if (!ghost.positionHistory.isEmpty() && ghost.position.squaredDistanceTo(ghost.positionHistory.get(0)) > 10.0) {
ghost.positionHistory.clear();
}
ghost.positionHistory.add(0, ghost.position);
while (ghost.positionHistory.size() > maxTrailSize) {
ghost.positionHistory.remove(ghost.positionHistory.size() - 1);
}
}
}
int color1 = Javelin.getInstance().getThemeManager().getCurrentTheme().getColor().getRGB();
int color2 = Javelin.getInstance().getThemeManager().getCurrentTheme().getColor().getRGB();
RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
RenderSystem.setShaderTexture(0, bloom);
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(
GlStateManager.SrcFactor.SRC_ALPHA,
GlStateManager.DstFactor.ONE,
GlStateManager.SrcFactor.ZERO,
GlStateManager.DstFactor.ONE
);
RenderSystem.disableCull();
RenderSystem.disableDepthTest();
RenderSystem.depthMask(false);
BufferBuilder builder = Tessellator.getInstance().begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
MatrixStack stack = passedMatrix;
for (GhostPhysics ghost : ghostPhysics) {
for (int i = ghost.positionHistory.size() - 1; i >= 0; i--) {
Vec3d pos = ghost.positionHistory.get(i);
renderGhostPart(builder, stack, camera, cameraPos, pos, i, ghost.positionHistory.size(), anim, baseSize, red, color1, color2);
}
renderGhostPart(builder, stack, camera, cameraPos, ghost.position, 0, 1, anim, baseSize, red, color1, color2);
}
BufferRenderer.drawWithGlobalProgram(builder.end());
RenderSystem.setShaderTexture(0, 0);
RenderSystem.enableDepthTest();
RenderSystem.depthMask(true);
RenderSystem.disableBlend();
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.enableCull();
}
SS:
SS-2 video:
Пожалуйста, авторизуйтесь для просмотра ссылки.