Major command changes that don't work yet.

This commit is contained in:
MattBDev
2019-07-05 20:46:48 -04:00
parent ffc2092d93
commit 8108d0a936
399 changed files with 13558 additions and 7985 deletions

View File

@ -83,18 +83,17 @@ public class AnvilChunk13 implements Chunk {
continue;
}
int blocksPerChunkSection = 16 * 16 * 16;
BlockState[] chunkSectionBlocks = new BlockState[blocksPerChunkSection];
blocks[y] = chunkSectionBlocks;
// parse palette
List<CompoundTag> paletteEntries = sectionTag.getList("Palette", CompoundTag.class);
int paletteSize = paletteEntries.size();
if (paletteSize == 0) {
continue;
}
BlockState[] palette = new BlockState[paletteSize];
for (int paletteEntryId = 0; paletteEntryId < paletteSize; paletteEntryId++) {
CompoundTag paletteEntry = paletteEntries.get(paletteEntryId);
BlockType type = BlockTypes.get(paletteEntry.getString("Name"));
if(type == null) {
if (type == null) {
throw new InvalidFormatException("Invalid block type: " + paletteEntry.getString("Name"));
}
BlockState blockState = type.getDefaultState();
@ -121,11 +120,16 @@ public class AnvilChunk13 implements Chunk {
// parse block states
long[] blockStatesSerialized = NBTUtils.getChildTag(sectionTag.getValue(), "BlockStates", LongArrayTag.class).getValue();
int blocksPerChunkSection = 16 * 16 * 16;
BlockState[] chunkSectionBlocks = new BlockState[blocksPerChunkSection];
blocks[y] = chunkSectionBlocks;
long currentSerializedValue = 0;
int nextSerializedItem = 0;
int remainingBits = 0;
for (int blockPos = 0; blockPos < blocksPerChunkSection; blockPos++) {
int localBlockId = 0;
int localBlockId;
if (remainingBits < paletteBits) {
int bitsNextLong = paletteBits - remainingBits;
localBlockId = (int) currentSerializedValue;
@ -159,14 +163,13 @@ public class AnvilChunk13 implements Chunk {
* @throws DataException
*/
private void populateTileEntities() throws DataException {
tileEntities = new HashMap<>();
if (!rootTag.getValue().containsKey("TileEntities")) {
return;
}
List<Tag> tags = NBTUtils.getChildTag(rootTag.getValue(),
"TileEntities", ListTag.class).getValue();
tileEntities = new HashMap<>();
for (Tag tag : tags) {
if (!(tag instanceof CompoundTag)) {
throw new InvalidFormatException("CompoundTag expected in TileEntities");
@ -225,6 +228,7 @@ public class AnvilChunk13 implements Chunk {
if (state.getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
return state.toBaseBlock(tileEntity);
}

View File

@ -187,6 +187,7 @@ public class OldChunk implements Chunk {
}
if (state.getBlockType().getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
if (tileEntity != null) {
return state.toBaseBlock(tileEntity);
}