Skip to content

Commit c44e502

Browse files
committed
Refactor: Rename offset parameter and add JavaDoc
- Renamed parameter 'i' to 'distance' in Vector3i, Vector3f, and Vector3d to improve code readability. - Added JavaDoc to offset methods to explain the functionality as requested.
1 parent 21866cc commit c44e502

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

api/src/main/java/com/github/retrooper/packetevents/util/Vector3d.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,15 @@ public Vector3d offset(BlockFace face) {
189189
return add(face.getModX(), face.getModY(), face.getModZ());
190190
}
191191

192-
public Vector3d offset(BlockFace face, int i) {
193-
return i == 0 ? this : add(face.getModX() * i, face.getModY() * i, face.getModZ() * i);
192+
/**
193+
* Offsets the vector by a specific BlockFace direction and distance.
194+
*
195+
* @param face The direction in which to offset.
196+
* @param distance The distance to offset in that direction.
197+
* @return A new Vector3d with the calculated offset.
198+
*/
199+
public Vector3d offset(BlockFace face, int distance) {
200+
return distance == 0 ? this : add(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
194201
}
195202

196203
public Vector3d subtract(double x, double y, double z) {

api/src/main/java/com/github/retrooper/packetevents/util/Vector3f.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,15 @@ public Vector3f offset(BlockFace face) {
150150
return add(face.getModX(), face.getModY(), face.getModZ());
151151
}
152152

153-
public Vector3f offset(BlockFace face, int i) {
154-
return i == 0 ? this : add(face.getModX() * i, face.getModY() * i, face.getModZ() * i);
153+
/**
154+
* Offsets the vector by a specific BlockFace direction and distance.
155+
*
156+
* @param face The direction in which to offset.
157+
* @param distance The distance to offset in that direction.
158+
* @return A new Vector3f with the calculated offset.
159+
*/
160+
public Vector3f offset(BlockFace face, int distance) {
161+
return distance == 0 ? this : add(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
155162
}
156163

157164
public Vector3f subtract(float x, float y, float z) {

api/src/main/java/com/github/retrooper/packetevents/util/Vector3i.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,15 @@ public Vector3i offset(BlockFace face) {
217217
return add(face.getModX(), face.getModY(), face.getModZ());
218218
}
219219

220-
public Vector3i offset(BlockFace face, int i) {
221-
return i == 0 ? this : add(face.getModX() * i, face.getModY() * i, face.getModZ() * i);
220+
/**
221+
* Offsets the vector by a specific BlockFace direction and distance.
222+
*
223+
* @param face The direction in which to offset.
224+
* @param distance The distance to offset in that direction.
225+
* @return A new Vector3i with the calculated offset.
226+
*/
227+
public Vector3i offset(BlockFace face, int distance) {
228+
return distance == 0 ? this : add(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
222229
}
223230

224231
public Vector3i subtract(int x, int y, int z) {

0 commit comments

Comments
 (0)