Move heightmap code above block entity check

This commit is contained in:
KennyTV 2020-04-22 21:46:14 +02:00
parent f7b841faf3
commit 867cd4ee39
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 9 additions and 9 deletions

View File

@ -55,6 +55,14 @@ public class WorldPackets {
} }
} }
CompoundTag heightMaps = chunk.getHeightMap();
for (String key : heightMaps.keySet()) {
LongArrayTag heightMap = heightMaps.get(key);
int[] heightMapData = new int[256];
CompactArrayUtil.iterateCompactArray(9, heightMapData.length, heightMap.getValue(), (i, v) -> heightMapData[i] = v);
heightMap.setValue(CompactArrayUtil.createCompactArrayWithPadding(9, heightMapData.length, i -> heightMapData[i]));
}
if (chunk.getBlockEntities() == null) return; if (chunk.getBlockEntities() == null) return;
for (CompoundTag blockEntity : chunk.getBlockEntities()) { for (CompoundTag blockEntity : chunk.getBlockEntities()) {
StringTag idTag = blockEntity.get("id"); StringTag idTag = blockEntity.get("id");
@ -84,14 +92,6 @@ public class WorldPackets {
blockEntity.put(skullOwnerTag); blockEntity.put(skullOwnerTag);
} }
} }
CompoundTag heightMaps = chunk.getHeightMap();
for (String key : heightMaps.keySet()) {
LongArrayTag heightMap = heightMaps.get(key);
int[] heightMapData = new int[256];
CompactArrayUtil.iterateCompactArray(9, heightMapData.length, heightMap.getValue(), (i, v) -> heightMapData[i] = v);
heightMap.setValue(CompactArrayUtil.createCompactArrayWithPadding(9, heightMapData.length, i -> heightMapData[i]));
}
}); });
} }
}); });

View File

@ -4,7 +4,7 @@ import java.util.function.IntToLongFunction;
public class CompactArrayUtil { public class CompactArrayUtil {
//Oh no //Oh no
private static final int[] MAGIC = new int[] { private static final int[] MAGIC = {
-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE, -1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE,
0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756, 0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756,
0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0, 0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0,