Added Preview for Camera's Position and look direction in Path Previews
Added getDestination() method to AdvancedPosition to calculate the destination based on a step size and the position's pitch/yaw
This commit is contained in:
@@ -6,6 +6,9 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import javax.vecmath.Vector3d;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@@ -48,6 +51,20 @@ public class AdvancedPosition extends Position {
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
public AdvancedPosition getDestination(double stepSize) {
|
||||
float f2 = MathHelper.cos((float) (Math.toRadians(-yaw) - (float)Math.PI));
|
||||
float f3 = MathHelper.sin((float) (Math.toRadians(-yaw) - (float) Math.PI));
|
||||
float f4 = -MathHelper.cos((float) (Math.toRadians(-pitch)));
|
||||
float f5 = MathHelper.sin((float) (Math.toRadians(-pitch)));
|
||||
Vector3d direction = new Vector3d((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
||||
direction.normalize();
|
||||
direction.scale(stepSize);
|
||||
|
||||
Vector3d position = new Vector3d(x, y, z);
|
||||
position.add(direction);
|
||||
return new AdvancedPosition(position.getX(), position.getY(), position.getZ(), pitch, yaw, roll, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancedPosition newInstance() {
|
||||
return new AdvancedPosition();
|
||||
|
||||
Reference in New Issue
Block a user