Skip to content

Commit

Permalink
Upgrade Minecraft version to 1.14.4
Browse files Browse the repository at this point in the history
Make 1.13 chunk status and height map types strings instead of enums because they keep changing
Temporarily disable goodies chest for Minecraft 1.13 and higher since it breaks it
Use platform configured on exporter/merger always, instead of platform stored on world, to support merging with a different platform
Skip empty chunks in import or merge
When merging use platform/version of target map; don't change platform/version of .world file
When merging, give error when trying to merge with map which does not support named blocks if the .world file contains named blocks
  • Loading branch information
Captain-Chaos committed Aug 18, 2019
1 parent 77acab9 commit 76d1f39
Show file tree
Hide file tree
Showing 30 changed files with 471 additions and 216 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
*.iml
logs
exporttimings.csv
exporttimings.csv
target
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ private Constants() {
public static final int VERSION_ANVIL = 0x4abd;

public static final int DATA_VERSION_MC_1_12_2 = 1343;
public static final int DATA_VERSION_MC_1_14_2 = 1963;
public static final int DATA_VERSION_MC_1_14_4 = 1976;

// Legacy (pre-MC 1.13) block IDs

Expand Down Expand Up @@ -1101,4 +1101,8 @@ private Constants() {
public static final int DIFFICULTY_EASY = 1;
public static final int DIFFICULTY_NORMAL = 2;
public static final int DIFFICULTY_HARD = 3;

public static final String STATUS_FULL = "full";
public static final String STATUS_LIQUID_CARVERS = "liquid_carvers";
public static final String STATUS_STRUCTURE_STARTS = "structure_starts";
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Level(int mapHeight, Platform platform) {
setInt(TAG_VERSION_, (platform == JAVA_MCREGION) ? VERSION_MCREGION : VERSION_ANVIL);
// TODO: make this dynamic?
if (platform != JAVA_MCREGION) {
int dataVersion = (platform == JAVA_ANVIL) ? DATA_VERSION_MC_1_12_2 : DATA_VERSION_MC_1_14_2;
int dataVersion = (platform == JAVA_ANVIL) ? DATA_VERSION_MC_1_12_2 : DATA_VERSION_MC_1_14_4;
setInt(TAG_DATA_VERSION, dataVersion);
Map<String, Tag> versionTag = new HashMap<>();
versionTag.put(TAG_ID, new IntTag(TAG_ID, dataVersion));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.pepsoft.minecraft;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.jnbt.*;
import org.pepsoft.worldpainter.exporting.MinecraftWorld;
import org.slf4j.Logger;
Expand All @@ -17,7 +18,6 @@

import static java.util.stream.Collectors.toList;
import static org.pepsoft.minecraft.Constants.*;
import static org.pepsoft.minecraft.MC114AnvilChunk.Status.*;
import static org.pepsoft.minecraft.Material.AIR;

/**
Expand All @@ -33,7 +33,7 @@ public MC114AnvilChunk(int xPos, int zPos, int maxHeight) {
this.maxHeight = maxHeight;

sections = new Section[maxHeight >> 4];
heightMaps = new EnumMap<>(HeightmapType.class);
heightMaps = new HashMap<>();
entities = new ArrayList<>();
tileEntities = new ArrayList<>();
readOnly = false;
Expand All @@ -55,7 +55,7 @@ public MC114AnvilChunk(CompoundTag tag, int maxHeight, boolean readOnly) {

sections = new Section[maxHeight >> 4];
List<CompoundTag> sectionTags = getList(TAG_SECTIONS);
// MC 1.13 has chunks without any sections; we're not sure yet if
// MC 1.14 has chunks without any sections; we're not sure yet if
// this is a bug
if (sectionTags != null) {
for (CompoundTag sectionTag: sectionTags) {
Expand All @@ -68,11 +68,11 @@ public MC114AnvilChunk(CompoundTag tag, int maxHeight, boolean readOnly) {
}
}
biomes = getIntArray(TAG_BIOMES);
heightMaps = new EnumMap<>(HeightmapType.class);
heightMaps = new HashMap<>();
Map<String, Tag> heightMapTags = getMap(TAG_HEIGHT_MAPS);
if (heightMapTags != null) {
for (Map.Entry<String, Tag> entry: heightMapTags.entrySet()) {
heightMaps.put(HeightmapType.valueOf(entry.getKey()), ((LongArrayTag) entry.getValue()).getValue());
heightMaps.put(entry.getKey().intern(), ((LongArrayTag) entry.getValue()).getValue());
}
}
List<CompoundTag> entityTags = getList(TAG_ENTITIES);
Expand All @@ -92,7 +92,7 @@ public MC114AnvilChunk(CompoundTag tag, int maxHeight, boolean readOnly) {
// TODO: last update is ignored, is that correct?
xPos = getInt(TAG_X_POS_);
zPos = getInt(TAG_Z_POS_);
status = Status.valueOf(getString(TAG_STATUS).toUpperCase());
status = getString(TAG_STATUS).intern();
lightPopulated = getBoolean(TAG_LIGHT_POPULATED);
inhabitedTime = getLong(TAG_INHABITED_TIME);
liquidTicks = getList(TAG_LIQUID_TICKS);
Expand All @@ -110,15 +110,15 @@ public Section[] getSections() {
return sections;
}

public void setStatus(Status status) {
this.status = status;
public void setStatus(String status) {
this.status = status.intern();
}

public Status getStatus() {
public String getStatus() {
return status;
}

public Map<HeightmapType, long[]> getHeightMaps() {
public Map<String, long[]> getHeightMaps() {
return heightMaps;
}

Expand Down Expand Up @@ -169,14 +169,14 @@ public CompoundTag toNBT() {
setLong(TAG_LAST_UPDATE, System.currentTimeMillis()); // TODO: is this correct?
setInt(TAG_X_POS_, xPos);
setInt(TAG_Z_POS_, zPos);
setString(TAG_STATUS, status.name().toLowerCase());
setString(TAG_STATUS, status);
setBoolean(TAG_LIGHT_POPULATED, lightPopulated);
setLong(TAG_INHABITED_TIME, inhabitedTime);
setList(TAG_LIQUID_TICKS, CompoundTag.class, liquidTicks);

CompoundTag tag = new CompoundTag("", Collections.emptyMap());
tag.setTag(TAG_LEVEL, super.toNBT());
tag.setTag(TAG_DATA_VERSION, new IntTag(TAG_DATA_VERSION, DATA_VERSION_MC_1_14_2));
tag.setTag(TAG_DATA_VERSION, new IntTag(TAG_DATA_VERSION, DATA_VERSION_MC_1_14_4));
return tag;
}

Expand Down Expand Up @@ -325,7 +325,7 @@ public void setBiome(int x, int z, int biome) {

@Override
public boolean isTerrainPopulated() {
return status.ordinal() > LIQUID_CARVED.ordinal();
return ! populatedStatuses.contains(status);
}

@Override
Expand All @@ -335,9 +335,9 @@ public void setTerrainPopulated(boolean terrainPopulated) {
}
// TODO: this is a guess, is this useful?
if (terrainPopulated) {
status = FULL;
status = STATUS_FULL;
} else {
status = LIQUID_CARVERS;
status = STATUS_LIQUID_CARVERS;
}
}

Expand Down Expand Up @@ -573,7 +573,7 @@ public int hashCode() {
*/
@Override
public MC114AnvilChunk clone() {
throw new UnsupportedOperationException("MC114AnvilChunk.clone() not supported");
throw new UnsupportedOperationException("MC113AnvilChunk.clone() not supported");
}

private int getDataByte(byte[] array, int x, int y, int z) {
Expand Down Expand Up @@ -605,7 +605,7 @@ private void setDataByte(byte[] array, int x, int y, int z, int dataValue) {
}

private void writeObject(ObjectOutputStream out) throws IOException {
throw new IOException("MC114AnvilChunk is not serializable");
throw new IOException("MC113AnvilChunk is not serializable");
}

static int blockOffset(int x, int y, int z) {
Expand All @@ -622,8 +622,8 @@ static int blockOffset(int x, int y, int z) {
final List<TileEntity> tileEntities;
final int maxHeight;
long inhabitedTime;
Status status;
final Map<HeightmapType, long[]> heightMaps;
String status;
final Map<String, long[]> heightMaps;
final List<CompoundTag> liquidTicks;

private static final Random RANDOM = new Random();
Expand Down Expand Up @@ -808,7 +808,7 @@ boolean isEmpty() {
}

private void writeObject(ObjectOutputStream out) throws IOException {
throw new IOException("MC114AnvilChunk.Section is not serializable");
throw new IOException("MC113AnvilChunk.Section is not serializable");
}

private Material getMaterial(List<CompoundTag> palette, int index) {
Expand All @@ -830,32 +830,16 @@ private Material getMaterial(List<CompoundTag> palette, int index) {
return Material.get(name, properties);
}

final byte level;
public final byte level;
final byte[] skyLight;
final byte[] blockLight;
final Material[] materials;
}

public enum HeightmapType {
// Observed in generated Minecraft maps. Uses unknown:
LIGHT, LIQUID, RAIN, SOLID, OCEAN_FLOOR, MOTION_BLOCKING_NO_LEAVES, LIGHT_BLOCKING, MOTION_BLOCKING,
OCEAN_FLOOR_WG, WORLD_SURFACE_WG, WORLD_SURFACE
}

/**
* The chunk generation status.
*/
public enum Status {
// 1.13, in this order of generation:
EMPTY, CARVED, LIQUID_CARVED, DECORATED, FULLCHUNK, POSTPROCESSED,
private static final Set<String> populatedStatuses = ImmutableSet.of(
// 1.14:
"features", "light", "full",

// 1.14.2, in order of generation:
STRUCTURE_STARTS, NOISE, LIQUID_CARVERS, FEATURES, LIGHT, FULL,

// Reported by users (TODOMC13: 1.13 or 1.14?):
CARVERS, BIOMES, SPAWN,

// These have not lately been observed and may not (longer) be in use by Minecraft:
HEIGHTMAPS, LIGHTED, FINALIZED, MOBS_SPAWNED
}
// 1.13:
"decorated", "fullchunk", "postprocessed");
}
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ private Object readResolve() throws ObjectStreamException {
public static final Material PUMPKIN_SOUTH_FACE = LEGACY_MATERIALS[((BLK_PUMPKIN) << 4) | (DATA_PUMPKIN_SOUTH_FACE)];
public static final Material PUMPKIN_WEST_FACE = LEGACY_MATERIALS[((BLK_PUMPKIN) << 4) | (DATA_PUMPKIN_WEST_FACE)];

// MC 1.14 block property access helpers
// MC 1.13 block property access helpers

public static final Property<Boolean> SNOWY = new Property<>(MC_SNOWY, Boolean.class);
public static final Property<Boolean> NORTH = new Property<>(MC_NORTH, Boolean.class);
Expand All @@ -1630,7 +1630,7 @@ private Object readResolve() throws ObjectStreamException {
public static final Property<String> SHAPE = new Property<>(MC_SHAPE, String.class);
public static final Property<String> HINGE = new Property<>(MC_HINGE, String.class);

// Modern materials (based on MC 1.14 block names and properties)
// Modern materials (based on MC 1.13 block names and properties)

/**
* A vine with no directions turned on, which is not a valid block in
Expand Down
Loading

0 comments on commit 76d1f39

Please sign in to comment.