2015-08-29 23:01:13 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("BookletPage.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package ellpeck.actuallyadditions.booklet.page;
|
|
|
|
|
|
|
|
|
|
import ellpeck.actuallyadditions.booklet.BookletChapter;
|
|
|
|
|
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
|
|
|
|
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
2015-08-30 01:19:03 +02:00
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
2015-08-30 01:19:03 +02:00
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
2015-08-30 05:11:05 +02:00
|
|
|
|
import net.minecraft.client.renderer.RenderHelper;
|
|
|
|
|
import net.minecraft.client.renderer.entity.RenderItem;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-08-30 01:19:03 +02:00
|
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
import org.lwjgl.input.Mouse;
|
2015-08-30 05:11:05 +02:00
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
import org.lwjgl.opengl.GL12;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class BookletPage implements IBookletPage{
|
|
|
|
|
|
|
|
|
|
protected int id;
|
|
|
|
|
protected BookletChapter chapter;
|
|
|
|
|
|
2015-08-30 19:10:10 +02:00
|
|
|
|
private boolean mouseWasDown;
|
|
|
|
|
|
2015-08-29 23:01:13 +02:00
|
|
|
|
public BookletPage(int id){
|
|
|
|
|
this.id = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getID(){
|
|
|
|
|
return this.id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setChapter(BookletChapter chapter){
|
|
|
|
|
this.chapter = chapter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BookletChapter getChapter(){
|
|
|
|
|
return this.chapter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getText(){
|
2015-08-30 01:19:03 +02:00
|
|
|
|
return StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".chapter."+this.chapter.getUnlocalizedName()+".text."+this.id).replaceAll("<imp>", EnumChatFormatting.DARK_GREEN+"").replaceAll("<item>", EnumChatFormatting.BLUE+"").replaceAll("<r>", EnumChatFormatting.BLACK+"");
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void renderPre(GuiBooklet gui, int mouseX, int mouseY){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void render(GuiBooklet gui, int mouseX, int mouseY){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getItemStackForPage(){
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
protected void renderTooltipAndTransfer(GuiBooklet gui, ItemStack stack, int x, int y, boolean checkAndTransfer){
|
|
|
|
|
List list = stack.getTooltip(gui.mc.thePlayer, gui.mc.gameSettings.advancedItemTooltips);
|
|
|
|
|
|
|
|
|
|
for(int k = 0; k < list.size(); ++k){
|
|
|
|
|
if(k == 0){
|
|
|
|
|
list.set(k, stack.getRarity().rarityColor+(String)list.get(k));
|
|
|
|
|
}
|
|
|
|
|
else{
|
2015-08-30 01:19:03 +02:00
|
|
|
|
list.set(k, EnumChatFormatting.GRAY+(String)list.get(k));
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(checkAndTransfer){
|
|
|
|
|
for(IBookletPage page : InitBooklet.pagesWithItemStackData){
|
|
|
|
|
if(page.getItemStackForPage() != null && page.getItemStackForPage().isItemEqual(stack)){
|
2015-08-30 19:10:10 +02:00
|
|
|
|
list.add(EnumChatFormatting.GOLD+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".clickToSeeRecipe"));
|
|
|
|
|
|
|
|
|
|
boolean isDown = Mouse.isButtonDown(0);
|
|
|
|
|
if(!this.mouseWasDown){
|
|
|
|
|
if(isDown){
|
|
|
|
|
gui.openChapter(page.getChapter(), page);
|
|
|
|
|
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
|
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|
2015-08-30 19:10:10 +02:00
|
|
|
|
this.mouseWasDown = isDown;
|
|
|
|
|
|
2015-08-29 23:01:13 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gui.drawHoveringText(list, x, y);
|
|
|
|
|
}
|
2015-08-30 05:11:05 +02:00
|
|
|
|
|
|
|
|
|
protected void renderItem(GuiBooklet gui, ItemStack stack, int x, int y){
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
|
GL11.glEnable(GL11.GL_BLEND);
|
|
|
|
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
RenderHelper.enableGUIStandardItemLighting();
|
|
|
|
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
|
|
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
|
GL11.glTranslated(x, y, 0);
|
|
|
|
|
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, 0, 0);
|
|
|
|
|
RenderItem.getInstance().renderItemOverlayIntoGUI(gui.mc.fontRenderer, gui.mc.getTextureManager(), stack, 0, 0);
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
RenderHelper.disableStandardItemLighting();
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
|
|
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|