-
Notifications
You must be signed in to change notification settings - Fork 79
Registerable WorldFormat api #1795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d2097ca
560f904
9cd732f
485d772
b6e812c
cf31ed1
bcf8d12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package se.llbit.chunky.chunk.biome; | ||
|
|
||
| import se.llbit.chunky.world.JavaChunk; | ||
| import se.llbit.chunky.world.biome.BiomePalette; | ||
| import se.llbit.chunky.world.biome.Biomes; | ||
| import se.llbit.nbt.Tag; | ||
|
|
@@ -34,7 +35,7 @@ public void clear() { | |
| } | ||
|
|
||
| public static void loadBiomeDataByteArray(Tag chunkData, BiomeData2d biomeData, BiomePalette biomePalette) { | ||
| byte[] data = chunkData.get(LEVEL_BIOMES).byteArray(); | ||
| byte[] data = chunkData.get(JavaChunk.LEVEL_BIOMES).byteArray(); | ||
| int i = 0; | ||
| for(int z = 0; z < Z_MAX; z++) { | ||
| for(int x = 0; x < X_MAX; x++) { | ||
|
|
@@ -46,7 +47,7 @@ public static void loadBiomeDataByteArray(Tag chunkData, BiomeData2d biomeData, | |
|
|
||
| public static void loadBiomeDataIntArray(Tag chunkData, BiomeData2d biomeData, BiomePalette biomePalette) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, ie. let the biome data classes only contain the data and add per world format factories to create them? |
||
| // Since Minecraft 1.13, biome IDs are stored in an int vector with 256 entries (one for each XZ position). | ||
| int[] data = chunkData.get(LEVEL_BIOMES).intArray(); | ||
| int[] data = chunkData.get(JavaChunk.LEVEL_BIOMES).intArray(); | ||
| int i = 0; | ||
| for(int z = 0; z < Z_MAX; z++) { | ||
| for(int x = 0; x < X_MAX; x++) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ | |
| import se.llbit.chunky.world.biome.Biome; | ||
| import se.llbit.chunky.world.biome.BiomePalette; | ||
| import se.llbit.chunky.world.biome.Biomes; | ||
| import se.llbit.chunky.world.worldformat.WorldFormats; | ||
| import se.llbit.json.*; | ||
| import se.llbit.log.Log; | ||
| import se.llbit.math.*; | ||
|
|
@@ -190,7 +191,7 @@ public class Scene implements JsonSerializable, Refreshable { | |
| */ | ||
| protected int rayDepth = PersistentSettings.getRayDepthDefault(); | ||
| protected String worldPath = ""; | ||
| protected int worldDimension = 0; | ||
| protected String worldDimension = PersistentSettings.DEFAULT_DIMENSION; | ||
| protected RenderMode mode = RenderMode.PREVIEW; | ||
| protected int dumpFrequency = DEFAULT_DUMP_FREQUENCY; | ||
| protected boolean saveSnapshots = false; | ||
|
|
@@ -543,11 +544,8 @@ public synchronized void loadScene(RenderContext context, String sceneName, Task | |
| loadedWorld = EmptyWorld.INSTANCE; | ||
| if (!worldPath.isEmpty()) { | ||
| File worldDirectory = new File(worldPath); | ||
| if (World.isWorldDir(worldDirectory)) { | ||
| loadedWorld = World.loadWorld(worldDirectory, worldDimension, World.LoggedWarnings.NORMAL); | ||
| } else { | ||
| Log.info("Could not load world: " + worldPath); | ||
| } | ||
| loadedWorld = WorldFormats.createWorld(worldDirectory).orElse(EmptyWorld.INSTANCE); | ||
| loadedWorld.loadDimension(this.worldDimension); | ||
| } | ||
|
|
||
| loadDump(context, taskTracker); | ||
|
|
@@ -761,7 +759,7 @@ public synchronized void reloadChunks(TaskTracker taskTracker) { | |
| Log.warn("Can not reload chunks for scene - world directory not found!"); | ||
| return; | ||
| } | ||
| loadedWorld = World.loadWorld(loadedWorld.getWorldDirectory(), worldDimension, World.LoggedWarnings.NORMAL); | ||
| loadedWorld.loadDimension(worldDimension); | ||
| loadChunks(taskTracker, loadedWorld, chunks); | ||
| refresh(); | ||
| } | ||
|
|
@@ -794,7 +792,7 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec | |
|
|
||
| loadedWorld = world; | ||
| worldPath = loadedWorld.getWorldDirectory().getAbsolutePath(); | ||
| worldDimension = world.currentDimensionId(); | ||
| worldDimension = world.currentDimension().getId(); | ||
|
|
||
| if (chunksToLoad.isEmpty()) { | ||
| return; | ||
|
|
@@ -821,7 +819,7 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec | |
| } | ||
|
|
||
| for (RegionPosition region : regions) { | ||
| dimension.getRegion(region).parse(yMin, yMax); | ||
| ((JavaDimension) dimension).getRegion(region).parse(yMin, yMax); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since regions are handy for selecting many chunks, could we add virtual regions (= squares of many chunks) to Bedrock? As a UI feature, not as in actually loading regions, if the world format doesn't actually have regions.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea being abstract out a virtual region that also happens to be the same size as a java region? |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -1192,7 +1190,8 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec | |
|
|
||
| if (!chunkData.isEmpty()){ | ||
| nonEmptyChunks.add(cp); | ||
| if (dimension.getChunk(cp).getVersion() == ChunkVersion.PRE_FLATTENING) { | ||
| Chunk chunk = dimension.getChunk(cp); | ||
| if (chunk instanceof JavaChunk javaChunk && javaChunk.getVersion() == ChunkVersion.PRE_FLATTENING) { | ||
| legacyChunks.add(cp); | ||
| } | ||
| } | ||
|
|
@@ -2907,7 +2906,14 @@ else if(waterShader.equals("SIMPLEX")) | |
| if (json.get("world").isObject()) { | ||
| JsonObject world = json.get("world").object(); | ||
| worldPath = world.get("path").stringValue(worldPath); | ||
| worldDimension = world.get("dimension").intValue(worldDimension); | ||
|
|
||
| String dimensionString = world.get("dimension").stringValue(""); | ||
| if (dimensionString.isEmpty()) { | ||
| // legacy int-based dimension indices | ||
| worldDimension = JavaWorld.VANILLA_DIMENSION_IDX_TO_ID.get(world.get("dimension").intValue(0)); | ||
| } else { | ||
| worldDimension = dimensionString; | ||
| } | ||
| } | ||
|
|
||
| if (json.get("camera").isObject()) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be moved to the world? Seems to be world format / chunk data dependant.