• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Martomate / Hexacraft / 7351367576

28 Dec 2023 06:50PM UTC coverage: 51.185% (-0.1%) from 51.312%
7351367576

push

github

Martomate
Refactor: Made Chunk not know if it has been saved to file

9 of 12 new or added lines in 2 files covered. (75.0%)

110 existing lines in 32 files now uncovered.

2829 of 5527 relevant lines covered (51.19%)

0.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/game/src/main/scala/hexacraft/world/coord/CoordUtils.scala
1
package hexacraft.world.coord
2

3
import hexacraft.world.CylinderSize
4

5
import org.joml.Vector3d
6

7
import scala.annotation.tailrec
8

9
object CoordUtils {
1✔
10
  def getEnclosingBlock(vec: BlockCoords)(using CylinderSize): (BlockRelWorld, BlockCoords.Offset) = {
11
    val (x, y, z) = (vec.x, vec.y, vec.z)
12

13
    @tailrec
1✔
14
    def findBlockPos(xInt: Int, zInt: Int): (Int, Int) = {
15
      val xx = x - xInt
16
      val zz = z - zInt
17

18
      val xp = xx + 0.5 * zz
19
      val zp = zz + 0.5 * xx
20
      val wp = zp - xp
21

×
22
      if (xp > 0.5) findBlockPos(xInt + 1, zInt)
1✔
23
      else if (xp < -0.5) findBlockPos(xInt - 1, zInt)
1✔
UNCOV
24
      else if (zp > 0.5) findBlockPos(xInt, zInt + 1)
×
25
      else if (zp < -0.5) findBlockPos(xInt, zInt - 1)
1✔
26
      else if (wp > 0.5) findBlockPos(xInt - 1, zInt + 1)
×
27
      else if (wp < -0.5) findBlockPos(xInt + 1, zInt - 1)
1✔
28
      else (xInt, zInt)
29
    }
30

1✔
31
    val (xInt, zInt) = findBlockPos(math.round(x).toInt, math.round(z).toInt)
32

33
    val xx = x - xInt
34
    val zz = z - zInt
1✔
35
    val yInt = math.floor(y).toInt
36

1✔
37
    (BlockRelWorld(xInt, yInt, zInt), BlockCoords.Offset(xx, y - yInt, zz))
38
  }
39

1✔
40
  def approximateIntCoords(coords: BlockCoords)(using CylinderSize): BlockRelWorld =
1✔
41
    val X = math.round(coords.x).toInt
1✔
42
    val Y = math.round(coords.y).toInt
1✔
43
    val Z = math.round(coords.z).toInt
1✔
44
    BlockRelWorld(X, Y, Z)
45

1✔
46
  def approximateChunkCoords(coords: CylCoords)(using CylinderSize): ChunkRelWorld =
1✔
47
    approximateIntCoords(coords.toBlockCoords).getChunkRelWorld
48

×
49
  def vectorToOffset(vec: Vector3d): Offset =
×
50
    val blockCoords = CylCoords.Offset(vec).toBlockCoordsOffset
×
51
    Offset(blockCoords.x.round.toInt, blockCoords.y.round.toInt, blockCoords.z.round.toInt)
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc