MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / getByNameOrId

Method getByNameOrId

src/main/java/net/minecraft/item/Item.java:99–116  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 5

parseItemsMethod · 0.95
detectItemsMethod · 0.95
getObjectMethod · 0.95
readFromNBTMethod · 0.95
readFromNBTMethod · 0.95

Calls 3

getItemByIdMethod · 0.95
getObjectMethod · 0.65
parseIntMethod · 0.45

Tested by

no test coverage detected