Skip to content

Commit

Permalink
Fixes Issue #37
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul19988 committed May 20, 2021
1 parent 0480c23 commit e24ac3f
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 36 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.grinderwolf</groupId>
<artifactId>slimeworldmanager</artifactId>
<packaging>pom</packaging>
<version>2.6.1-SNAPSHOT</version>
<version>2.6.2-SNAPSHOT</version>
<modules>
<module>slimeworldmanager-api</module>
<module>slimeworldmanager-nms-common</module>
Expand Down
2 changes: 1 addition & 1 deletion slimeworldmanager-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>slimeworldmanager</artifactId>
<groupId>com.grinderwolf</groupId>
<version>2.6.1-SNAPSHOT</version>
<version>2.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ public interface SlimeChunkSection {
*/
long[] getBlockStates();

/**
* Returns all the states of the entities of the chunk section, or
* <code>null</code> in case it's a pre 1.13 world.
*
* @return A <code>long[]</code> with every block state.
*/
long[] getEntityStates();

/**
* Returns the block light data.
*
Expand Down
2 changes: 1 addition & 1 deletion slimeworldmanager-classmodifier/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>slimeworldmanager</artifactId>
<groupId>com.grinderwolf</groupId>
<version>2.6.1-SNAPSHOT</version>
<version>2.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion slimeworldmanager-importer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>slimeworldmanager</artifactId>
<groupId>com.grinderwolf</groupId>
<version>2.6.1-SNAPSHOT</version>
<version>2.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>slimeworldmanager-importer</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ private static SlimeChunk readChunk(CompoundTag compound, byte worldVersion) {
NibbleArray blockLightArray = sectionTag.getValue().containsKey("BlockLight") ? new NibbleArray(sectionTag.getByteArrayValue("BlockLight").get()) : null;
NibbleArray skyLightArray = sectionTag.getValue().containsKey("SkyLight") ? new NibbleArray(sectionTag.getByteArrayValue("SkyLight").get()) : null;

sectionArray[index] = new CraftSlimeChunkSection(blocks, dataArray, paletteTag, blockStatesArray, null, blockLightArray, skyLightArray);
sectionArray[index] = new CraftSlimeChunkSection(blocks, dataArray, paletteTag, blockStatesArray, blockLightArray, skyLightArray);
}

for (SlimeChunkSection section : sectionArray) {
Expand Down
2 changes: 1 addition & 1 deletion slimeworldmanager-nms-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>slimeworldmanager</artifactId>
<groupId>com.grinderwolf</groupId>
<version>2.6.1-SNAPSHOT</version>
<version>2.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class CraftSlimeChunkSection implements SlimeChunkSection {
// Post 1.13 block data
private final ListTag<CompoundTag> palette;
private final long[] blockStates;
private final long[] entityStates;

private final NibbleArray blockLight;
private final NibbleArray skyLight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public byte[] serialize() {
// Tile Entities
List<CompoundTag> tileEntitiesList = sortedChunks.stream().flatMap(chunk -> chunk.getTileEntities().stream()).collect(Collectors.toList());
ListTag<CompoundTag> tileEntitiesNbtList = new ListTag<>("tiles", TagType.TAG_COMPOUND, tileEntitiesList);
CompoundTag tileEntitiesCompound = new CompoundTag(tileEntitiesNbtList.getName(), new CompoundMap(Collections.singletonList(tileEntitiesNbtList)));
CompoundTag tileEntitiesCompound = new CompoundTag("", new CompoundMap(Collections.singletonList(tileEntitiesNbtList)));
byte[] tileEntitiesData = serializeCompoundTag(tileEntitiesCompound);
byte[] compressedTileEntitiesData = Zstd.compress(tileEntitiesData);

Expand All @@ -199,7 +199,7 @@ public byte[] serialize() {

if (!entitiesList.isEmpty()) {
ListTag<CompoundTag> entitiesNbtList = new ListTag<>("entities", TagType.TAG_COMPOUND, entitiesList);
CompoundTag entitiesCompound = new CompoundTag(entitiesNbtList.getName(), new CompoundMap(Collections.singletonList(entitiesNbtList)));
CompoundTag entitiesCompound = new CompoundTag("", new CompoundMap(Collections.singletonList(entitiesNbtList)));
byte[] entitiesData = serializeCompoundTag(entitiesCompound);
byte[] compressedEntitiesData = Zstd.compress(entitiesData);

Expand Down
2 changes: 1 addition & 1 deletion slimeworldmanager-nms-v1_16_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>slimeworldmanager</artifactId>
<groupId>com.grinderwolf</groupId>
<version>2.6.1-SNAPSHOT</version>
<version>2.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public SlimeChunkSection[] getSections() {
ListTag<CompoundTag> palette = (ListTag<CompoundTag>) Converter.convertTag("", paletteList);
long[] blockStates = blocksCompound.getLongArray("BlockStates");

sections[sectionId] = new CraftSlimeChunkSection(null, null, palette, blockStates, null, blockLightArray, skyLightArray);
sections[sectionId] = new CraftSlimeChunkSection(null, null, palette, blockStates, blockLightArray, skyLightArray);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion slimeworldmanager-nms-v1_16_R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>slimeworldmanager</artifactId>
<groupId>com.grinderwolf</groupId>
<version>2.6.1-SNAPSHOT</version>
<version>2.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public SlimeChunkSection[] getSections() {
ListTag<CompoundTag> palette = (ListTag<CompoundTag>) Converter.convertTag("", paletteList);
long[] blockStates = blocksCompound.getLongArray("BlockStates");

sections[sectionId] = new CraftSlimeChunkSection(null, null, palette, blockStates, null, blockLightArray, skyLightArray);
sections[sectionId] = new CraftSlimeChunkSection(null, null, palette, blockStates, blockLightArray, skyLightArray);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion slimeworldmanager-nms-v1_16_R3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>slimeworldmanager</artifactId>
<groupId>com.grinderwolf</groupId>
<version>2.6.1-SNAPSHOT</version>
<version>2.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public void save(IProgressUpdate progressUpdate, boolean forceSave, boolean flag

// Update level data
NBTTagCompound compound = new NBTTagCompound();
worldDataServer.a(MinecraftServer.getServer().getCustomRegistry(), compound);
slimeWorld.getExtraData().getValue().put(Converter.convertTag("LevelData", compound));
NBTTagCompound nbtTagCompound = worldDataServer.a(MinecraftServer.getServer().getCustomRegistry(), compound);
slimeWorld.getExtraData().getValue().put(Converter.convertTag("LevelData", nbtTagCompound));

if (MinecraftServer.getServer().isStopped()) { // Make sure the world gets saved before stopping the server by running it from the main thread
save();
Expand Down Expand Up @@ -214,6 +214,8 @@ private Chunk createChunk(SlimeChunk chunk) {
for (CompoundTag tag : tileEntities) {
Optional<String> type = tag.getStringValue("id");

Bukkit.broadcastMessage("TILE: " + type.get() + ".\n" + tag);

// Sometimes null tile entities are saved
if (type.isPresent()) {
BlockPosition blockPosition = new BlockPosition(tag.getIntValue("x").get(), tag.getIntValue("y").get(), tag.getIntValue("z").get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public SlimeChunkSection[] getSections() {
ListTag<CompoundTag> palette = (ListTag<CompoundTag>) Converter.convertTag("", paletteList);
long[] blockStates = blocksCompound.getLongArray("BlockStates");

sections[sectionId] = new CraftSlimeChunkSection(null, null, palette, blockStates, null, blockLightArray, skyLightArray);
sections[sectionId] = new CraftSlimeChunkSection(null, null, palette, blockStates, blockLightArray, skyLightArray);
}
}
}
Expand Down Expand Up @@ -109,7 +109,8 @@ public List<CompoundTag> getTileEntities() {
List<CompoundTag> tileEntities = new ArrayList<>();

for (TileEntity entity : chunk.getTileEntities().values()) {
NBTTagCompound entityNbt = entity.b();
NBTTagCompound entityNbt = new NBTTagCompound();
entity.save(entityNbt);
tileEntities.add((CompoundTag) Converter.convertTag(entityNbt.getString("name"), entityNbt));
}

Expand Down
2 changes: 1 addition & 1 deletion slimeworldmanager-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>slimeworldmanager</artifactId>
<groupId>com.grinderwolf</groupId>
<version>2.6.1-SNAPSHOT</version>
<version>2.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>slimeworldmanager-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private static SlimeChunkSection[] readChunkSections(DataInputStream dataStream,
paletteList.add(readCompoundTag(serializedTag));
}

paletteTag = new ListTag<>("", TagType.TAG_LIST, paletteList);
paletteTag = new ListTag<>("", TagType.TAG_COMPOUND, paletteList);

// Block states
int blockStatesArrayLength = dataStream.readInt();
Expand Down Expand Up @@ -479,7 +479,7 @@ private static SlimeChunkSection[] readChunkSections(DataInputStream dataStream,
dataStream.skip(hypixelBlocksLength);
}

chunkSectionArray[i] = new CraftSlimeChunkSection(blockArray, dataArray, paletteTag, blockStatesArray,null, blockLightArray, skyLightArray);
chunkSectionArray[i] = new CraftSlimeChunkSection(blockArray, dataArray, paletteTag, blockStatesArray, blockLightArray, skyLightArray);
}
}

Expand All @@ -493,10 +493,6 @@ private static CompoundTag readCompoundTag(byte[] serializedCompound) throws IOE

NBTInputStream stream = new NBTInputStream(new ByteArrayInputStream(serializedCompound), NBTInputStream.NO_COMPRESSION, ByteOrder.BIG_ENDIAN);

CompoundTag compoundTag = (CompoundTag) stream.readTag();

// System.out.println("READING TAG: " + compoundTag);

return compoundTag;
return (CompoundTag) stream.readTag();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void upgrade(CraftSlimeWorld world) {

if (!isPowerOfTwo(bitsPerBlock)) {
section = new CraftSlimeChunkSection(null, null, section.getPalette(),
addPadding(4096, bitsPerBlock, section.getBlockStates()), section.getEntityStates(),
addPadding(4096, bitsPerBlock, section.getBlockStates()),
section.getBlockLight(), section.getSkyLight());
chunk.getSections()[sectionIndex] = section;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private static SlimeChunk readChunk(CompoundTag compound, byte worldVersion) {
NibbleArray blockLightArray = sectionTag.getValue().containsKey("BlockLight") ? new NibbleArray(sectionTag.getByteArrayValue("BlockLight").get()) : null;
NibbleArray skyLightArray = sectionTag.getValue().containsKey("SkyLight") ? new NibbleArray(sectionTag.getByteArrayValue("SkyLight").get()) : null;

sectionArray[index] = new CraftSlimeChunkSection(blocks, dataArray, paletteTag, blockStatesArray, null, blockLightArray, skyLightArray);
sectionArray[index] = new CraftSlimeChunkSection(blocks, dataArray, paletteTag, blockStatesArray, blockLightArray, skyLightArray);
}

for (SlimeChunkSection section : sectionArray) {
Expand Down

0 comments on commit e24ac3f

Please sign in to comment.