XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

MyDimension-Lord

【我的世界】我的维度附属模组:维度之主

公开
关注 0 Fork 0 Star 0
UTF-8
package com.xfestudio.mydimensionlord.equipment;

import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;

/** Charging motes follow aim; hit cuts lie on the victim's visible front surface. */
public final class BladeEffectGeometry {
    private BladeEffectGeometry() {}
    /** A tilted crescent in the plane perpendicular to the launch direction. */
    public static Vec3 wavePoint(Vec3 center, Vec3 forward, Vec3 right, double charge, double progress, double edge) {
        Vec3 up = forward.cross(right).normalize();
        Vec3 cut = right.scale(.82).add(up.scale(.57)).normalize();
        Vec3 rim = forward.cross(cut).normalize();
        double t = Math.max(0, Math.min(1, progress)) * 2 - 1;
        return center.add(cut.scale(t * (.9 + 1.25 * charge)))
                .add(rim.scale((1 - t * t) * (.45 + .35 * charge) + edge))
                .add(forward.scale((1 - t * t) * .12));
    }
    public static Vec3 impactPoint(Vec3 center, Vec3 attacker, double width, double height, double progress, double edge) {
        Vec3 toward = attacker.subtract(center);
        Vec3 front = new Vec3(toward.x, 0, toward.z).normalize();
        if (front.lengthSqr() < .0001) front = new Vec3(0, 0, 1);
        Vec3 right = new Vec3(-front.z, 0, front.x);
        double t = Math.max(0, Math.min(1, progress)) * 2 - 1;
        double halfWidth = Math.max(.12, Math.min(1.4, width * .62));
        double halfHeight = Math.max(.18, Math.min(2.3, height * .42));
        return center.add(front.scale(width * .52 + .035 + (1 - t * t) * .045))
                .add(right.scale(t * halfWidth + edge * .8))
                .add(0, -t * halfHeight + edge * .6, 0);
    }
    public static Vec3 arc(Player player, double radius, double angle) {
        double yaw = Math.toRadians(player.getYRot());
        Vec3 forward = player.getLookAngle();
        Vec3 right = new Vec3(Math.cos(yaw), 0, Math.sin(yaw));
        Vec3 up = forward.cross(right).normalize();
        return player.getEyePosition().add(0, -0.42, 0)
                .add(forward.scale(radius * Math.cos(angle)))
                .add(right.scale(radius * Math.sin(angle)))
                .add(up.scale(Math.sin(angle) * 0.28));
    }
}