mnsbabydoll 124 1 0 7 Авг 2017 #1 Подскажите пожалуйста, как получить ItemStack блока или предмета, зная только его нелокализованное имя (например item.bread).
Подскажите пожалуйста, как получить ItemStack блока или предмета, зная только его нелокализованное имя (например item.bread).
timaxa007 Модератор 5,831 409 672 7 Авг 2017 #2 Код: 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) { } Позитивный голос 0 Негативный голос
Код: 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) { }