Skip to content

Commit 99f4fb6

Browse files
committed
-
1 parent d25315b commit 99f4fb6

83 files changed

Lines changed: 8020 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

10 KB
Binary file not shown.

LICENSE.txt

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ARM
2+
3+
[Minecraft](https://www.minecraft.net/ja-jp) | [forge1.12.2](https://files.minecraftforge.net/net/minecraftforge/forge/index_1.12.2.html)
4+
5+
# 最新版のダウンロードは[こちら](https://github.com/ringo-1234/ARM/releases/latest)から
6+
7+
## この Mod はなにか
8+
9+
ARM は [WebCTC](https://github.com/WebCTC/WebCTC) をベースとした、RealTrainMod(RTM) 向けの Webマップ です。
10+
WebCTC とは独立したプロジェクトであり、別途開発・配布されています。
11+
12+
## 注意事項
13+
14+
**当 Mod の使用による一切の責任を負いません。**
15+
16+
## 動作環境
17+
18+
- Minecraft 1.12.2
19+
- Forge 1.12.2
20+
- RealTrainMod-1.12.2 (または、[AppleExtended](https://github.com/ringo-1234/AppleExtended))
21+
22+
## 導入方法
23+
24+
当 Mod をダウンロードし、mods フォルダに入れてください。
25+
26+
## ライセンス
27+
28+
[GNU Affero General Public License v3.0](LICENSE)
29+
30+
## 謝辞
31+
32+
本プロジェクトは [WebCTC](https://github.com/WebCTC/WebCTC) をベースとしています。
33+
WebCTC を開発・公開された [Kaiz_JP](https://github.com/Kai-Z-JP) 様、[masa300](https://github.com/masa300) 様に感謝申し上げます。

build.gradle.kts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
buildscript {
2+
repositories {
3+
gradlePluginPortal()
4+
mavenCentral()
5+
maven("https://maven.minecraftforge.net/")
6+
}
7+
dependencies {
8+
classpath("net.minecraftforge.gradle:ForgeGradle:6.0.24")
9+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21")
10+
classpath("org.jetbrains.kotlin:kotlin-serialization:2.0.21")
11+
classpath("com.github.johnrengelman:shadow:8.1.1")
12+
}
13+
}
14+
15+
allprojects {
16+
repositories {
17+
mavenCentral()
18+
maven("https://maven.minecraftforge.net/")
19+
}
20+
21+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().configureEach {
22+
compilerOptions {
23+
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
24+
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
25+
freeCompilerArgs.add("-opt-in=kotlin.uuid.ExperimentalUuidApi")
26+
}
27+
}
28+
}
29+
30+
val buildFront = tasks.register<Exec>("buildFront") {
31+
group = "build"
32+
workingDir = file("front")
33+
val isWindows = System.getProperty("os.name").lowercase().contains("windows")
34+
commandLine(
35+
if (isWindows) listOf("cmd", "/c", "npm run build")
36+
else listOf("npm", "run", "build")
37+
)
38+
}
39+
40+
val copyArtifact = tasks.register<Copy>("copyArtifact") {
41+
group = "build"
42+
dependsOn(":mc:reobfShadowJar")
43+
from(project(":mc").layout.buildDirectory.dir("libs")) {
44+
include("*.jar")
45+
exclude("*-thin.jar")
46+
}
47+
into(layout.buildDirectory.dir("libs"))
48+
}
49+
50+
tasks.register("build") {
51+
group = "build"
52+
dependsOn(buildFront, ":mc:reobfShadowJar", copyArtifact)
53+
}

common/.DS_Store

6 KB
Binary file not shown.

common/build.gradle.kts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
plugins {
2+
kotlin("multiplatform")
3+
kotlin("plugin.serialization")
4+
}
5+
6+
kotlin {
7+
jvm()
8+
9+
sourceSets {
10+
commonMain.dependencies {
11+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
12+
}
13+
}
14+
15+
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
16+
compilerOptions {
17+
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
18+
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
19+
freeCompilerArgs.add("-opt-in=kotlin.uuid.ExperimentalUuidApi")
20+
}
21+
22+
jvmToolchain(8)
23+
}
24+
25+
tasks.matching { it.name.contains("Metadata") }.configureEach {
26+
enabled = false
27+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.webctc.common.types
2+
3+
import kotlinx.serialization.json.*
4+
import kotlinx.serialization.modules.SerializersModule
5+
import kotlinx.serialization.modules.polymorphic
6+
import kotlinx.serialization.modules.subclass
7+
import org.webctc.common.types.rail.IRailMapData
8+
import org.webctc.common.types.rail.RailMapData
9+
import org.webctc.common.types.rail.RailMapSwitchData
10+
11+
val kotlinxJson = Json {
12+
serializersModule = SerializersModule {
13+
polymorphic(IRailMapData::class) {
14+
subclass(RailMapData::class)
15+
subclass(RailMapSwitchData::class)
16+
}
17+
}
18+
ignoreUnknownKeys = true
19+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package org.webctc.common.types
2+
3+
import kotlinx.serialization.Serializable
4+
import kotlin.math.ceil
5+
import kotlin.math.log2
6+
import kotlin.math.pow
7+
import kotlin.math.sqrt
8+
9+
private const val worldSize = 30000000
10+
private val bits = 1 + log2(ceil(worldSize.toDouble()).nextPowerOfTwo()).toInt()
11+
private val xBits = bits
12+
private val zBits = bits
13+
private val yBits = 64 - xBits - zBits
14+
private val yShift = 0 + zBits
15+
private val xShift = yShift + yBits
16+
private val xMask = (1L shl xBits) - 1L
17+
private val yMask = (1L shl yBits) - 1L
18+
private val zMask = (1L shl zBits) - 1L
19+
20+
@Serializable
21+
data class PosInt(val x: Int, val y: Int, val z: Int) {
22+
constructor(serialized: Long) : this(
23+
(serialized shl 64 - xShift - xBits shr 64 - xBits).toInt(),
24+
(serialized shl 64 - yShift - yBits shr 64 - yBits).toInt(),
25+
(serialized shl 64 - zBits shr 64 - zBits).toInt()
26+
)
27+
28+
override fun toString(): String {
29+
return "$x,$y,$z"
30+
}
31+
32+
fun toLong(): Long {
33+
return (x.toLong() and xMask shl xShift) or (y.toLong() and yMask shl yShift) or (z.toLong() and zMask shl 0)
34+
}
35+
36+
companion object {
37+
val ZERO = PosInt(0, 0, 0)
38+
}
39+
}
40+
41+
fun Double.nextPowerOfTwo(): Double = 2.0.pow(ceil(log2(this)))
42+
43+
fun IntArray.toPosInt(): PosInt {
44+
return PosInt(this[0], this[1], this[2])
45+
}
46+
47+
@Serializable
48+
data class PosInt2D(val x: Int, val y: Int) {
49+
override fun toString(): String {
50+
return "$x,$y"
51+
}
52+
53+
operator fun minus(start: PosInt2D): PosInt2D {
54+
return PosInt2D(this.x - start.x, this.y - start.y)
55+
}
56+
57+
companion object {
58+
val ZERO = PosInt2D(0, 0)
59+
}
60+
}
61+
62+
@Serializable
63+
data class PosDouble(val x: Double, val y: Double, val z: Double) {
64+
fun distanceTo(other: PosDouble): Double {
65+
val dx = x - other.x
66+
val dz = z - other.z
67+
return sqrt(dx * dx + dz * dz)
68+
}
69+
70+
fun isInsideSegment2D(b1: PosDouble, b2: PosDouble): Boolean {
71+
val ax = x - b1.x
72+
val az = z - b1.z
73+
val bx = b2.x - b1.x
74+
val bz = b2.z - b1.z
75+
val r = (ax * bx + az * bz) / (bx * bx + bz * bz)
76+
77+
return r in 0.0..1.0
78+
}
79+
80+
fun distanceToSegment(b1: PosDouble, b2: PosDouble): Double {
81+
val dx = b2.x - b1.x
82+
val dz = b2.z - b1.z
83+
val r = ((x - b1.x) * dx + (z - b1.z) * dz) / (dx * dx + dz * dz)
84+
85+
return if (r in 0.0..1.0) {
86+
val closestX = b1.x + r * dx
87+
val closestZ = b1.z + r * dz
88+
sqrt((x - closestX) * (x - closestX) + (z - closestZ) * (z - closestZ))
89+
} else {
90+
Double.MAX_VALUE
91+
}
92+
}
93+
94+
override fun toString(): String {
95+
return "$x,$y,$z"
96+
}
97+
98+
companion object {
99+
val ZERO: PosDouble = PosDouble(0.0, 0.0, 0.0)
100+
}
101+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.webctc.common.types.mc
2+
3+
import kotlinx.serialization.Serializable
4+
5+
6+
@Serializable
7+
data class PlayerPrincipal(
8+
val name: String,
9+
val uuid: String,
10+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@file:OptIn(kotlin.uuid.ExperimentalUuidApi::class)
2+
@file:UseSerializers(org.webctc.common.uuid.UuidSerializer::class)
3+
package org.webctc.common.types.mc
4+
5+
import kotlinx.serialization.ExperimentalSerializationApi
6+
import kotlinx.serialization.Serializable
7+
import kotlinx.serialization.UseSerializers
8+
import kotlinx.serialization.json.JsonNames
9+
import kotlin.uuid.Uuid
10+
11+
@Serializable
12+
data class PlayerProfile(
13+
@JsonNames("uuid_formatted")
14+
@OptIn(ExperimentalSerializationApi::class)
15+
val uuid: Uuid,
16+
val username: String
17+
)

0 commit comments

Comments
 (0)