Skip to content

Commit

Permalink
Add a button to force the use of GenericChunkData
Browse files Browse the repository at this point in the history
  • Loading branch information
NotStirred committed Oct 10, 2022
1 parent e9baf67 commit 125e095
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import se.llbit.chunky.ui.controller.RenderControlsFxController;
import se.llbit.chunky.ui.dialogs.ShutdownAlert;
import se.llbit.chunky.ui.render.RenderControlsTab;
import se.llbit.chunky.world.World;
import se.llbit.fxutil.Dialogs;
import se.llbit.math.Octree;
import se.llbit.math.bvh.BVH;
Expand Down Expand Up @@ -71,6 +72,7 @@ public class AdvancedTab extends ScrollPane implements RenderControlsTab, Initia
@FXML private ChoiceBox<String> biomeStructureImplementation;
@FXML private IntegerAdjuster gridSize;
@FXML private CheckBox preventNormalEmitterWithSampling;
@FXML private CheckBox genericChunkDataForced;
@FXML private CheckBox hideUnknownBlocks;
@FXML private ChoiceBox<String> rendererSelect;
@FXML private ChoiceBox<String> previewSelect;
Expand Down Expand Up @@ -242,6 +244,13 @@ public PictureExportFormat fromString(String string) {
PersistentSettings.setPreventNormalEmitterWithSampling(newvalue);
});

genericChunkDataForced.setSelected(PersistentSettings.getGenericChunkDataForced());
genericChunkDataForced.setTooltip(new Tooltip("Force the use of GenericChunkData (Can help with some WorldPainter worlds)"));
genericChunkDataForced.selectedProperty().addListener((observable, oldvalue, newvalue) -> {
World.GENERIC_CHUNK_DATA_FORCED = newvalue;
PersistentSettings.setGenericChunkDataForced(newvalue);
});

hideUnknownBlocks.setTooltip(new Tooltip("Hide unknown blocks instead of rendering them as question marks."));
hideUnknownBlocks.selectedProperty().addListener((observable, oldValue, newValue) -> {
scene.setHideUnknownBlocks(newValue);
Expand Down
11 changes: 11 additions & 0 deletions chunky/src/java/se/llbit/chunky/world/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public class World implements Comparable<World> {
public static final int VERSION_21W06A = 2694;
public static final int VERSION_1_12_2 = 1343;

public static boolean GENERIC_CHUNK_DATA_FORCED = false;

protected final Long2ObjectMap<Region> regionMap = new Long2ObjectOpenHashMap<>();

private final File worldDirectory;
Expand Down Expand Up @@ -286,6 +288,15 @@ public synchronized Chunk getChunk(ChunkPosition pos) {
* The provided ChunkData instance may or may not be re-used.
*/
public ChunkData createChunkData(@Nullable ChunkData chunkData, int chunkVersion) {
// the user can force GenericChunkData to fix some chunk version issues by external tools such as WorldPainter
if (GENERIC_CHUNK_DATA_FORCED) {
if(chunkData instanceof GenericChunkData) {
return chunkData;
}
return new GenericChunkData();
}

// only after checking forced do we check against the chunk's version
if(chunkVersion >= World.VERSION_21W06A) {
if(chunkData instanceof GenericChunkData) {
return chunkData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</HBox>
<IntegerAdjuster fx:id="gridSize" />
<CheckBox fx:id="preventNormalEmitterWithSampling" mnemonicParsing="false" text="Prevent normal emitter when using emitter sampling" />
<CheckBox fx:id="genericChunkDataForced" mnemonicParsing="false" text="Force GenericChunkData" />

<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="10.0">
Expand Down
9 changes: 9 additions & 0 deletions lib/src/se/llbit/chunky/PersistentSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,15 @@ public static String getBvhMethod() {
return settings.getString("bvhMethod", "SAH_MA");
}

public static void setGenericChunkDataForced(boolean value) {
settings.setBool("genericChunkDataForced", value);
save();
}

public static boolean getGenericChunkDataForced() {
return settings.getBool("genericChunkDataForced", false);
}

public static void setBiomeStructureImplementation(String implementation) {
settings.setString("biomeStructureImplementation", implementation);
save();
Expand Down

0 comments on commit 125e095

Please sign in to comment.