MCPcopy Index your code
hub / github.com/PaperMC/Paper / getRandom

Method getRandom

paper-api/src/test/java/org/bukkit/LocationTest.java:109–143  ·  view source on GitHub ↗
(Random random, int index)

Source from the content-addressed store, hash-verified

107 }
108
109 private static Arguments getRandom(Random random, int index) {
110 final double YAW_FACTOR = 360;
111 final double YAW_OFFSET = 0;
112 final double PITCH_FACTOR = 180;
113 final double PITCH_OFFSET = -90;
114 final double CARTESIAN_FACTOR = 256;
115 final double CARTESIAN_OFFSET = -128;
116
117 Vector vector;
118 Location location;
119 if (random.nextBoolean()) {
120 float pitch = (float) (random.nextDouble() * PITCH_FACTOR + PITCH_OFFSET);
121 float yaw = (float) (random.nextDouble() * YAW_FACTOR + YAW_OFFSET);
122
123 location = getEmptyLocation();
124 location.setPitch(pitch);
125 location.setYaw(yaw);
126
127 vector = location.getDirection();
128 } else {
129 double x = random.nextDouble() * CARTESIAN_FACTOR + CARTESIAN_OFFSET;
130 double y = random.nextDouble() * CARTESIAN_FACTOR + CARTESIAN_OFFSET;
131 double z = random.nextDouble() * CARTESIAN_FACTOR + CARTESIAN_OFFSET;
132
133 location = getEmptyLocation();
134 vector = new Vector(x, y, z).normalize();
135
136 location.setDirection(vector);
137 }
138
139 return Arguments.of("R" + index,
140 vector.getX(), vector.getY(), vector.getZ(),
141 location.getYaw(), location.getPitch()
142 );
143 }
144
145 @ParameterizedTest
146 @MethodSource("data")

Callers 1

dataMethod · 0.95

Calls 14

getEmptyLocationMethod · 0.95
setPitchMethod · 0.95
setYawMethod · 0.95
getDirectionMethod · 0.95
setDirectionMethod · 0.95
getXMethod · 0.95
getYMethod · 0.95
getZMethod · 0.95
getYawMethod · 0.95
getPitchMethod · 0.95
normalizeMethod · 0.80
ofMethod · 0.65

Tested by

no test coverage detected