-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an tModLoader that improves mini map support + sync to client
Signed-off-by: Seppe Volkaerts <[email protected]>
- Loading branch information
1 parent
af766a5
commit 04cf263
Showing
23 changed files
with
328 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
proxy/src/main/kotlin/org/lanternpowered/terre/impl/addon/Mod.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Terre | ||
* | ||
* Copyright (c) LanternPowered <https://www.lanternpowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* This work is licensed under the terms of the MIT License (MIT). For | ||
* a copy, see 'LICENSE.txt' or <https://opensource.org/licenses/MIT>. | ||
*/ | ||
package org.lanternpowered.terre.impl.addon | ||
|
||
import io.netty.buffer.Unpooled | ||
import org.lanternpowered.terre.impl.network.buffer.readString | ||
import java.io.InputStream | ||
|
||
class Mod( | ||
val name: String, | ||
val version: String, | ||
val tModLoaderVersion: String, | ||
val hash: ByteArray, | ||
val data: ByteArray | ||
) { | ||
|
||
companion object { | ||
|
||
fun load(inputStream: InputStream): Mod { | ||
val data = inputStream.readAllBytes() | ||
val buf = Unpooled.wrappedBuffer(data) | ||
|
||
val header = ByteArray(4) | ||
buf.readBytes(header) | ||
if (!"TMOD".toByteArray(Charsets.US_ASCII).contentEquals(header)) { | ||
error("Not a mod file.") | ||
} | ||
val tModLoaderVersion = buf.readString() | ||
|
||
val hash = ByteArray(20) | ||
buf.readBytes(hash) | ||
|
||
buf.skipBytes(256) // signature | ||
buf.readIntLE() // data length for following data | ||
|
||
val name = buf.readString() | ||
val version = buf.readString() | ||
|
||
return Mod(name, version, tModLoaderVersion, hash, data) | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
proxy/src/main/kotlin/org/lanternpowered/terre/impl/addon/TerreAddon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Terre | ||
* | ||
* Copyright (c) LanternPowered <https://www.lanternpowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* This work is licensed under the terms of the MIT License (MIT). For | ||
* a copy, see 'LICENSE.txt' or <https://opensource.org/licenses/MIT>. | ||
*/ | ||
package org.lanternpowered.terre.impl.addon | ||
|
||
object TerreAddon { | ||
|
||
val mod = requireNotNull(TerreAddon::class.java.getResourceAsStream("/TerreAddon.tmod")) | ||
.use { input -> Mod.load(input) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
proxy/src/test/kotlin/org/lanternpowered/terre/impl/util/ModLoaderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Terre | ||
* | ||
* Copyright (c) LanternPowered <https://www.lanternpowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* This work is licensed under the terms of the MIT License (MIT). For | ||
* a copy, see 'LICENSE.txt' or <https://opensource.org/licenses/MIT>. | ||
*/ | ||
package org.lanternpowered.terre.impl.util | ||
|
||
import org.lanternpowered.terre.impl.addon.TerreAddon | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class ModLoaderTest { | ||
|
||
@Test fun test() { | ||
assertEquals("TerreAddon", TerreAddon.mod.name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"profiles": { | ||
"Terraria": { | ||
"commandName": "Executable", | ||
"executablePath": "$(DotNetName)", | ||
"commandLineArgs": "$(tMLPath)", | ||
"workingDirectory": "$(tMLSteamPath)" | ||
}, | ||
"TerrariaServer": { | ||
"commandName": "Executable", | ||
"executablePath": "$(DotNetName)", | ||
"commandLineArgs": "$(tMLServerPath)", | ||
"workingDirectory": "$(tMLSteamPath)" | ||
} | ||
} | ||
} |
Oops, something went wrong.