use of amerifrance.guideapi.gui.GuiHome in project Guide-API by TeamAmeriFrance.
the class CommonProxy method getClientGuiElement.
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
ItemStack bookStack = player.getHeldItem(EnumHand.values()[x]);
if (!bookStack.isEmpty() && bookStack.getItem() instanceof IGuideItem) {
Book book = GuideAPI.getIndexedBooks().get(ID);
try {
if (bookStack.hasTagCompound()) {
NBTTagCompound tagCompound = bookStack.getTagCompound();
if (tagCompound.hasKey(NBTBookTags.ENTRY_TAG) && tagCompound.hasKey(NBTBookTags.CATEGORY_TAG)) {
CategoryAbstract category = book.getCategoryList().get(tagCompound.getInteger(NBTBookTags.CATEGORY_TAG));
EntryAbstract entry = category.entries.get(new ResourceLocation(tagCompound.getString(NBTBookTags.ENTRY_TAG)));
int pageNumber = tagCompound.getInteger(NBTBookTags.PAGE_TAG);
GuiEntry guiEntry = new GuiEntry(book, category, entry, player, bookStack);
guiEntry.pageNumber = pageNumber;
return guiEntry;
} else if (tagCompound.hasKey(NBTBookTags.CATEGORY_TAG)) {
CategoryAbstract category = book.getCategoryList().get(tagCompound.getInteger(NBTBookTags.CATEGORY_TAG));
int entryPage = tagCompound.getInteger(NBTBookTags.ENTRY_PAGE_TAG);
GuiCategory guiCategory = new GuiCategory(book, category, player, bookStack);
guiCategory.entryPage = entryPage;
return guiCategory;
} else {
int categoryNumber = tagCompound.getInteger(NBTBookTags.CATEGORY_PAGE_TAG);
GuiHome guiHome = new GuiHome(book, player, bookStack);
guiHome.categoryPage = categoryNumber;
return guiHome;
}
}
} catch (Exception e) {
// No-op: If the linked content doesn't exist anymore
}
return new GuiHome(book, player, bookStack);
}
return null;
}
Aggregations