From 0697c425ca7793da4b4df9b622165b03eb8247f1 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Thu, 3 Oct 2024 03:38:58 -0400 Subject: [PATCH 1/2] Document SimpleCollisionBox and HexCollisionBox with Javadoc --- .../collisions/datatypes/HexCollisionBox.java | 16 +++++++++---- .../datatypes/SimpleCollisionBox.java | 24 +++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/main/java/ac/grim/grimac/utils/collisions/datatypes/HexCollisionBox.java b/src/main/java/ac/grim/grimac/utils/collisions/datatypes/HexCollisionBox.java index c058abc954..cc23caec69 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/datatypes/HexCollisionBox.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/datatypes/HexCollisionBox.java @@ -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; diff --git a/src/main/java/ac/grim/grimac/utils/collisions/datatypes/SimpleCollisionBox.java b/src/main/java/ac/grim/grimac/utils/collisions/datatypes/SimpleCollisionBox.java index f23a824a0b..ab62dea842 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/datatypes/SimpleCollisionBox.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/datatypes/SimpleCollisionBox.java @@ -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; @@ -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; From 980226fab914a0ee8f0b012d083205cf4ece8830 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Thu, 10 Oct 2024 23:54:19 -0400 Subject: [PATCH 2/2] Update LOSP to work with new grim config --- .../grimac/checks/impl/scaffolding/LineOfSightPlace.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/LineOfSightPlace.java b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/LineOfSightPlace.java index 4f02f08ca5..939ffc26ba 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/LineOfSightPlace.java +++ b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/LineOfSightPlace.java @@ -1,5 +1,6 @@ package ac.grim.grimac.checks.impl.scaffolding; +import ac.grim.grimac.api.config.ConfigManager; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.BlockPlaceCheck; import ac.grim.grimac.player.GrimPlayer; @@ -178,12 +179,10 @@ private boolean isBlockTypeWhitelisted(StateType type) { } @Override - public void reload() { - super.reload(); - - useBlockWhitelist = getConfig().getBooleanElse("LineOfSightPlace.use-block-whitelist", false); + public void onReload(ConfigManager config) { + useBlockWhitelist = config.getBooleanElse("LineOfSightPlace.use-block-whitelist", false); blockWhitelist = new HashSet<>(); - List blocks = getConfig().getList("LineOfSightPlace.block-whitelist"); + List blocks = config.getStringList("LineOfSightPlace.block-whitelist"); for (String block : blocks) { blockWhitelist.add(StateTypes.getByName(block)); }