-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optional data converter shim for upgrading world data
- Loading branch information
Showing
6 changed files
with
112 additions
and
17 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
51 changes: 51 additions & 0 deletions
51
src/main/java/net/hollowcube/polar/PolarDataConverter.java
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,51 @@ | ||
package net.hollowcube.polar; | ||
|
||
import net.kyori.adventure.nbt.CompoundBinaryTag; | ||
import net.minestom.server.MinecraftServer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Allows for upgrading world data from one game version to another. | ||
*/ | ||
public interface PolarDataConverter { | ||
@NotNull | ||
PolarDataConverter NOOP = new PolarDataConverter() { | ||
}; | ||
|
||
/** | ||
* Returns the data version to use on worlds lower than {@link PolarWorld#VERSION_DATA_CONVERTER} which | ||
* do not store a data version. Defaults to the current Minestom data version. | ||
*/ | ||
default int defaultDataVersion() { | ||
return MinecraftServer.DATA_VERSION; | ||
} | ||
|
||
/** | ||
* Returns the current data version of the world. | ||
*/ | ||
default int dataVersion() { | ||
return MinecraftServer.DATA_VERSION; | ||
} | ||
|
||
/** | ||
* <p>Converts the block palette from one version to another. Implementations are expected to modify | ||
* the palette array in place.</p> | ||
* | ||
* @param palette An array of block namespaces, eg "minecraft:stone_stairs[facing=north]" | ||
* @param fromVersion The data version of the palette | ||
* @param toVersion The data version to convert the palette to | ||
*/ | ||
default void convertBlockPalette(@NotNull String[] palette, int fromVersion, int toVersion) { | ||
|
||
} | ||
|
||
default @NotNull Map.Entry<String, CompoundBinaryTag> convertBlockEntityData( | ||
@NotNull String id, @NotNull CompoundBinaryTag data, | ||
int fromVersion, int toVersion | ||
) { | ||
return Map.entry(id, data); | ||
} | ||
|
||
} |
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