use of io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem in project Slimefun4 by Slimefun.
the class SurvivalSlimefunGuide method displayItem.
@Override
@ParametersAreNonnullByDefault
public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
Player p = profile.getPlayer();
if (p == null) {
return;
}
ChestMenu menu = create(p);
Optional<String> wiki = item.getWikipage();
if (wiki.isPresent()) {
menu.addItem(8, new CustomItemStack(Material.KNOWLEDGE_BOOK, ChatColor.WHITE + Slimefun.getLocalization().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> {
pl.closeInventory();
ChatUtils.sendURL(pl, wiki.get());
return false;
});
}
AsyncRecipeChoiceTask task = new AsyncRecipeChoiceTask();
if (addToHistory) {
profile.getGuideHistory().add(item);
}
ItemStack result = item.getRecipeOutput();
RecipeType recipeType = item.getRecipeType();
ItemStack[] recipe = item.getRecipe();
displayItem(menu, profile, p, item, result, recipeType, recipe, task);
if (item instanceof RecipeDisplayItem) {
displayRecipes(p, profile, menu, (RecipeDisplayItem) item, 0);
}
menu.open(p);
if (!task.isEmpty()) {
task.start(menu.toInventory());
}
}
Aggregations