Add safety checks to prevent itemblocks with invalid metadata turning into invalid blockstates, fixes #382

(Because *some* mod authors are not very careful...)
This commit is contained in:
Electroblob77
2020-03-31 21:42:16 +01:00
parent 1ab674136b
commit 586840aa53
2 changed files with 6 additions and 2 deletions
@@ -107,7 +107,9 @@ public class BlockPedestal extends Block implements ITileEntityProvider {
natural = true;
metadata -= ELEMENT.getAllowedValues().size();
}
return this.getDefaultState().withProperty(ELEMENT, Element.values()[metadata]).withProperty(NATURAL, natural);
Element element = Element.values()[metadata];
if(!ELEMENT.getAllowedValues().contains(element)) return this.getDefaultState().withProperty(NATURAL, natural);
return this.getDefaultState().withProperty(ELEMENT, element).withProperty(NATURAL, natural);
}
@Override