Skip to content

Commit

Permalink
Fixed the Strange/Incorrect Sphere and Circle Shapes (#79)
Browse files Browse the repository at this point in the history
* Successfully fixed the longtime outstanding issue of strange/incorrect sphere and circle shapes. An unnecessary voxel/block check was the issue which I removed for both. Note the de/spawning spheres are unaffected by this change

* Forgot the 'if equals' check on the ring for the circle method. Minor ommission from the last commit

* Bump MaLiLib

---------

Co-authored-by: Sakura Ryoko <[email protected]>
  • Loading branch information
JamesSG2 and sakura-ryoko authored Dec 17, 2024
1 parent c1bd74d commit 5ed184a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ build.number
libs/
run/
.idea/
.vscode/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Compiling
=========
* Clone the repository
* Open a command prompt/terminal to the repository directory
* run 'gradlew build'
* run 'gradlew build' (or try '.\gradlew build' if this fails with Powershell)
* The built jar file will be in build/libs/
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod_file_name = minihud-fabric
mod_version = 0.34.0-sakura.3

# Required malilib version
malilib_version = 975d68adf7
malilib_version = b41a9d0fa3

# Minecraft, Fabric Loader and API and mappings versions
minecraft_version_out = 1.21.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,12 @@ protected boolean isPositionOnOrInsideRing(int blockX, int blockY, int blockZ, D
double distSq = effectiveCenter.squaredDistanceTo(x, y, z);
double diff = radiusSq - distSq;

if (diff > 0)
if (diff >= 0)
{
return true;
}

double xAdj = x + outSide.getOffsetX();
double yAdj = y + outSide.getOffsetY();
double zAdj = z + outSide.getOffsetZ();
double distAdjSq = effectiveCenter.squaredDistanceTo(xAdj, yAdj, zAdj);
double diffAdj = radiusSq - distAdjSq;

return diffAdj > 0 && Math.abs(diff) < Math.abs(diffAdj);
return false;
}

public static List<SideQuad> buildStripsToQuadsForCircle(Long2ObjectOpenHashMap<SideQuad> strips,
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/fi/dy/masa/minihud/util/shape/SphereUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,12 @@ public static boolean isPositionInsideOrClosestToRadiusOnBlockRing(int blockX,
double dist = center.squaredDistanceTo(x, y, z);
double diff = squareRadius - dist;

if (diff > 0)
if (diff >= 0)
{
return true;
}

double xAdj = (double) blockX + escapeDirection.getOffsetX() + 0.5;
double yAdj = (double) blockY + escapeDirection.getOffsetY() + 0.5;
double zAdj = (double) blockZ + escapeDirection.getOffsetZ() + 0.5;
double distAdj = center.squaredDistanceTo(xAdj, yAdj, zAdj);
double diffAdj = squareRadius - distAdj;

return diffAdj > 0 && Math.abs(diff) < Math.abs(diffAdj);

return false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@

"depends": {
"minecraft": "1.21.4",
"malilib": ">=0.23.0-sakura.3"
"malilib": ">=0.23.0-sakura.4"
}
}

0 comments on commit 5ed184a

Please sign in to comment.