Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ dependencies {
compileOnly("curse.maven:cofh-core-69162:2388751")
compileOnly("curse.maven:computercraft-67504:2269339") // https://www.curseforge.com/minecraft/mc-mods/computercraft/files/2269339
compileOnly files("dependencies/ColoredLightsCore-1.3.7.39.jar")

testImplementation("junit:junit:4.13.2")
}
212 changes: 212 additions & 0 deletions src/main/scala/mrtjp/projectred/integration/GateWireMasks.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
package mrtjp.projectred.integration

import codechicken.lib.vec.Rectangle4i

private[integration] object GateWireMasks {
private val names = Array[String](
"OR-0",
"OR-1",
"OR-2",
"OR-3",
"NOR-0",
"NOR-1",
"NOR-2",
"NOR-3",
"NOT-0",
"NOT-1",
"NOT-2",
"NOT-3",
"AND-0",
"AND-1",
"AND-2",
"AND-3",
"NAND-0",
"NAND-1",
"NAND-2",
"NAND-3",
"XOR-0",
"XOR-1",
"XOR-2",
"XOR-3",
"XNOR-0",
"XNOR-1",
"XNOR-2",
"XNOR-3",
"XNOR-4",
"BUFFER-0",
"BUFFER-1",
"BUFFER-2",
"BUFFER-3",
"MULTIPLEXER-0",
"MULTIPLEXER-1",
"MULTIPLEXER-2",
"MULTIPLEXER-3",
"MULTIPLEXER-4",
"MULTIPLEXER-5",
"PULSE-0",
"PULSE-1",
"PULSE-2",
"REPEATER-0",
"REPEATER-1",
"RAND-0",
"RAND-1",
"RAND-2",
"RAND-3",
"RAND-4",
"RAND-5",
"RAND-6",
"RSLATCH-0",
"RSLATCH-1",
"RSLATCH2-0",
"RSLATCH2-1",
"RSLATCH2-2",
"RSLATCH2-3",
"TOGLATCH-0",
"TOGLATCH-1",
"TRANSLATCH-0",
"TRANSLATCH-1",
"TRANSLATCH-2",
"TRANSLATCH-3",
"TRANSLATCH-4",
"LIGHTSENSOR-0",
"RAINSENSOR-0",
"TIME-0",
"TIME-1",
"TIME-2",
"COUNT-0",
"COUNT-1",
"STATECELL-0",
"STATECELL-1",
"STATECELL-2",
"STATECELL-3",
"STATECELL-4",
"SYNC-0",
"SYNC-1",
"SYNC-2",
"SYNC-3",
"SYNC-4",
"SYNC-5",
"BUSXCVR-0",
"BUSXCVR-1",
"COMPARATOR-0",
"COMPARATOR-1",
"COMPARATOR-2",
"COMPARATOR-3",
"BUSRAND1-0",
"BUSRAND1-1",
"BUSRAND2-0",
"BUSRAND2-1",
"BUSCONV-0",
"BUSCONV-1",
"BUSCONV-2",
"BUSINPUT-0",
"INVCELL-0",
"BUFFCELL-0",
"BUFFCELL-1",
"ANDCELL-0",
"ANDCELL-1",
"STACKLATCH-0",
"STACKLATCH-1",
"STACKLATCH-2",
"STACKLATCH-3",
"STACKLATCH-4",
"DECRAND-0",
"DECRAND-1",
"DECRAND-2",
"DECRAND-3",
"DECRAND-4",
"DECRAND-5",
"IC1-0",
"IC1-1",
"IC1-2",
"IC1-3",
"IC2-0",
"IC2-1",
"IC2-2",
"IC2-3"
)
private val offsets = Array[Int](
0, 3, 5, 6, 8, 11, 13, 14, 16, 19, 21, 22, 24, 26, 27, 28, 29, 32, 35, 36,
37, 45, 50, 54, 58, 63, 68, 72, 76, 79, 82, 86, 87, 91, 96, 101, 104, 109,
110, 111, 117, 120, 124, 127, 130, 131, 133, 134, 136, 137, 138, 139, 144,
149, 154, 157, 162, 165, 168, 169, 174, 177, 180, 182, 183, 184, 185, 191,
197, 198, 202, 206, 210, 212, 214, 217, 218, 221, 224, 228, 231, 233, 235,
237, 238, 241, 242, 245, 250, 251, 252, 255, 258, 259, 260, 262, 263, 264,
265, 269, 274, 275, 278, 282, 284, 286, 287, 292, 298, 300, 301, 303, 307,
308, 309, 310, 311, 312, 313, 314, 315
)
private val packedRectangles = Array[Int](
0x0f04020a, 0x0d0c0202, 0x110c0202, 0x180f0602, 0x12110602, 0x0f12020c,
0x020f0602, 0x08110802, 0x0f02020c, 0x0d0c0202, 0x110c0202, 0x180f0602,
0x12110602, 0x0f12020c, 0x020f0602, 0x08110802, 0x0f02020a, 0x0d0a0202,
0x110a0202, 0x140d0206, 0x160f0802, 0x0f10020e, 0x0a0d0206, 0x020f0802,
0x0f020208, 0x060a1402, 0x0f10020e, 0x020f0602, 0x180f0602, 0x0f020206,
0x11080202, 0x060a1402, 0x0f120204, 0x0d160204, 0x0f1a0204, 0x020f0802,
0x160f0802, 0x0f020204, 0x0a060c02, 0x08080204, 0x16080204, 0x060a0202,
0x0a0a0202, 0x140a0202, 0x180a0202, 0x090f0602, 0x110f0602, 0x0f110204,
0x0d130202, 0x11130202, 0x020f0602, 0x04110204, 0x06150202, 0x08170802,
0x180f0602, 0x1a110204, 0x18150202, 0x10170802, 0x0f020204, 0x0a060602,
0x08080204, 0x060a0202, 0x0a0a0202, 0x0f020204, 0x10060602, 0x16080204,
0x140a0202, 0x180a0202, 0x020f0602, 0x04110204, 0x06150202, 0x08170802,
0x180f0602, 0x1a110204, 0x18150202, 0x10170802, 0x080f0602, 0x120f0602,
0x0e110402, 0x0f060208, 0x0d0c0202, 0x110c0202, 0x14040206, 0x16060202,
0x18080208, 0x1a100402, 0x0f12020c, 0x0a040206, 0x08060202, 0x06080208,
0x02100402, 0x0f020204, 0x0a060602, 0x08080204, 0x060a0202, 0x0a0a0202,
0x0f020204, 0x10060602, 0x16080204, 0x140a0202, 0x180a0202, 0x08100204,
0x0c120206, 0x0a140202, 0x16120202, 0x10140602, 0x15160204, 0x111a0402,
0x0f1c0202, 0x020f0802, 0x160f0802, 0x09060602, 0x07080208, 0x050e0202,
0x090e0202, 0x0b100206, 0x0d120a02, 0x07120206, 0x09180602, 0x0f1a0204,
0x0f060602, 0x15080208, 0x130e0202, 0x170e0202, 0x0f020206, 0x17060414,
0x11080602, 0x130c020e, 0x11120202, 0x0f14020a, 0x0f020206, 0x180f0602,
0x16110206, 0x0f180206, 0x020f0602, 0x08110206, 0x0f08020e, 0x11160602,
0x09160602, 0x08070204, 0x060b020c, 0x020f0402, 0x08170202, 0x0a190802,
0x0e050802, 0x16070202, 0x1809020c, 0x1a0f0402, 0x16150204, 0x12070206,
0x140d0204, 0x16110208, 0x12170206, 0x14190202, 0x12050802, 0x1a070208,
0x1c0f0202, 0x0c030206, 0x0a050202, 0x08070208, 0x0a0f0204, 0x0c130206,
0x020f0202, 0x04110208, 0x06190802, 0x020f0802, 0x100f0602, 0x0a110602,
0x160f0802, 0x0f02020a, 0x15080602, 0x070a0802, 0x110a0402, 0x1b0a0206,
0x0f0e020a, 0x07180802, 0x0f1a0204, 0x070e0208, 0x05140202, 0x09140202,
0x170d0206, 0x110f0602, 0x020f0602, 0x0f12020c, 0x0f0c0212, 0x0a030206,
0x08050202, 0x06070208, 0x080d0202, 0x020f0402, 0x0a0f0402, 0x14030206,
0x16050202, 0x18070208, 0x160d0202, 0x100f0602, 0x1a0f0402, 0x0f10020e,
0x020f0802, 0x100f0602, 0x0a110602, 0x04190602, 0x18030206, 0x16050202,
0x1a050202, 0x160f0802, 0x0e040206, 0x0c060202, 0x0a080204, 0x0c0c0206,
0x0d160204, 0x0f1a0204, 0x14100402, 0x10120402, 0x020f0202, 0x04110202,
0x06130402, 0x180f0602, 0x0c050402, 0x0a070202, 0x08090206, 0x10050402,
0x14070202, 0x16090206, 0x08140204, 0x16140204, 0x0a180c02, 0x0f1a0204,
0x0e0f0402, 0x0c110202, 0x12110202, 0x020f0202, 0x04110202, 0x1c0f0202,
0x1a110202, 0x160e0804, 0x1e0e0204, 0x000e0a04, 0x0f020206, 0x11080402,
0x150a0206, 0x160f0802, 0x15100208, 0x11180402, 0x0f1a0204, 0x020f0202,
0x100f0602, 0x04110204, 0x0e110204, 0x06150802, 0x160f0802, 0x020f0802,
0x160d0402, 0x1a0f0402, 0x16110402, 0x060d0402, 0x020f0402, 0x06110402,
0x160f0802, 0x020f0802, 0x0e10040e, 0x0e1e0402, 0x0e000404, 0x0b0f0602,
0x11190602, 0x0f0f0602, 0x15110206, 0x13150202, 0x17150202, 0x0f020214,
0x0d0f0202, 0x110f0202, 0x0d140202, 0x11140202, 0x0f180206, 0x0b030602,
0x09050206, 0x0b0b0210, 0x0e0f0802, 0x180f0202, 0x16110202, 0x18130206,
0x14150206, 0x10170402, 0x0d070602, 0x0f090206, 0x0f180206, 0x09040802,
0x07060202, 0x09080210, 0x03100208, 0x05180202, 0x0f050204, 0x11090204,
0x0f0b0202, 0x130b0402, 0x170d0202, 0x190f0202, 0x111a0202, 0x0f1c0202,
0x0d1a0202, 0x050f1002, 0x15110208, 0x13020206, 0x15040402, 0x19060206,
0x1b0c0206, 0x0f020204, 0x1a0f0402, 0x0f1a0204, 0x020f0402, 0x0e020404,
0x1a0e0404, 0x0e1a0404, 0x020e0404
)

def rectangles(name: String): Seq[Rectangle4i] = {
val index = names.indexOf(name)
if (index < 0) return null

val result = Seq.newBuilder[Rectangle4i]
var i = offsets(index)
while (i < offsets(index + 1)) {
val packed = packedRectangles(i)
result += new Rectangle4i(
packed >>> 24,
packed >>> 16 & 0xff,
packed >>> 8 & 0xff,
packed & 0xff
)
i += 1
}
result.result()
}
}
Loading