dont crash on blockstate deserialization errors
This commit is contained in:
@@ -363,8 +363,13 @@ public class Mapper {
|
|||||||
if (compound.getInt("id", -1) != id) {
|
if (compound.getInt("id", -1) != id) {
|
||||||
throw new IllegalStateException("Encoded id != expected id");
|
throw new IllegalStateException("Encoded id != expected id");
|
||||||
}
|
}
|
||||||
BlockState state = BlockState.CODEC.parse(NbtOps.INSTANCE, compound.getCompound("block_state").orElseThrow()).getOrThrow();
|
var state = BlockState.CODEC.parse(NbtOps.INSTANCE, compound.getCompound("block_state").orElseThrow());
|
||||||
return new StateEntry(id, state);
|
if (state.isError()) {
|
||||||
|
Logger.error("Could not decode blockstate setting to air. id:" + id + " error: " + state.error().get().message());
|
||||||
|
return new StateEntry(id, Blocks.AIR.getDefaultState());
|
||||||
|
} else {
|
||||||
|
return new StateEntry(id, state.getOrThrow());
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user