mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Added Informational Booklet
This commit is contained in:
parent
36d3d7f79f
commit
af5fa6e920
15 changed files with 596 additions and 2 deletions
|
@ -14,6 +14,8 @@ public class InitAchievements{
|
|||
public static final int SMELTING_ACH = 1;
|
||||
public static final int PICKUP_ACH = 2;
|
||||
|
||||
public static int pageNumber;
|
||||
|
||||
public static AchievementPage theAchievementPage;
|
||||
public static ArrayList<Achievement> achievementList = new ArrayList<Achievement>();
|
||||
|
||||
|
@ -25,6 +27,7 @@ public class InitAchievements{
|
|||
}
|
||||
|
||||
theAchievementPage = new AchievementPage(StringUtil.localize("achievement.page."+ModUtil.MOD_ID_LOWER), achievementList.toArray(new Achievement[achievementList.size()]));
|
||||
pageNumber = AchievementPage.getAchievementPages().size();
|
||||
AchievementPage.registerAchievementPage(theAchievementPage);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,14 @@ import ellpeck.actuallyadditions.util.Util;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
public class FoodCrafting{
|
||||
|
||||
public static IRecipe recipePizza;
|
||||
|
||||
public static void init(){
|
||||
|
||||
ItemStack knifeStack = new ItemStack(InitItems.itemKnife, 1, Util.WILDCARD);
|
||||
|
@ -29,7 +32,7 @@ public class FoodCrafting{
|
|||
TheMiscItems.DOUGH.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal()), 1F);
|
||||
|
||||
//Pizza
|
||||
if(ConfigCrafting.PIZZA.isEnabled())
|
||||
if(ConfigCrafting.PIZZA.isEnabled()){
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.PIZZA.ordinal()),
|
||||
"HKH", "MCF", " D ",
|
||||
'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DOUGH.ordinal()),
|
||||
|
@ -38,6 +41,8 @@ public class FoodCrafting{
|
|||
'F', new ItemStack(Items.cooked_fished, 1, Util.WILDCARD),
|
||||
'K', knifeStack,
|
||||
'H', new ItemStack(InitItems.itemFoods, 1, TheFoods.CHEESE.ordinal())));
|
||||
recipePizza = Util.latestIRecipe();
|
||||
}
|
||||
|
||||
//Hamburger
|
||||
if(ConfigCrafting.HAMBURGER.isEnabled())
|
||||
|
|
|
@ -27,6 +27,7 @@ public class CreativeTab extends CreativeTabs{
|
|||
public void displayAllReleventItems(List list){
|
||||
this.list = list;
|
||||
|
||||
add(InitItems.itemLexicon);
|
||||
add(InitBlocks.blockSmileyCloud);
|
||||
|
||||
add(InitBlocks.blockPhantomface);
|
||||
|
|
|
@ -4,6 +4,7 @@ import cpw.mods.fml.common.network.IGuiHandler;
|
|||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import ellpeck.actuallyadditions.ActuallyAdditions;
|
||||
import ellpeck.actuallyadditions.inventory.gui.*;
|
||||
import ellpeck.actuallyadditions.inventory.gui.lexicon.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -126,6 +127,8 @@ public class GuiHandler implements IGuiHandler{
|
|||
return new GuiOreMagnet(entityPlayer.inventory, tile);
|
||||
case CLOUD:
|
||||
return new GuiSmileyCloud(tile, x, y, z, world);
|
||||
case BOOK:
|
||||
return new GuiBooklet();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -155,7 +158,8 @@ public class GuiHandler implements IGuiHandler{
|
|||
ENERVATOR,
|
||||
XP_SOLIDIFIER,
|
||||
ORE_MAGNET,
|
||||
CLOUD
|
||||
CLOUD,
|
||||
BOOK
|
||||
}
|
||||
|
||||
public static void init(){
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package ellpeck.actuallyadditions.inventory.gui.lexicon;
|
||||
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
|
||||
public class BookletChapter{
|
||||
|
||||
public final IBookletPage[] pages;
|
||||
private final String unlocalizedName;
|
||||
public final BookletIndexEntry entry;
|
||||
|
||||
public BookletChapter(String unlocalizedName, BookletIndexEntry entry, IBookletPage... pages){
|
||||
this.pages = pages.clone();
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
entry.addChapter(this);
|
||||
this.entry = entry;
|
||||
|
||||
for(IBookletPage page : this.pages){
|
||||
page.setChapter(this);
|
||||
}
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(){
|
||||
return this.unlocalizedName;
|
||||
}
|
||||
|
||||
public String getLocalizedName(){
|
||||
return StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".chapter."+this.unlocalizedName+".name");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package ellpeck.actuallyadditions.inventory.gui.lexicon;
|
||||
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BookletIndexEntry{
|
||||
|
||||
private final String unlocalizedName;
|
||||
public ArrayList<BookletChapter> chapters = new ArrayList<BookletChapter>();
|
||||
|
||||
public BookletIndexEntry(String unlocalizedName){
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
InitBooklet.entries.add(this);
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(){
|
||||
return this.unlocalizedName;
|
||||
}
|
||||
|
||||
public void addChapter(BookletChapter chapter){
|
||||
this.chapters.add(chapter);
|
||||
}
|
||||
|
||||
public String getLocalizedName(){
|
||||
return StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".indexEntry."+this.unlocalizedName+".name");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package ellpeck.actuallyadditions.inventory.gui.lexicon;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import ellpeck.actuallyadditions.achievement.InitAchievements;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.achievement.GuiAchievements;
|
||||
import net.minecraft.stats.StatFileWriter;
|
||||
|
||||
public class GuiAAAchievements extends GuiAchievements{
|
||||
|
||||
public GuiAAAchievements(GuiScreen screen, StatFileWriter writer){
|
||||
super(screen, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* (Partially excerpted from Botania with permission, thanks!)
|
||||
*/
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
ReflectionHelper.setPrivateValue(GuiAchievements.class, this, InitAchievements.pageNumber, "currentPage");
|
||||
((GuiButton)buttonList.get(1)).displayString = InitAchievements.theAchievementPage.getName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,271 @@
|
|||
package ellpeck.actuallyadditions.inventory.gui.lexicon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.config.GuiConfiguration;
|
||||
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBooklet extends GuiScreen{
|
||||
|
||||
public static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiBooklet");
|
||||
public FontRenderer unicodeRenderer;
|
||||
|
||||
public int xSize;
|
||||
public int ySize;
|
||||
public int guiLeft;
|
||||
public int guiTop;
|
||||
|
||||
public IBookletPage currentPage;
|
||||
public BookletChapter currentChapter;
|
||||
public BookletIndexEntry currentIndexEntry;
|
||||
|
||||
private static final int BUTTON_ACHIEVEMENTS_ID = -2;
|
||||
private static final int BUTTON_CONFIG_ID = -1;
|
||||
private static final int BUTTON_FORWARD_ID = 0;
|
||||
private static final int BUTTON_BACK_ID = 1;
|
||||
private static final int BUTTON_RETURN_ID = 2;
|
||||
private static final int CHAPTER_BUTTONS_START = 3;
|
||||
|
||||
public GuiBooklet(){
|
||||
this.xSize = 146;
|
||||
this.ySize = 180;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui(){
|
||||
this.guiLeft = (this.width-this.xSize)/2;
|
||||
this.guiTop = (this.height-this.ySize)/2;
|
||||
|
||||
this.unicodeRenderer = new FontRenderer(this.mc.gameSettings, new ResourceLocation("textures/font/ascii.png"), this.mc.renderEngine, true);
|
||||
|
||||
this.buttonList.add(new TexturedButton(BUTTON_FORWARD_ID, this.guiLeft+this.xSize, this.guiTop+this.ySize+2, 164, 0, 18, 10));
|
||||
this.buttonList.add(new TexturedButton(BUTTON_BACK_ID, this.guiLeft-18, this.guiTop+this.ySize+2, 146, 0, 18, 10));
|
||||
this.buttonList.add(new TexturedButton(BUTTON_RETURN_ID, this.guiLeft+this.xSize/2-7, this.guiTop+this.ySize+2, 182, 0, 15, 10));
|
||||
|
||||
for(int i = 0; i < 12; i++){
|
||||
this.buttonList.add(new IndexButton(this.unicodeRenderer, CHAPTER_BUTTONS_START+i, guiLeft+13, guiTop+15+(i*11), 120, 10, ""));
|
||||
}
|
||||
|
||||
this.buttonList.add(new TexturedButton(BUTTON_ACHIEVEMENTS_ID, this.guiLeft+138, this.guiTop, 0, 0, 8, 8));
|
||||
this.buttonList.add(new TexturedButton(BUTTON_CONFIG_ID, this.guiLeft+138, this.guiTop+10, 0, 0, 8, 8));
|
||||
|
||||
this.currentPage = null;
|
||||
this.currentChapter = null;
|
||||
this.currentIndexEntry = null;
|
||||
this.openIndexEntry(null);
|
||||
}
|
||||
|
||||
private GuiButton getButton(int id){
|
||||
return (GuiButton)this.buttonList.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderToolTip(ItemStack stack, int x, int y){
|
||||
super.renderToolTip(stack, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float f){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(resLoc);
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if(this.currentIndexEntry != null){
|
||||
if(this.currentChapter == null){
|
||||
this.drawCenteredString(this.fontRendererObj, this.currentIndexEntry.getLocalizedName(), this.guiLeft+this.xSize/2, this.guiTop-8, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
else
|
||||
this.drawCenteredString(this.fontRendererObj, this.currentChapter.getLocalizedName(), this.guiLeft+this.xSize/2, this.guiTop-8, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
else
|
||||
this.drawCenteredString(this.fontRendererObj, StringUtil.localize("itemGroup."+ModUtil.MOD_ID_LOWER), this.guiLeft+this.xSize/2, this.guiTop-8, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
|
||||
super.drawScreen(x, y, f);
|
||||
|
||||
if(this.currentIndexEntry != null && this.currentChapter != null && this.currentPage != null){
|
||||
this.currentPage.render(this, x, y);
|
||||
}
|
||||
|
||||
//Achievements Hover Text
|
||||
if(x >= this.guiLeft+138 && x <= this.guiLeft+138+8 && y >= this.guiTop && y <= this.guiTop+8){
|
||||
this.func_146283_a(Collections.singletonList("Show Achievements"), x, y);
|
||||
}
|
||||
//Config Hover Text
|
||||
if(x >= this.guiLeft+138 && x <= this.guiLeft+138+8 && y >= this.guiTop+10 && y <= this.guiTop+10+8){
|
||||
this.func_146283_a(Collections.singletonList("Show Config"), x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private IBookletPage getNextPage(BookletChapter chapter, IBookletPage currentPage){
|
||||
for(int i = 0; i < chapter.pages.length; i++){
|
||||
if(chapter.pages[i] == currentPage){
|
||||
if(i+1 < chapter.pages.length){
|
||||
return chapter.pages[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private IBookletPage getPrevPage(BookletChapter chapter, IBookletPage currentPage){
|
||||
for(int i = 0; i < chapter.pages.length; i++){
|
||||
if(chapter.pages[i] == currentPage){
|
||||
if(i-1 >= 0){
|
||||
return chapter.pages[i-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
if(button.id == BUTTON_CONFIG_ID){
|
||||
mc.displayGuiScreen(new GuiConfiguration(this));
|
||||
}
|
||||
else if(button.id == BUTTON_ACHIEVEMENTS_ID){
|
||||
mc.displayGuiScreen(new GuiAAAchievements(this, mc.thePlayer.getStatFileWriter()));
|
||||
}
|
||||
else if(button.id == BUTTON_FORWARD_ID){
|
||||
IBookletPage page = this.getNextPage(this.currentChapter, this.currentPage);
|
||||
if(page != null) this.currentPage = page;
|
||||
}
|
||||
else if(button.id == BUTTON_BACK_ID){
|
||||
IBookletPage page = this.getPrevPage(this.currentChapter, this.currentPage);
|
||||
if(page != null) this.currentPage = page;
|
||||
}
|
||||
else if(button.id == BUTTON_RETURN_ID){
|
||||
if(this.currentChapter != null){
|
||||
this.openIndexEntry(this.currentChapter.entry);
|
||||
this.currentChapter = null;
|
||||
}
|
||||
else this.openIndexEntry(null);
|
||||
}
|
||||
else if(button.id >= CHAPTER_BUTTONS_START){
|
||||
int actualButton = button.id-CHAPTER_BUTTONS_START;
|
||||
if(this.currentIndexEntry != null){
|
||||
if(this.currentChapter == null){
|
||||
if(actualButton < InitBooklet.entries.size()){
|
||||
this.openChapter(currentIndexEntry.chapters.get(actualButton));
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(actualButton < InitBooklet.entries.size()){
|
||||
this.openIndexEntry(InitBooklet.entries.get(actualButton));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(button.id == BUTTON_FORWARD_ID || button.id == BUTTON_BACK_ID){
|
||||
this.getButton(BUTTON_FORWARD_ID).visible = this.getNextPage(this.currentChapter, this.currentPage) != null;
|
||||
this.getButton(BUTTON_BACK_ID).visible = this.getPrevPage(this.currentChapter, this.currentPage) != null;
|
||||
}
|
||||
}
|
||||
|
||||
private void openIndexEntry(BookletIndexEntry entry){
|
||||
this.currentIndexEntry = entry;
|
||||
|
||||
this.getButton(BUTTON_RETURN_ID).visible = entry != null;
|
||||
this.getButton(BUTTON_FORWARD_ID).visible = false;
|
||||
this.getButton(BUTTON_BACK_ID).visible = false;
|
||||
|
||||
for(int i = 0; i < 12; i++){
|
||||
GuiButton button = this.getButton(CHAPTER_BUTTONS_START+i);
|
||||
if(entry == null){
|
||||
boolean entryExists = InitBooklet.entries.size() > i;
|
||||
button.visible = entryExists;
|
||||
if(entryExists) button.displayString = InitBooklet.entries.get(i).getLocalizedName();
|
||||
}
|
||||
else{
|
||||
boolean entryExists = entry.chapters.size() > i;
|
||||
button.visible = entryExists;
|
||||
if(entryExists) button.displayString = entry.chapters.get(i).getLocalizedName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openChapter(BookletChapter chapter){
|
||||
if(chapter == null) return;
|
||||
|
||||
this.currentChapter = chapter;
|
||||
this.currentPage = currentChapter.pages[0];
|
||||
|
||||
this.getButton(BUTTON_FORWARD_ID).visible = this.getNextPage(chapter, currentPage) != null;
|
||||
this.getButton(BUTTON_BACK_ID).visible = false;
|
||||
|
||||
for(int i = 0; i < 12; i++){
|
||||
GuiButton button = this.getButton(CHAPTER_BUTTONS_START+i);
|
||||
button.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class IndexButton extends GuiButton{
|
||||
|
||||
private FontRenderer renderer;
|
||||
|
||||
public IndexButton(FontRenderer renderer, int id, int x, int y, int width, int height, String text){
|
||||
super(id, x, y, width, height, text);
|
||||
this.renderer = renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY){
|
||||
if(this.visible){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition+this.width && mouseY < this.yPosition+this.height;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
int color = 0;
|
||||
if(this.field_146123_n){
|
||||
color = 38144;
|
||||
}
|
||||
|
||||
this.renderer.drawString((this.field_146123_n ? StringUtil.UNDERLINE : "")+this.displayString, this.xPosition, this.yPosition+(this.height-8)/2, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class TexturedButton extends GuiButton{
|
||||
|
||||
private int texturePosX;
|
||||
private int texturePosY;
|
||||
|
||||
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height){
|
||||
super(id, x, y, width, height, "");
|
||||
this.texturePosX = texturePosX;
|
||||
this.texturePosY = texturePosY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int x, int y){
|
||||
if(this.visible){
|
||||
minecraft.getTextureManager().bindTexture(resLoc);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height;
|
||||
int k = this.getHoverState(this.field_146123_n);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.texturePosX, this.texturePosY-this.height+k*this.height, this.width, this.height);
|
||||
this.mouseDragged(minecraft, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package ellpeck.actuallyadditions.inventory.gui.lexicon;
|
||||
|
||||
public interface IBookletPage{
|
||||
|
||||
int getID();
|
||||
|
||||
void setChapter(BookletChapter chapter);
|
||||
|
||||
String getText();
|
||||
|
||||
void render(GuiBooklet gui, int mouseX, int mouseY);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package ellpeck.actuallyadditions.inventory.gui.lexicon;
|
||||
|
||||
import ellpeck.actuallyadditions.crafting.FoodCrafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class InitBooklet{
|
||||
|
||||
public static ArrayList<BookletIndexEntry> entries = new ArrayList<BookletIndexEntry>();
|
||||
|
||||
public static BookletIndexEntry entryFood = new BookletIndexEntry("food");
|
||||
|
||||
static{
|
||||
new BookletChapter("pizza", entryFood, new PageText(1), new PageText(2), new PageCrafting(3, FoodCrafting.recipePizza));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package ellpeck.actuallyadditions.inventory.gui.lexicon;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PageCrafting extends PageText{
|
||||
|
||||
private final IRecipe recipe;
|
||||
|
||||
public PageCrafting(int id, IRecipe recipe){
|
||||
super(id);
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void render(GuiBooklet gui, int mouseX, int mouseY){
|
||||
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
|
||||
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 146, 20, 60, 60);
|
||||
|
||||
gui.unicodeRenderer.drawSplitString(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+112, 115, 0);
|
||||
|
||||
ItemStack[] stacks = new ItemStack[9];
|
||||
int width = 3;
|
||||
int height = 3;
|
||||
|
||||
if(recipe instanceof ShapedRecipes){
|
||||
ShapedRecipes shaped = (ShapedRecipes)recipe;
|
||||
width = shaped.recipeWidth;
|
||||
height = shaped.recipeHeight;
|
||||
stacks = shaped.recipeItems;
|
||||
}
|
||||
else if(recipe instanceof ShapelessRecipes){
|
||||
ShapelessRecipes shapeless = (ShapelessRecipes)recipe;
|
||||
for(int i = 0; i < shapeless.recipeItems.size(); i++){
|
||||
stacks[i] = (ItemStack)shapeless.recipeItems.get(i);
|
||||
}
|
||||
}
|
||||
else if(recipe instanceof ShapedOreRecipe){
|
||||
ShapedOreRecipe shaped = (ShapedOreRecipe)recipe;
|
||||
width = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4);
|
||||
height = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5);
|
||||
for(int i = 0; i < shaped.getInput().length; i++){
|
||||
Object input = shaped.getInput()[i];
|
||||
if(input != null)
|
||||
stacks[i] = input instanceof ItemStack ? (ItemStack)input : ((ArrayList<ItemStack>)input).get(0);
|
||||
}
|
||||
}
|
||||
else if(recipe instanceof ShapelessOreRecipe){
|
||||
ShapelessOreRecipe shapeless = (ShapelessOreRecipe)recipe;
|
||||
for(int i = 0; i < shapeless.getInput().size(); i++){
|
||||
Object input = shapeless.getInput().get(i);
|
||||
stacks[i] = input instanceof ItemStack ? (ItemStack)input : ((ArrayList<ItemStack>)input).get(0);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 2; i++){
|
||||
boolean tooltip = i == 1;
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
ItemStack stack = stacks[y*width+x];
|
||||
if(stack != null){
|
||||
int xShow = gui.guiLeft+38+x*21;
|
||||
int yShow = gui.guiTop+23+y*21;
|
||||
if(!tooltip){
|
||||
if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0);
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow);
|
||||
}
|
||||
else{
|
||||
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
||||
gui.renderToolTip(stack, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package ellpeck.actuallyadditions.inventory.gui.lexicon;
|
||||
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
|
||||
public class PageText implements IBookletPage{
|
||||
|
||||
private int id;
|
||||
private BookletChapter chapter;
|
||||
|
||||
public PageText(int id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID(){
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChapter(BookletChapter chapter){
|
||||
this.chapter = chapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(){
|
||||
return StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".chapter."+this.chapter.getUnlocalizedName()+".text."+this.id+".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiBooklet gui, int mouseX, int mouseY){
|
||||
gui.unicodeRenderer.drawSplitString(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+11, 115, 0);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,8 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
|||
|
||||
public class InitItems{
|
||||
|
||||
public static Item itemLexicon;
|
||||
|
||||
public static Item itemFertilizer;
|
||||
public static Item itemMisc;
|
||||
public static Item itemFoods;
|
||||
|
@ -116,6 +118,9 @@ public class InitItems{
|
|||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Items...");
|
||||
|
||||
itemLexicon = new ItemBooklet();
|
||||
ItemUtil.register(itemLexicon);
|
||||
|
||||
itemGrowthRing = new ItemGrowthRing();
|
||||
ItemUtil.register(itemGrowthRing);
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package ellpeck.actuallyadditions.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.ActuallyAdditions;
|
||||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||
import ellpeck.actuallyadditions.util.INameableItem;
|
||||
import ellpeck.actuallyadditions.util.ItemUtil;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBooklet extends Item implements INameableItem{
|
||||
|
||||
public ItemBooklet(){
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.epic;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||
ItemUtil.addInformation(this, list, 1, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int pass){
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconReg){
|
||||
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
return "itemBooklet";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int)player.posX, (int)player.posY, (int)player.posZ);
|
||||
return stack;
|
||||
}
|
||||
}
|
|
@ -4,9 +4,13 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
|||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Util{
|
||||
|
||||
|
@ -20,4 +24,10 @@ public class Util{
|
|||
public static void registerDispenserHandler(Item item, BehaviorDefaultDispenseItem handler){
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject(item, handler);
|
||||
}
|
||||
|
||||
public static IRecipe latestIRecipe(){
|
||||
List list = CraftingManager.getInstance().getRecipeList();
|
||||
Object recipe = list.get(list.size()-1);
|
||||
return recipe instanceof IRecipe ? (IRecipe)recipe : null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue