Skip to content

Commit

Permalink
Document SimpleCollisionBox and HexCollisionBox with Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Axionize committed Oct 3, 2024
1 parent 428f213 commit 0697c42
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

public class HexCollisionBox extends SimpleCollisionBox {

// Mojang's block hitbox values are all based on chunks, so they're stored in game as 16 * the actual values we want
// When copying block hitbox values, it may be easier to simple copy the multiplied values and divide them
// HexCollisionBox is a simple extension of SimpleCollisionBox that does this for us.
// If none of your min/max values are > 1 you probably should not be using this class.
/**
* Creates a box defined by two points in 3d space; used to represent hitboxes and collision boxes.
* Mojang's block hitbox values are all based on chunks, so they're stored in game as 16 * the actual size
* When copying block hitbox values, it may be easier to simple copy the multiplied values and use this class
* If your min/max values are < 1 you should probably check out {@link SimpleCollisionBox}
* @param minX 16 * x position of first corner
* @param minY 16 * y position of first corner
* @param minZ 16 * z position of first corner
* @param maxX 16 * x position of second corner
* @param maxY 16 * y position of second corner
* @param maxZ 16 * z position of second corner
*/
public HexCollisionBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
this.minX = minX / 16d;
this.minY = minY / 16d;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ public class SimpleCollisionBox implements CollisionBox {
public double minX, minY, minZ, maxX, maxY, maxZ;
private boolean isFullBlock = false;

// If your min/max values are > 1 you should probably check out HexCollisionBox
public SimpleCollisionBox() {
this(0, 0, 0, 0, 0, 0, false);
}

/**
* Creates a box defined by two points in 3d space; used to represent hitboxes and collision boxes.
* If your min/max values are > 1 you should probably check out {@link HexCollisionBox}
* @param minX x position of first corner
* @param minY y position of first corner
* @param minZ z position of first corner
* @param maxX x position of second corner
* @param maxY y position of second corner
* @param maxZ z position of second corner
* @param fullBlock - whether on not the box is a perfect 1x1x1 sized block
*/
public SimpleCollisionBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, boolean fullBlock) {
this.minX = minX;
this.maxX = maxX;
Expand All @@ -48,7 +58,17 @@ public SimpleCollisionBox(double minX, double minY, double minZ) {
this(minX, minY, minZ, minX + 1, minY + 1, minZ + 1, true);
}

// Use only if you don't know the fullBlock status, which is rare
/**
* Creates a box defined by two points in 3d space; used to represent hitboxes and collision boxes.
* If your min/max values are > 1 you should probably check out {@link HexCollisionBox}
* Use only if you don't know the fullBlock status, which is rare
* @param minX x position of first corner
* @param minY y position of first corner
* @param minZ z position of first corner
* @param maxX x position of second corner
* @param maxY y position of second corner
* @param maxZ z position of second corner
*/
public SimpleCollisionBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
this.minX = minX;
this.maxX = maxX;
Expand Down

0 comments on commit 0697c42

Please sign in to comment.