ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPageAA.java

96 lines
3.1 KiB
Java
Raw Normal View History

2016-01-05 14:57:50 +01:00
/*
2016-05-16 22:52:27 +02:00
* This file ("BookletPageAA.java") is part of the Actually Additions mod for Minecraft.
2016-01-05 14:57:50 +01:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2016-01-05 14:57:50 +01:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2016-01-05 14:57:50 +01:00
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.item.ItemStack;
2016-03-18 23:47:22 +01:00
import net.minecraft.util.text.TextFormatting;
2016-01-05 14:57:50 +01:00
import java.util.Map;
public class BookletPageAA extends BookletPage{
2016-05-19 20:05:12 +02:00
protected final int localizationKey;
2016-01-05 14:57:50 +01:00
public BookletPageAA(int localizationKey){
this.localizationKey = localizationKey;
}
@Override
public int getID(){
return this.chapter.getPageId(this);
2016-01-05 14:57:50 +01:00
}
@Override
public String getText(){
2016-01-05 14:57:50 +01:00
if(this.hasNoText){
return null;
}
String base = StringUtil.localize("booklet."+ModUtil.MOD_ID+".chapter."+this.chapter.getIdentifier()+".text."+this.localizationKey);
2016-03-18 23:47:22 +01:00
base = base.replaceAll("<imp>", TextFormatting.DARK_GREEN+"");
base = base.replaceAll("<item>", TextFormatting.BLUE+"");
base = base.replaceAll("<r>", TextFormatting.BLACK+"");
2016-01-05 14:57:50 +01:00
base = base.replaceAll("<n>", "\n");
2016-03-18 23:47:22 +01:00
base = base.replaceAll("<i>", TextFormatting.ITALIC+"");
base = base.replaceAll("<tifisgrin>", TextFormatting.DARK_RED+""+TextFormatting.UNDERLINE); //This is fucking important so go read it now
2016-01-05 14:57:50 +01:00
2016-08-02 01:06:21 +02:00
for(Map.Entry<String, String> entry : this.textReplacements.entrySet()){
base = base.replaceAll(entry.getKey(), entry.getValue());
2016-01-05 14:57:50 +01:00
}
return base;
}
@Override
2016-02-01 17:49:55 +01:00
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
2016-01-05 14:57:50 +01:00
}
@Override
2016-02-01 17:49:55 +01:00
public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
2016-01-05 14:57:50 +01:00
}
@Override
public void updateScreen(int ticksElapsed){
}
2016-02-01 17:49:55 +01:00
@Override
public ItemStack[] getItemStacksForPage(){
return null;
}
@Override
public String getClickToSeeRecipeString(){
2016-04-20 21:39:03 +02:00
return TextFormatting.GOLD+StringUtil.localize("booklet."+ModUtil.MOD_ID+".clickToSeeRecipe");
2016-02-01 17:49:55 +01:00
}
2016-01-05 14:57:50 +01:00
public void addToPagesWithItemStackData(){
2016-05-19 20:05:12 +02:00
if(!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_DATA.contains(this)){
2016-01-05 14:57:50 +01:00
ItemStack[] stacks = this.getItemStacksForPage();
if(stacks != null && stacks.length > 0){
//Ensure that there is at least one ItemStack
for(ItemStack stack : stacks){
if(stack != null){
ActuallyAdditionsAPI.addPageWithItemStackData(this);
break;
}
}
}
}
}
}