| 1 | package net.minecraft.world;
|
| 2 |
|
| 3 | public class WorldType
|
| 4 | {
|
| 5 | /** List of world types. */
|
| 6 | public static final WorldType[] worldTypes = new WorldType[16];
|
| 7 |
|
| 8 | /** Default world type. */
|
| 9 | public static final WorldType DEFAULT = (new WorldType(0, "default", 1)).setVersioned();
|
| 10 |
|
| 11 | /** Flat world type. */
|
| 12 | public static final WorldType FLAT = new WorldType(1, "flat");
|
| 13 |
|
| 14 | /** Large Biome world Type. */
|
| 15 | public static final WorldType LARGE_BIOMES = new WorldType(2, "largeBiomes");
|
| 16 |
|
| 17 | /** amplified world type */
|
| 18 | public static final WorldType AMPLIFIED = (new WorldType(3, "amplified")).setNotificationData();
|
| 19 | public static final WorldType CUSTOMIZED = new WorldType(4, "customized");
|
| 20 | public static final WorldType DEBUG_WORLD = new WorldType(5, "debug_all_block_states");
|
| 21 |
|
| 22 | /** Default (1.1) world type. */
|
| 23 | public static final WorldType DEFAULT_1_1 = (new WorldType(8, "default_1_1", 0)).setCanBeCreated(false);
|
| 24 |
|
| 25 | /** ID for this world type. */
|
| 26 | private final int worldTypeId;
|
| 27 | private final String worldType;
|
| 28 |
|
| 29 | /** The int version of the ChunkProvider that generated this world. */
|
| 30 | private final int generatorVersion;
|
| 31 |
|
| 32 | /**
|
| 33 | * Whether this world type can be generated. Normally true; set to false for out-of-date generator versions.
|
| 34 | */
|
| 35 | private boolean canBeCreated;
|
| 36 |
|
| 37 | /** Whether this WorldType has a version or not. */
|
| 38 | private boolean isWorldTypeVersioned;
|
| 39 | private boolean hasNotificationData;
|
| 40 |
|
| 41 | private WorldType(int id, String name)
|
| 42 | {
|
| 43 | this(id, name, 0);
|
| 44 | }
|
| 45 |
|
| 46 | private WorldType(int id, String name, int version)
|
| 47 | {
|
| 48 | this.worldType = name;
|
| 49 | this.generatorVersion = version;
|
| 50 | this.canBeCreated = true;
|
| 51 | this.worldTypeId = id;
|
| 52 | worldTypes[id] = this;
|
| 53 | }
|
| 54 |
|
| 55 | public String getWorldTypeName()
|
| 56 | {
|
| 57 | return this.worldType;
|
| 58 | }
|
| 59 |
|
| 60 | /**
|
| 61 | * Gets the translation key for the name of this world type.
|
| 62 | */
|
| 63 | public String getTranslateName()
|
| 64 | {
|
| 65 | return "generator." + this.worldType;
|
| 66 | }
|
| 67 |
|
| 68 | /**
|
| 69 | * Gets the translation key for the info text for this world type.
|
| 70 | */
|
| 71 | public String getTranslatedInfo()
|
| 72 | {
|
| 73 | return this.getTranslateName() + ".info";
|
| 74 | }
|
| 75 |
|
| 76 | /**
|
| 77 | * Returns generatorVersion.
|
| 78 | */
|
| 79 | public int getGeneratorVersion()
|
| 80 | {
|
| 81 | return this.generatorVersion;
|
| 82 | }
|
| 83 |
|
| 84 | public WorldType getWorldTypeForGeneratorVersion(int version)
|
| 85 | {
|
| 86 | return this == DEFAULT && version == 0 ? DEFAULT_1_1 : this;
|
| 87 | }
|
| 88 |
|
| 89 | /**
|
| 90 | * Sets canBeCreated to the provided value, and returns this.
|
| 91 | */
|
| 92 | private WorldType setCanBeCreated(boolean enable)
|
| 93 | {
|
| 94 | this.canBeCreated = enable;
|
| 95 | return this;
|
| 96 | }
|
| 97 |
|
| 98 | /**
|
| 99 | * Gets whether this WorldType can be used to generate a new world.
|
| 100 | */
|
| 101 | public boolean getCanBeCreated()
|
| 102 | {
|
| 103 | return this.canBeCreated;
|
| 104 | }
|
| 105 |
|
| 106 | /**
|
| 107 | * Flags this world type as having an associated version.
|
| 108 | */
|
| 109 | private WorldType setVersioned()
|
| 110 | {
|
| 111 | this.isWorldTypeVersioned = true;
|
| 112 | return this;
|
| 113 | }
|
| 114 |
|
| 115 | /**
|
| 116 | * Returns true if this world Type has a version associated with it.
|
| 117 | */
|
| 118 | public boolean isVersioned()
|
| 119 | {
|
| 120 | return this.isWorldTypeVersioned;
|
| 121 | }
|
| 122 |
|
| 123 | public static WorldType parseWorldType(String type)
|
| 124 | {
|
| 125 | for (int i = 0; i < worldTypes.length; ++i)
|
| 126 | {
|
| 127 | if (worldTypes[i] != null && worldTypes[i].worldType.equalsIgnoreCase(type))
|
| 128 | {
|
| 129 | return worldTypes[i];
|
| 130 | }
|
| 131 | }
|
| 132 |
|
| 133 | return null;
|
| 134 | }
|
| 135 |
|
| 136 | public int getWorldTypeID()
|
| 137 | {
|
| 138 | return this.worldTypeId;
|
| 139 | }
|
| 140 |
|
| 141 | /**
|
| 142 | * returns true if selecting this worldtype from the customize menu should display the generator.[worldtype].info
|
| 143 | * message
|
| 144 | */
|
| 145 | public boolean showWorldInfoNotice()
|
| 146 | {
|
| 147 | return this.hasNotificationData;
|
| 148 | }
|
| 149 |
|
| 150 | /**
|
| 151 | * enables the display of generator.[worldtype].info message on the customize world menu
|
| 152 | */
|
| 153 | private WorldType setNotificationData()
|
| 154 | {
|
| 155 | this.hasNotificationData = true;
|
| 156 | return this;
|
| 157 | }
|
| 158 | }
|
| 159 |
|