| 1 | package net.minecraft.world.level.storage;
|
| 2 |
|
| 3 | import com.mojang.serialization.Lifecycle;
|
| 4 | import java.util.Locale;
|
| 5 | import java.util.Set;
|
| 6 | import java.util.UUID;
|
| 7 | import net.minecraft.CrashReportCategory;
|
| 8 | import net.minecraft.nbt.CompoundTag;
|
| 9 | import net.minecraft.world.Difficulty;
|
| 10 | import net.minecraft.world.flag.FeatureFlagSet;
|
| 11 | import net.minecraft.world.level.GameType;
|
| 12 | import net.minecraft.world.level.LevelSettings;
|
| 13 | import net.minecraft.world.level.WorldDataConfiguration;
|
| 14 | import org.jspecify.annotations.Nullable;
|
| 15 |
|
| 16 | public interface WorldData {
|
| 17 | int ANVIL_VERSION_ID = 19133;
|
| 18 | int MCREGION_VERSION_ID = 19132;
|
| 19 |
|
| 20 | WorldDataConfiguration getDataConfiguration();
|
| 21 |
|
| 22 | void setDataConfiguration(final WorldDataConfiguration dataConfiguration);
|
| 23 |
|
| 24 | boolean wasModded();
|
| 25 |
|
| 26 | Set<String> getKnownServerBrands();
|
| 27 |
|
| 28 | Set<String> getRemovedFeatureFlags();
|
| 29 |
|
| 30 | void setModdedInfo(final String serverBrand, final boolean isModded);
|
| 31 |
|
| 32 | default void fillCrashReportCategory(final CrashReportCategory category) {
|
| 33 | category.setDetail("Known server brands", () -> String.join(", ", this.getKnownServerBrands()));
|
| 34 | category.setDetail("Removed feature flags", () -> String.join(", ", this.getRemovedFeatureFlags()));
|
| 35 | category.setDetail("Level was modded", () -> Boolean.toString(this.wasModded()));
|
| 36 | category.setDetail("Level storage version", () -> {
|
| 37 | int version = this.getVersion();
|
| 38 | return String.format(Locale.ROOT, "0x%05X - %s", version, this.getStorageVersionName(version));
|
| 39 | });
|
| 40 | }
|
| 41 |
|
| 42 | default String getStorageVersionName(final int version) {
|
| 43 | return switch (version) {
|
| 44 | case 19132 -> "McRegion";
|
| 45 | case 19133 -> "Anvil";
|
| 46 | default -> "Unknown?";
|
| 47 | };
|
| 48 | }
|
| 49 |
|
| 50 | ServerLevelData overworldData();
|
| 51 |
|
| 52 | LevelSettings getLevelSettings();
|
| 53 |
|
| 54 | CompoundTag createTag(@Nullable UUID singlePlayerUUID);
|
| 55 |
|
| 56 | boolean isHardcore();
|
| 57 |
|
| 58 | int getVersion();
|
| 59 |
|
| 60 | String getLevelName();
|
| 61 |
|
| 62 | GameType getGameType();
|
| 63 |
|
| 64 | void setGameType(GameType gameType);
|
| 65 |
|
| 66 | boolean isAllowCommands();
|
| 67 |
|
| 68 | void setAllowCommands(final boolean allowCommands);
|
| 69 |
|
| 70 | Difficulty getDifficulty();
|
| 71 |
|
| 72 | void setDifficulty(final Difficulty difficulty);
|
| 73 |
|
| 74 | boolean isDifficultyLocked();
|
| 75 |
|
| 76 | void setDifficultyLocked(final boolean difficultyLocked);
|
| 77 |
|
| 78 | @Nullable UUID getSinglePlayerUUID();
|
| 79 |
|
| 80 | boolean isFlatWorld();
|
| 81 |
|
| 82 | boolean isDebugWorld();
|
| 83 |
|
| 84 | Lifecycle worldGenSettingsLifecycle();
|
| 85 |
|
| 86 | default FeatureFlagSet enabledFeatures() {
|
| 87 | return this.getDataConfiguration().enabledFeatures();
|
| 88 | }
|
| 89 | }
|
| 90 |
|