[BlockData] Fix fromString no longer returning null when name is invalid
Signed-off-by: Irmo van den Berge <irmo.vandenberge@ziggo.nl>
This commit is contained in:
1 parent
45f9006be2
commit
58aefbbb1f
2 files changed
+17
-1
No files matched your search
@@ -44,11 +44,16 @@ public class BlockDataRegistry {
|
||||
* Obtains immutable BlockData information wrapping particular IBlockData
|
||||
*
|
||||
* @param iBlockData input data
|
||||
* @return Immutable BlockData
|
||||
* @return Immutable BlockData. Null if the input block data is null also.
|
||||
*/
|
||||
public static BlockData fromBlockData(Object iBlockData) {
|
||||
final BlockDataWrapperHook hook = BlockDataWrapperHook.INSTANCE;
|
||||
|
||||
// Protect against null
|
||||
if (iBlockData == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Try to access an already hooked IBlockData first
|
||||
Object accessor;
|
||||
try {
|
||||
|
||||
@@ -358,6 +358,17 @@ public class BlockDataTest {
|
||||
assertEquals("furnace", blockData.getBlockName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidBlockDataFromString() {
|
||||
assertEquals(MaterialUtil.getFirst("DIAMOND_BLOCK", "LEGACY_DIAMOND_BLOCK"),
|
||||
BlockData.fromString("minecraft:diamond_block").getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidBlockDataFromString() {
|
||||
assertNull(BlockData.fromString("invalid_block_data"));
|
||||
}
|
||||
|
||||
private void testSignMaterial(Material material, boolean isWallSign) {
|
||||
assertNotNull(material);
|
||||
BlockData signData = BlockData.fromMaterial(material);
|
||||
|
||||
Reference in new issue
Block a user