Made the all items chapter use all chapters on its own

This commit is contained in:
Ellpeck 2016-11-11 15:21:57 +01:00
parent b295672585
commit 2760c794d6
6 changed files with 24 additions and 5 deletions

View file

@ -77,6 +77,7 @@ public final class ActuallyAdditionsAPI{
public static IBookletEntry entryItemsNonRF;
public static IBookletEntry entryItemsRF;
public static IBookletEntry entryMisc;
//This is added to automatically, you don't need to add anything to this entry
public static IBookletEntry allAndSearch;
//These are getting initialized in Actually Additions' PreInit phase

View file

@ -35,8 +35,6 @@ public class BookletChapter implements IBookletChapter{
this.color = TextFormatting.RESET;
this.entry.addChapter(this);
ActuallyAdditionsAPI.allAndSearch.addChapter(this);
for(IBookletPage page : this.pages){
page.setChapter(this);
}

View file

@ -24,7 +24,7 @@ import java.util.List;
public class BookletEntry implements IBookletEntry{
private final String identifier;
public List<IBookletChapter> chapters = new ArrayList<IBookletChapter>();
private final List<IBookletChapter> chapters = new ArrayList<IBookletChapter>();
private TextFormatting color;
public BookletEntry(String identifier){
@ -61,7 +61,7 @@ public class BookletEntry implements IBookletEntry{
@Override
public List<IBookletChapter> getChaptersForGuiDisplaying(GuiBookletBase gui, String searchBarText){
return this.chapters;
return this.getAllChapters();
}
public BookletEntry setImportant(){

View file

@ -10,9 +10,24 @@
package de.ellpeck.actuallyadditions.mod.booklet.entry;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import java.util.List;
public class BookletEntryAllItems extends BookletEntry{
public BookletEntryAllItems(String identifier){
super(identifier);
}
@Override
public void addChapter(IBookletChapter chapter){
}
@Override
public List<IBookletChapter> getAllChapters(){
return ActuallyAdditionsAPI.ALL_CHAPTERS;
}
}

View file

@ -18,6 +18,8 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.client.config.GuiUtils;
@ -77,6 +79,8 @@ public class ItemDisplay{
public void onMousePress(int button, int mouseX, int mouseY){
if(button == 0 && this.isHovered(mouseX, mouseY)){
if(this.page != null && this.page != this.gui.pages[0] && this.page != this.gui.pages[1]){
this.gui.mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
GuiBooklet gui = BookletUtils.createPageGui(this.gui.previousScreen, this.gui, this.page);
this.gui.mc.displayGuiScreen(gui);
}

View file

@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.mod.blocks.render.*;
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllItems;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
import de.ellpeck.actuallyadditions.mod.event.ClientEvents;
@ -65,7 +66,7 @@ public class ClientProxy implements IProxy{
String bookletText = "";
for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){
if(entry != ActuallyAdditionsAPI.allAndSearch){
if(!(entry instanceof BookletEntryAllItems)){
bookletWordCount += entry.getLocalizedName().split(" ").length;
bookletCharCount += entry.getLocalizedName().length();
bookletText += entry.getLocalizedName()+"\n\n";