Added twitter & forum buttons, changed the way text is shown, added crusher page with every crusher recipe

This commit is contained in:
Ellpeck 2015-08-30 05:11:05 +02:00
parent 943b8d9a83
commit 390ea2a2a6
9 changed files with 110 additions and 31 deletions

View file

@ -0,0 +1,35 @@
/*
* This file ("BookletChapterCrusher.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
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.booklet;
import ellpeck.actuallyadditions.booklet.page.IBookletPage;
import ellpeck.actuallyadditions.booklet.page.PageCrusherRecipe;
import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry;
import scala.actors.threadpool.Arrays;
import java.util.ArrayList;
public class BookletChapterCrusher extends BookletChapter{
public BookletChapterCrusher(String unlocalizedName, BookletIndexEntry entry, IBookletPage... pages){
super(unlocalizedName, entry, getAllPages(pages));
}
@SuppressWarnings("unchecked")
private static IBookletPage[] getAllPages(IBookletPage... pages){
ArrayList<IBookletPage> list = new ArrayList<IBookletPage>();
list.addAll(Arrays.asList(pages));
for(CrusherRecipeManualRegistry.CrusherRecipe rec : CrusherRecipeManualRegistry.recipes){
list.add(new PageCrusherRecipe(list.size()+1, rec));
}
return list.toArray(new IBookletPage[list.size()]);
}
}

View file

@ -28,6 +28,8 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -51,6 +53,8 @@ public class GuiBooklet extends GuiScreen{
private GuiTextField searchField; private GuiTextField searchField;
private static final int BUTTON_TWITTER_ID = -4;
private static final int BUTTON_FORUM_ID = -3;
private static final int BUTTON_ACHIEVEMENTS_ID = -2; private static final int BUTTON_ACHIEVEMENTS_ID = -2;
private static final int BUTTON_CONFIG_ID = -1; private static final int BUTTON_CONFIG_ID = -1;
private static final int BUTTON_FORWARD_ID = 0; private static final int BUTTON_FORWARD_ID = 0;
@ -123,6 +127,8 @@ public class GuiBooklet extends GuiScreen{
this.buttonList.add(new TexturedButton(BUTTON_ACHIEVEMENTS_ID, this.guiLeft+138, this.guiTop, 205, 0, 8, 8)); this.buttonList.add(new TexturedButton(BUTTON_ACHIEVEMENTS_ID, this.guiLeft+138, this.guiTop, 205, 0, 8, 8));
this.buttonList.add(new TexturedButton(BUTTON_CONFIG_ID, this.guiLeft+138, this.guiTop+10, 197, 0, 8, 8)); this.buttonList.add(new TexturedButton(BUTTON_CONFIG_ID, this.guiLeft+138, this.guiTop+10, 197, 0, 8, 8));
this.buttonList.add(new TexturedButton(BUTTON_TWITTER_ID, this.guiLeft, this.guiTop, 213, 0, 8, 8));
this.buttonList.add(new TexturedButton(BUTTON_FORUM_ID, this.guiLeft, this.guiTop+10, 221, 0, 8, 8));
this.searchField = new GuiTextField(this.unicodeRenderer, guiLeft+148, guiTop+162, 66, 10); this.searchField = new GuiTextField(this.unicodeRenderer, guiLeft+148, guiTop+162, 66, 10);
this.searchField.setMaxStringLength(30); this.searchField.setMaxStringLength(30);
@ -191,6 +197,14 @@ public class GuiBooklet extends GuiScreen{
if(x >= this.guiLeft+138 && x <= this.guiLeft+138+7 && y >= this.guiTop+10 && y <= this.guiTop+10+7){ if(x >= this.guiLeft+138 && x <= this.guiLeft+138+7 && y >= this.guiTop+10 && y <= this.guiTop+10+7){
this.func_146283_a(Collections.singletonList("Show Config"), x, y); this.func_146283_a(Collections.singletonList("Show Config"), x, y);
} }
//Twitter Hover Text
if(x >= this.guiLeft && x <= this.guiLeft+7 && y >= this.guiTop && y <= this.guiTop+7){
this.func_146283_a(Collections.singletonList("Open @ActAddMod on Twitter in Browser"), x, y);
}
//Forum Hover Text
if(x >= this.guiLeft && x <= this.guiLeft+7 && y >= this.guiTop+10 && y <= this.guiTop+10+7){
this.func_146283_a(Collections.singletonList("Open Minecraft Forum Post in Browser"), x, y);
}
if(this.currentIndexEntry != null && this.currentChapter != null && this.currentPage != null){ if(this.currentIndexEntry != null && this.currentChapter != null && this.currentPage != null){
this.currentPage.render(this, x, y); this.currentPage.render(this, x, y);
@ -221,7 +235,27 @@ public class GuiBooklet extends GuiScreen{
@Override @Override
public void actionPerformed(GuiButton button){ public void actionPerformed(GuiButton button){
if(button.id == BUTTON_CONFIG_ID){ if(button.id == BUTTON_TWITTER_ID){
try{
if(Desktop.isDesktopSupported()){
Desktop.getDesktop().browse(new URI("https://twitter.com/ActAddMod"));
}
}
catch(Exception e){
e.printStackTrace();
}
}
else if(button.id == BUTTON_FORUM_ID){
try{
if(Desktop.isDesktopSupported()){
Desktop.getDesktop().browse(new URI("http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2374910-actually-additions-a-bunch-of-awesome-gadgets"));
}
}
catch(Exception e){
e.printStackTrace();
}
}
else if(button.id == BUTTON_CONFIG_ID){
mc.displayGuiScreen(new GuiConfiguration(this)); mc.displayGuiScreen(new GuiConfiguration(this));
} }
else if(button.id == BUTTON_ACHIEVEMENTS_ID){ else if(button.id == BUTTON_ACHIEVEMENTS_ID){

View file

@ -40,6 +40,7 @@ public class InitBooklet{
new BookletChapter("esd", entryFunctionalNonRF, new PageText(1), new PageCrafting(2, BlockCrafting.recipeESD), new PageCrafting(3, BlockCrafting.recipeAdvancedESD)); new BookletChapter("esd", entryFunctionalNonRF, new PageText(1), new PageCrafting(2, BlockCrafting.recipeESD), new PageCrafting(3, BlockCrafting.recipeAdvancedESD));
new BookletChapter("coffeeMachine", entryFunctionalRF, new PageText(1), new PageText(2), new PageText(3), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine)); new BookletChapter("coffeeMachine", entryFunctionalRF, new PageText(1), new PageText(2), new PageText(3), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine));
new BookletChapterCrusher("crusher", entryFunctionalRF, new PageText(1), new PageCrafting(2, BlockCrafting.recipeCrusher), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher));
new BookletChapter("craftingIngs", entryMisc, new PageText(1), new PageCrafting(2, ItemCrafting.recipeCoil), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced), new PageCrafting(4, BlockCrafting.recipeCase), new PageCrafting(5, BlockCrafting.recipeStoneCase), new PageCrafting(6, BlockCrafting.recipeEnderPearlBlock), new PageCrafting(7, BlockCrafting.recipeEnderCase)); new BookletChapter("craftingIngs", entryMisc, new PageText(1), new PageCrafting(2, ItemCrafting.recipeCoil), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced), new PageCrafting(4, BlockCrafting.recipeCase), new PageCrafting(5, BlockCrafting.recipeStoneCase), new PageCrafting(6, BlockCrafting.recipeEnderPearlBlock), new PageCrafting(7, BlockCrafting.recipeEnderCase));
new BookletChapter("cloud", entryMisc, new PageText(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud)); new BookletChapter("cloud", entryMisc, new PageText(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud));

View file

@ -17,10 +17,14 @@ import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import java.util.List; import java.util.List;
@ -97,4 +101,21 @@ public class BookletPage implements IBookletPage{
gui.drawHoveringText(list, x, y); gui.drawHoveringText(list, x, y);
} }
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();
}
} }

View file

@ -16,8 +16,6 @@ import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;
import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.Util;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapedRecipes;
@ -101,9 +99,7 @@ public class PageCrafting extends BookletPage{
int xShowOutput = gui.guiLeft+28+82; int xShowOutput = gui.guiLeft+28+82;
int yShowOutput = gui.guiTop+23+20; int yShowOutput = gui.guiTop+23+20;
RenderHelper.disableStandardItemLighting(); this.renderItem(gui, recipe.getRecipeOutput(), xShowOutput, yShowOutput);
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), recipe.getRecipeOutput(), xShowOutput, yShowOutput);
RenderHelper.enableStandardItemLighting();
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
boolean tooltip = i == 1; boolean tooltip = i == 1;
for(int x = 0; x < width; x++){ for(int x = 0; x < width; x++){
@ -114,9 +110,7 @@ public class PageCrafting extends BookletPage{
int yShow = gui.guiTop+23+y*21; int yShow = gui.guiTop+23+y*21;
if(!tooltip){ if(!tooltip){
if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0); if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0);
RenderHelper.disableStandardItemLighting(); this.renderItem(gui, stack, xShow, yShow);
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow);
RenderHelper.enableStandardItemLighting();
} }
else{ else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){

View file

@ -15,23 +15,21 @@ import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry; import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class PageCrusherRecipe extends BookletPage{ public class PageCrusherRecipe extends BookletPage{
public ItemStack input; public CrusherRecipeManualRegistry.CrusherRecipe recipe;
public PageCrusherRecipe(int id, ItemStack input){ public PageCrusherRecipe(int id, CrusherRecipeManualRegistry.CrusherRecipe recipe){
super(id); super(id);
this.input = input; this.recipe = recipe;
InitBooklet.pagesWithItemStackData.add(this); InitBooklet.pagesWithItemStackData.add(this);
} }
@Override @Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY){ public void renderPre(GuiBooklet gui, int mouseX, int mouseY){
if(CrusherRecipeManualRegistry.getOutput(this.input, false) != null){ if(recipe.firstOutput != null){
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc); gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 60, 180, 60, 60); gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 60, 180, 60, 60);
} }
@ -39,14 +37,13 @@ public class PageCrusherRecipe extends BookletPage{
@Override @Override
public ItemStack getItemStackForPage(){ public ItemStack getItemStackForPage(){
return CrusherRecipeManualRegistry.getOutput(this.input, false); return recipe.firstOutput;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void render(GuiBooklet gui, int mouseX, int mouseY){ public void render(GuiBooklet gui, int mouseX, int mouseY){
ItemStack output = CrusherRecipeManualRegistry.getOutput(this.input, false); if(recipe.firstOutput == null){
if(output == null){
gui.unicodeRenderer.drawSplitString(StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0); gui.unicodeRenderer.drawSplitString(StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0);
} }
@ -55,15 +52,14 @@ public class PageCrusherRecipe extends BookletPage{
gui.unicodeRenderer.drawSplitString(text.replace("<n>", "\n"), gui.guiLeft+14, gui.guiTop+100, 115, 0); gui.unicodeRenderer.drawSplitString(text.replace("<n>", "\n"), gui.guiLeft+14, gui.guiTop+100, 115, 0);
} }
int secondChance = CrusherRecipeManualRegistry.getSecondChance(this.input); if(recipe.secondChance > 0){
if(secondChance > 0){ gui.unicodeRenderer.drawString(recipe.secondChance+"%", gui.guiLeft+37+62, gui.guiTop+20+35, 0);
gui.unicodeRenderer.drawString(secondChance+"%", gui.guiLeft+37+62, gui.guiTop+20+35, 0);
} }
if(output != null){ if(recipe.firstOutput != null){
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
for(int j = 0; j < 3; j++){ for(int j = 0; j < 3; j++){
ItemStack stack = (j == 0 ? this.input : (j == 1 ? output : (j == 2 ? CrusherRecipeManualRegistry.getOutput(this.input, true) : null))); ItemStack stack = (j == 0 ? this.recipe.input : (j == 1 ? recipe.firstOutput : (j == 2 ? recipe.secondOutput : null)));
if(stack != null){ if(stack != null){
boolean tooltip = i == 1; boolean tooltip = i == 1;
@ -71,9 +67,7 @@ public class PageCrusherRecipe extends BookletPage{
int xShow = gui.guiLeft+37+(j == 0 ? 0 : (j == 1 ? 42 : (j == 2 ? 43 : 0))); int xShow = gui.guiLeft+37+(j == 0 ? 0 : (j == 1 ? 42 : (j == 2 ? 43 : 0)));
int yShow = gui.guiTop+20+(j == 0 ? 18 : (j == 1 ? 12 : (j == 2 ? 30 : 0))); int yShow = gui.guiTop+20+(j == 0 ? 18 : (j == 1 ? 12 : (j == 2 ? 30 : 0)));
if(!tooltip){ if(!tooltip){
RenderHelper.disableStandardItemLighting(); this.renderItem(gui, stack, xShow, yShow);
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow);
RenderHelper.enableStandardItemLighting();
} }
else{ else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){

View file

@ -14,8 +14,6 @@ import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet; import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.FurnaceRecipes;
@ -66,9 +64,7 @@ public class PageFurnace extends BookletPage{
int xShow = gui.guiLeft+37+1+x*40; int xShow = gui.guiLeft+37+1+x*40;
int yShow = gui.guiTop+20+20; int yShow = gui.guiTop+20+20;
if(!tooltip){ if(!tooltip){
RenderHelper.disableStandardItemLighting(); this.renderItem(gui, stack, xShow, yShow);
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow);
RenderHelper.enableStandardItemLighting();
} }
else{ else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){

View file

@ -46,6 +46,8 @@ public class BlockCrafting{
public static IRecipe recipeAdvancedESD; public static IRecipe recipeAdvancedESD;
public static IRecipe recipePhantomBooster; public static IRecipe recipePhantomBooster;
public static IRecipe recipeCoffeeMachine; public static IRecipe recipeCoffeeMachine;
public static IRecipe recipeCrusher;
public static IRecipe recipeDoubleCrusher;
public static void init(){ public static void init(){
@ -369,6 +371,7 @@ public class BlockCrafting{
'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()), 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()),
'P', new ItemStack(Blocks.piston), 'P', new ItemStack(Blocks.piston),
'F', new ItemStack(Items.flint))); 'F', new ItemStack(Items.flint)));
recipeCrusher = Util.lastIRecipe();
} }
//Double Crusher //Double Crusher
@ -380,6 +383,7 @@ public class BlockCrafting{
'R', InitBlocks.blockGrinder, 'R', InitBlocks.blockGrinder,
'F', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()), 'F', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()),
'P', new ItemStack(Blocks.piston))); 'P', new ItemStack(Blocks.piston)));
recipeDoubleCrusher = Util.lastIRecipe();
} }
//Double Furnace //Double Furnace

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB