This commit is contained in:
Jesse Boyd 2019-04-23 22:56:01 +10:00
parent d97836762d
commit c45d4b58cc
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -173,11 +173,20 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (split.length == 1) { if (split.length == 1) {
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0])); state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]));
} else if (MathMan.isInteger(split[0])) { } else if (MathMan.isInteger(split[0])) {
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1])); int id = Integer.parseInt(split[0]);
int data = Integer.parseInt(split[1]);
if (data < 0 || data >= 16) {
throw new InputParseException("Invalid data " + data);
}
state = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
} else { } else {
BlockType type = BlockTypes.get(split[0].toLowerCase()); BlockType type = BlockTypes.get(split[0].toLowerCase());
if (type != null) { if (type != null) {
state = LegacyMapper.getInstance().getBlockFromLegacy(type.getLegacyCombinedId() >> 4, Integer.parseInt(split[1])); int data = Integer.parseInt(split[1]);
if (data < 0 || data >= 16) {
throw new InputParseException("Invalid data " + data);
}
state = LegacyMapper.getInstance().getBlockFromLegacy(type.getLegacyCombinedId() >> 4, data);
} }
} }
} catch (NumberFormatException ignore) {} } catch (NumberFormatException ignore) {}