Tries to get an Item by it's name (e.g. minecraft:apple) or a String representation of a numerical ID. If both fail, null is returned.
(String id)
| 97 | * fail, null is returned. |
| 98 | */ |
| 99 | public static Item getByNameOrId(String id) |
| 100 | { |
| 101 | Item item = itemRegistry.getObject(new ResourceLocation(id)); |
| 102 | |
| 103 | if (item == null) |
| 104 | { |
| 105 | try |
| 106 | { |
| 107 | return getItemById(Integer.parseInt(id)); |
| 108 | } |
| 109 | catch (NumberFormatException var3) |
| 110 | { |
| 111 | ; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | return item; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Called when an ItemStack with NBT data is read to potentially that ItemStack's NBT data |
no test coverage detected