Skip to content

Commit

Permalink
fix(blocks): Fix block state not accepting id directly
Browse files Browse the repository at this point in the history
Fixes #114
  • Loading branch information
Marco (Valandur) committed Aug 13, 2018
1 parent 539c9ce commit da6a148
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ public BlockStateDeserializer() {
@Override
public BlockState deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
JsonNode root = p.readValueAsTree();
if (root.path("type").path("id").isMissingNode()) {
return null;
if (root.path("type").isMissingNode()) {
throw new IOException("Missing block type");
}

String typeStr = root.path("type").path("id").asText();
String typeStr = root.path("type").isTextual()
? root.path("type").asText()
: root.path("type").path("id").asText();
Optional<BlockType> optType = Sponge.getRegistry().getType(BlockType.class, typeStr);
if (!optType.isPresent()) {
throw new IOException("Invalid block type " + typeStr);
Expand Down

0 comments on commit da6a148

Please sign in to comment.