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

Martomate / Hexacraft / 4212765122

pending completion
4212765122

push

github

Martin Jakobsson
Moved block specs from json files to code

51 of 51 new or added lines in 9 files covered. (100.0%)

1609 of 4743 relevant lines covered (33.92%)

0.34 hits per line

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

50.0
/src/main/scala/com/martomate/hexacraft/world/block/BlockSpec.scala
1
package com.martomate.hexacraft.world.block
2

3
case class BlockSpec(textures: BlockSpec.Textures)
4

5
object BlockSpec:
6
  case class Textures(
7
      sides: IndexedSeq[String],
8
      top: String,
9
      bottom: String,
10
      topOffsets: Offsets,
11
      bottomOffsets: Offsets
12
  ):
×
13
    def indices(texIdxMap: Map[String, Int]): IndexedSeq[Int] =
×
14
      val topIdx = texIdxMap(top) | topOffsets.packed << 12
×
15
      val bottomIdx = texIdxMap(bottom) | bottomOffsets.packed << 12
×
16
      val sidesIdx = sides.map(s => texIdxMap(s))
×
17
      topIdx +: bottomIdx +: sidesIdx
18

1✔
19
    def withTop(top: String, offsets: Offsets = Offsets.default): Textures =
20
      copy(top = top, topOffsets = offsets)
1✔
21
    def withBottom(bottom: String, offsets: Offsets = Offsets.default): Textures =
22
      copy(bottom = bottom, bottomOffsets = offsets)
23

24
  object Textures:
1✔
25
    def basic(all: String): Textures =
1✔
26
      Textures(IndexedSeq.fill(6)(all), all, all, Offsets.default, Offsets.default)
27

28
  case class Offsets(off0: Int, off1: Int, off2: Int, off3: Int, off4: Int, off5: Int):
1✔
29
    require(off0 == 0) // not allowed
30

×
31
    def packed: Int = off1 << 16 | off2 << 12 | off3 << 8 | off4 << 4 | off5
32

33
  object Offsets:
1✔
34
    def default: Offsets = Offsets(0, 0, 0, 0, 0, 0)
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