generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] refactor: Build a new tracking & versioning system (#7)
* refactor: Deprecated old tracking classes * refactor: Change type of entities in structure Change type of `entities` from `List<NbtCompound>` to `Map<UUID, NbtCompound>` where `UUID` is `java.util.UUID` Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * feat: [NOT GREAT, DON'T WORK] Add new RVC IO and Tracked Structure designs * feat: some code 4 tracking * feat: add some fields * feat: [DRAFT] New RVC IO architecture Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * fix: Fix TrackedStructure IO Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * feat: block events IO (Draft) * refactor: Reorganize RVC IO architecture Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * refactor: RvcGitIO params Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * refactor: Change RVC file extension to `.rvc` Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * chore: Add data separator for RvcFileIO Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * refactor: Encapsulate RVC File IO functions Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * feat: Add part of RvcFile save Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * refactor: Improve tick saving for RVC File IO Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * feat: Add part of RvcFile load Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * fix: undo perm check crash * chore * feat: scheduled ticks * refactor: remove unused files * feat(RvcFileIO): Add some save/load funcs TrackPoint deserialization needs to be implemented. Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * feat: Add `RvcDataReader` to properly read some RVC data Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * refactor: Improve RVC data file header read func Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * feat: IRvcFileReader * chore: add jgit dependency * style(RvcFileIO): Format document Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * refactor(RvcFileIO): Move `.forEach` to save data to `.entries.joinToString` Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * refactor(RvcFileIO): SImplify save codes Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * refactor: Build the new RvcFileReader architecture Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * feat: Complete RvcReader for version 1 Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> --------- Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> Co-authored-by: Liyan Zhao <return65535@qq.com>
- Loading branch information
1 parent
5eb88e3
commit 2cea96e
Showing
19 changed files
with
603 additions
and
649 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
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
89 changes: 0 additions & 89 deletions
89
src/main/java/com/github/zly2006/reden/rvc/tracking/DiffSerializer.kt
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
src/main/java/com/github/zly2006/reden/rvc/tracking/FileSystemStorage.kt
This file was deleted.
Oops, something went wrong.
98 changes: 98 additions & 0 deletions
98
src/main/java/com/github/zly2006/reden/rvc/tracking/IRvcFileReader.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,98 @@ | ||
package com.github.zly2006.reden.rvc.tracking | ||
|
||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.block.BlockState | ||
import net.minecraft.nbt.NbtCompound | ||
import net.minecraft.server.world.BlockEvent | ||
import java.util.UUID | ||
|
||
/** | ||
* Interface that defines the data reading methods for | ||
* reading RVC data and transform to [TrackedStructure] structures. | ||
*/ | ||
interface IRvcFileReader { | ||
|
||
/** | ||
* Read blocks data from RVC files to maps for structure | ||
* @param data Lines contains data read form RVC files | ||
* @return [Map]<[BlockPos], [BlockState]> data that can be saved to a [TrackedStructure] | ||
*/ | ||
fun readBlocksData(data: List<String>): Map<BlockPos, BlockState> | ||
|
||
/** | ||
* Read blocks entities data from RVC files to maps for structure | ||
* @param data Lines contains data read form RVC files | ||
* @return [Map]<[BlockPos], [NbtCompound]> data that can be saved to a [TrackedStructure] | ||
*/ | ||
fun readBlockEntitiesData(data: List<String>): Map<BlockPos, NbtCompound> | ||
|
||
/** | ||
* Read entities data from RVC files to maps for structure | ||
* @param data Lines contains data read form RVC files | ||
* @return [Map]<[UUID], [NbtCompound]> data that can be saved to a [TrackedStructure] | ||
*/ | ||
fun readEntitiesData(data: List<String>): Map<UUID, NbtCompound> | ||
|
||
/** | ||
* Read track point data from RVC files to list for structure | ||
* @param data Lines contains data read form RVC files | ||
* @return [List]<[TrackedStructure.TrackPoint]> data that can be saved to a [TrackedStructure] | ||
*/ | ||
fun readTrackPointData(data: List<String>): List<TrackedStructure.TrackPoint> | ||
|
||
/** | ||
* Read block events data from RVC files to list for structure | ||
* @param data Lines contains data read form RVC files | ||
* @return [List]<[BlockEvent]> data that can be saved to a [TrackedStructure] | ||
*/ | ||
fun readBlockEventsData(data: List<String>): List<BlockEvent> | ||
|
||
/** | ||
* Read scheduled ticks data from RVC files to list for structure. | ||
* (This is used for both block scheduled ticks and fluid scheduled ticks.) | ||
* @param data Lines contains data read form RVC files | ||
* @return [List]<[NbtCompound]> data that can be saved to a [TrackedStructure] | ||
*/ | ||
fun readScheduledTicksData(data: List<String>): List<NbtCompound> | ||
|
||
/** | ||
* RVC File with a [IRvcFileReader] (for the corresponding data version) | ||
* and data [List] of [String]s. | ||
*/ | ||
data class RvcFile( | ||
val reader: IRvcFileReader, | ||
val data: List<String> | ||
) | ||
|
||
/** | ||
* RVC File metadata header | ||
*/ | ||
data class RvcHeader( | ||
val metadata: MutableMap<String, String> = mutableMapOf() | ||
) { | ||
/** | ||
* @param header The string containing the header data from the RVC file. | ||
*/ | ||
constructor(header: String): this() { | ||
if (!header.startsWith("RVC; ")) { | ||
throw IllegalArgumentException("Invalid RVC header") | ||
} | ||
header.split("; ").drop(1).forEach { | ||
val key = it.substringBefore(": ") | ||
val value = it.substringAfter(": ") | ||
metadata[key] = value | ||
} | ||
} | ||
|
||
/** | ||
* @return Generated RVC data string for RVC data files. | ||
*/ | ||
override fun toString(): String { | ||
var str = "RVC; " | ||
metadata.forEach { (key, value) -> | ||
str += "$key: $value; " | ||
} | ||
return str.substring(0, str.length - 2) | ||
} | ||
} | ||
} |
Oops, something went wrong.