Handle empty list case, let the try-catch handle NPE

This commit is contained in:
TheMode 2021-07-20 23:48:13 +02:00
parent bad206d504
commit efc135f48a
2 changed files with 5 additions and 10 deletions

View File

@ -125,16 +125,8 @@ public class AnvilLoader implements IChunkLoader {
for (int y = 0; y < Chunk.CHUNK_SECTION_SIZE; y++) {
try {
final BlockState blockState = section.get(x, y, z);
Block block = Block.fromNamespaceId(blockState.getName());
if (block == null) {
// Invalid block
continue;
}
final var properties = blockState.getProperties();
if (!properties.isEmpty()) {
block = block.withProperties(properties);
}
chunk.setBlock(x, y + yOffset, z, block);
chunk.setBlock(x, y + yOffset, z,
Block.fromNamespaceId(blockState.getName()).withProperties(blockState.getProperties()));
} catch (Exception e) {
EXCEPTION_MANAGER.handleException(e);
}

View File

@ -58,6 +58,9 @@ final class BlockImpl implements Block {
@Override
public @NotNull Block withProperties(@NotNull Map<@NotNull String, @NotNull String> properties) {
if (properties.isEmpty()) {
return this;
}
Block block;
if (this.properties.size() == properties.size()) {
// Map should be complete