Крафт

Версия Minecraft
1.7.10
124
1
0
Подскажите пожалуйста, как получить ItemStack блока или предмета, зная только его нелокализованное имя (например item.bread).
 

timaxa007

Модератор
5,831
409
672
Код:
	public static final ItemStack getItem(String name) {
		if (name == null) return null;

		Iterator iterator = Item.itemRegistry.iterator();

		while (iterator.hasNext()) {
			Item item = (Item)iterator.next();

			if (item == null) continue;

			if (item.getUnlocalizedName().equals(name)) return new ItemStack(item);
		}

		return null;
	}
ItemStack itemStack = getItem("item.bread");
if (itemStack != null) {
}
 
Сверху