use of amerifrance.guideapi.api.impl.abstraction.EntryAbstract 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;
}
use of amerifrance.guideapi.api.impl.abstraction.EntryAbstract in project Guide-API by TeamAmeriFrance.
the class GuiEntry method onGuiClosed.
@Override
public void onGuiClosed() {
super.onGuiClosed();
ResourceLocation key = null;
for (Map.Entry<ResourceLocation, EntryAbstract> mapEntry : category.entries.entrySet()) if (mapEntry.getValue().equals(entry))
key = mapEntry.getKey();
if (key != null)
PacketHandler.INSTANCE.sendToServer(new PacketSyncEntry(book.getCategoryList().indexOf(category), key, pageNumber));
}
use of amerifrance.guideapi.api.impl.abstraction.EntryAbstract in project Guide-API by TeamAmeriFrance.
the class GuiCategory method initGui.
@Override
public void initGui() {
super.initGui();
this.buttonList.clear();
this.entryWrapperMap.clear();
guiLeft = (this.width - this.xSize) / 2;
guiTop = (this.height - this.ySize) / 2;
this.buttonList.add(buttonBack = new ButtonBack(0, guiLeft + xSize / 6, guiTop, this));
this.buttonList.add(buttonNext = new ButtonNext(1, guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, this));
this.buttonList.add(buttonPrev = new ButtonPrev(2, guiLeft + xSize / 5, guiTop + 5 * ySize / 6, this));
int eX = guiLeft + 37;
int eY = guiTop + 15;
int i = 0;
int pageNumber = 0;
List<EntryAbstract> entries = Lists.newArrayList(category.entries.values());
for (EntryAbstract entry : entries) {
entry.onInit(book, category, this, player, bookStack);
entryWrapperMap.put(pageNumber, new EntryWrapper(this, book, category, entry, eX, eY, 4 * xSize / 6, 10, player, this.fontRenderer, bookStack));
eY += 13;
i++;
if (i >= 11) {
i = 0;
eY = guiTop + 15;
pageNumber++;
}
}
}
use of amerifrance.guideapi.api.impl.abstraction.EntryAbstract in project Guide-API by TeamAmeriFrance.
the class TestBook method buildBook.
@Nullable
@Override
public Book buildBook() {
book = new Book();
book.setAuthor("TehNut");
book.setColor(Color.BLUE);
book.setDisplayName("Display Name");
book.setTitle("Title message");
book.setWelcomeMessage("Is this still a thing?");
List<CategoryAbstract> categories = Lists.newArrayList();
Map<ResourceLocation, EntryAbstract> entries = Maps.newHashMap();
List<IPage> pages = Lists.newArrayList();
pages.add(new PageText("Hello, this is\nsome text"));
pages.add(new PageFurnaceRecipe(Blocks.COBBLESTONE));
pages.add(new PageIRecipe(new ShapedOreRecipe(Items.ACACIA_BOAT, "X X", "XXX", 'X', "plankWood")));
Entry entry = new EntryItemStack(pages, "test.entry.name", new ItemStack(Items.POTATO));
entries.put(new ResourceLocation("guideapi", "entry"), entry);
categories.add(new CategoryItemStack(entries, "test.category.name", new ItemStack(Items.BANNER)));
book.setCategoryList(categories);
book.setRegistryName(new ResourceLocation("guideapi", "test_book"));
return book;
}
Aggregations