mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Handle empty list case, let the try-catch handle NPE
This commit is contained in:
parent
bad206d504
commit
efc135f48a
@ -125,16 +125,8 @@ public class AnvilLoader implements IChunkLoader {
|
|||||||
for (int y = 0; y < Chunk.CHUNK_SECTION_SIZE; y++) {
|
for (int y = 0; y < Chunk.CHUNK_SECTION_SIZE; y++) {
|
||||||
try {
|
try {
|
||||||
final BlockState blockState = section.get(x, y, z);
|
final BlockState blockState = section.get(x, y, z);
|
||||||
Block block = Block.fromNamespaceId(blockState.getName());
|
chunk.setBlock(x, y + yOffset, z,
|
||||||
if (block == null) {
|
Block.fromNamespaceId(blockState.getName()).withProperties(blockState.getProperties()));
|
||||||
// Invalid block
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final var properties = blockState.getProperties();
|
|
||||||
if (!properties.isEmpty()) {
|
|
||||||
block = block.withProperties(properties);
|
|
||||||
}
|
|
||||||
chunk.setBlock(x, y + yOffset, z, block);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
EXCEPTION_MANAGER.handleException(e);
|
EXCEPTION_MANAGER.handleException(e);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,9 @@ final class BlockImpl implements Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Block withProperties(@NotNull Map<@NotNull String, @NotNull String> properties) {
|
public @NotNull Block withProperties(@NotNull Map<@NotNull String, @NotNull String> properties) {
|
||||||
|
if (properties.isEmpty()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
Block block;
|
Block block;
|
||||||
if (this.properties.size() == properties.size()) {
|
if (this.properties.size() == properties.size()) {
|
||||||
// Map should be complete
|
// Map should be complete
|
||||||
|
Loading…
Reference in New Issue
Block a user