Moved Booklet package

This commit is contained in:
Ellpeck 2015-08-29 23:01:13 +02:00
parent 4e4fc76f2c
commit 3f09889e7f
14 changed files with 476 additions and 8 deletions

View file

@ -8,8 +8,9 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.inventory.gui.booklet; package ellpeck.actuallyadditions.booklet;
import ellpeck.actuallyadditions.booklet.page.IBookletPage;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.inventory.gui.booklet; package ellpeck.actuallyadditions.booklet;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.inventory.gui.booklet; package ellpeck.actuallyadditions.booklet;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.inventory.gui.booklet; package ellpeck.actuallyadditions.booklet;
import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.ReflectionHelper;
import ellpeck.actuallyadditions.achievement.InitAchievements; import ellpeck.actuallyadditions.achievement.InitAchievements;

View file

@ -8,10 +8,11 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.inventory.gui.booklet; package ellpeck.actuallyadditions.booklet;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.booklet.page.IBookletPage;
import ellpeck.actuallyadditions.config.GuiConfiguration; import ellpeck.actuallyadditions.config.GuiConfiguration;
import ellpeck.actuallyadditions.util.AssetUtil; import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;

View file

@ -8,8 +8,12 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.inventory.gui.booklet; package ellpeck.actuallyadditions.booklet;
import ellpeck.actuallyadditions.booklet.page.IBookletPage;
import ellpeck.actuallyadditions.booklet.page.PageCrafting;
import ellpeck.actuallyadditions.booklet.page.PageFurnace;
import ellpeck.actuallyadditions.booklet.page.PageText;
import ellpeck.actuallyadditions.crafting.BlockCrafting; import ellpeck.actuallyadditions.crafting.BlockCrafting;
import ellpeck.actuallyadditions.crafting.FoodCrafting; import ellpeck.actuallyadditions.crafting.FoodCrafting;
import ellpeck.actuallyadditions.crafting.ItemCrafting; import ellpeck.actuallyadditions.crafting.ItemCrafting;

View file

@ -0,0 +1,94 @@
/*
* 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
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.booklet.page;
import ellpeck.actuallyadditions.booklet.BookletChapter;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import java.util.List;
public class BookletPage implements IBookletPage{
protected int id;
protected BookletChapter chapter;
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(){
return null;
}
@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{
list.set(k, StringUtil.GRAY+list.get(k));
}
}
if(checkAndTransfer){
for(IBookletPage page : InitBooklet.pagesWithItemStackData){
if(page.getItemStackForPage() != null && page.getItemStackForPage().isItemEqual(stack)){
list.add(StringUtil.ORANGE+"Click to see Recipe!");
if(Mouse.isButtonDown(0)){
gui.openChapter(page.getChapter(), page);
}
break;
}
}
}
gui.drawHoveringText(list, x, y);
}
}

View file

@ -0,0 +1,32 @@
/*
* This file ("IBookletPage.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.page;
import ellpeck.actuallyadditions.booklet.BookletChapter;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import net.minecraft.item.ItemStack;
public interface IBookletPage{
int getID();
void setChapter(BookletChapter chapter);
BookletChapter getChapter();
String getText();
void renderPre(GuiBooklet gui, int mouseX, int mouseY);
void render(GuiBooklet gui, int mouseX, int mouseY);
ItemStack getItemStackForPage();
}

View file

@ -0,0 +1,132 @@
/*
* This file ("PageCrafting.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.page;
import cpw.mods.fml.relauncher.ReflectionHelper;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
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.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 BookletPage{
private final IRecipe recipe;
public PageCrafting(int id, IRecipe recipe){
super(id);
this.recipe = recipe;
InitBooklet.pagesWithItemStackData.add(this);
}
@Override
public ItemStack getItemStackForPage(){
return this.recipe == null ? null : this.recipe.getRecipeOutput();
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY){
if(this.recipe != null){
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+27, gui.guiTop+20, 146, 20, 99, 60);
}
}
@SuppressWarnings("unchecked")
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY){
if(this.recipe == null){
gui.unicodeRenderer.drawSplitString(StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0);
}
gui.unicodeRenderer.drawSplitString(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+112, 115, 0);
if(this.recipe != null){
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);
}
}
int xShowOutput = gui.guiLeft+28+82;
int yShowOutput = gui.guiTop+23+20;
RenderHelper.disableStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), recipe.getRecipeOutput(), xShowOutput, yShowOutput);
RenderHelper.enableStandardItemLighting();
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+28+x*21;
int yShow = gui.guiTop+23+y*21;
if(!tooltip){
if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0);
RenderHelper.disableStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow);
RenderHelper.enableStandardItemLighting();
}
else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, true);
}
}
}
}
}
}
if(mouseX >= xShowOutput && mouseX <= xShowOutput+16 && mouseY >= yShowOutput && mouseY <= yShowOutput+16){
gui.renderToolTip(recipe.getRecipeOutput(), mouseX, mouseY);
}
}
}
}

View file

@ -0,0 +1,85 @@
/*
* This file ("PageCrusher.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.page;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
public class PageCrusherRecipe extends BookletPage{
public ItemStack input;
public PageCrusherRecipe(int id, ItemStack input){
super(id);
this.input = input;
InitBooklet.pagesWithItemStackData.add(this);
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY){
if(CrusherRecipeManualRegistry.getOutput(this.input, false) != null){
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 60, 180, 60, 60);
}
}
@Override
public ItemStack getItemStackForPage(){
return CrusherRecipeManualRegistry.getOutput(this.input, false);
}
@SuppressWarnings("unchecked")
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY){
ItemStack output = CrusherRecipeManualRegistry.getOutput(this.input, false);
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(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+112, 115, 0);
int secondChance = CrusherRecipeManualRegistry.getSecondChance(this.input);
if(secondChance > 0){
gui.unicodeRenderer.drawString(secondChance+"%", gui.guiLeft+37+62, gui.guiTop+20+35, 0);
}
if(output != null){
for(int i = 0; i < 2; i++){
for(int j = 0; j < 3; j++){
ItemStack stack = (j == 0 ? this.input : (j == 1 ? output : (j == 2 ? CrusherRecipeManualRegistry.getOutput(this.input, true) : null)));
if(stack != null){
boolean tooltip = i == 1;
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)));
if(!tooltip){
RenderHelper.disableStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow);
RenderHelper.enableStandardItemLighting();
}
else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, j == 0);
}
}
}
}
}
}
}
}

View file

@ -0,0 +1,87 @@
/*
* This file ("PageFurnace.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.page;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.util.ModUtil;
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.crafting.FurnaceRecipes;
import java.util.Map;
public class PageFurnace extends BookletPage{
private final ItemStack result;
public PageFurnace(int id, ItemStack result){
super(id);
this.result = result;
InitBooklet.pagesWithItemStackData.add(this);
}
@Override
public ItemStack getItemStackForPage(){
return this.result;
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY){
if(this.getInputForOutput(this.result) != null){
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 0, 180, 60, 60);
}
}
@SuppressWarnings("unchecked")
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY){
ItemStack input = this.getInputForOutput(this.result);
if(input == null){
gui.unicodeRenderer.drawSplitString(StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0);
}
gui.unicodeRenderer.drawSplitString(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+112, 115, 0);
if(input != null){
for(int i = 0; i < 2; i++){
for(int x = 0; x < 2; x++){
ItemStack stack = x == 0 ? input : this.result;
boolean tooltip = i == 1;
int xShow = gui.guiLeft+37+1+x*40;
int yShow = gui.guiTop+20+20;
if(!tooltip){
RenderHelper.disableStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow);
RenderHelper.enableStandardItemLighting();
}
else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, x == 0);
}
}
}
}
}
}
private ItemStack getInputForOutput(ItemStack output){
for(Object o : FurnaceRecipes.smelting().getSmeltingList().entrySet()){
ItemStack stack = (ItemStack)((Map.Entry)o).getValue();
if(stack.isItemEqual(output)) return (ItemStack)((Map.Entry)o).getKey();
}
return null;
}
}

View file

@ -0,0 +1,32 @@
/*
* This file ("PageText.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.page;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
public class PageText extends BookletPage{
public PageText(int id){
super(id);
}
@Override
public String getText(){
return StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".chapter."+this.chapter.getUnlocalizedName()+".text."+this.id);
}
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY){
gui.unicodeRenderer.drawSplitString(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+11, 115, 0);
}
}

View file

@ -13,8 +13,8 @@ package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
import ellpeck.actuallyadditions.ActuallyAdditions; import ellpeck.actuallyadditions.ActuallyAdditions;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.inventory.gui.*; import ellpeck.actuallyadditions.inventory.gui.*;
import ellpeck.actuallyadditions.inventory.gui.booklet.GuiBooklet;
import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;

View file

@ -398,7 +398,7 @@ booklet.actuallyadditions.chapter.phantomfaces.text.3=The Phantom Liquiface can
booklet.actuallyadditions.chapter.phantomfaces.text.4=The Phantom Energyface can connect to things like generators and crushers, allowing for RF to flow through them into and out of machines. booklet.actuallyadditions.chapter.phantomfaces.text.4=The Phantom Energyface can connect to things like generators and crushers, allowing for RF to flow through them into and out of machines.
booklet.actuallyadditions.chapter.phantomfaces.text.5=Shift-Right-Click this onto any inventory and then on the Phantom Device to connect the two. booklet.actuallyadditions.chapter.phantomfaces.text.5=Shift-Right-Click this onto any inventory and then on the Phantom Device to connect the two.
booklet.actuallyadditions.chapter.phantomBreaker.name=Phantom Breakers & Placers booklet.actuallyadditions.chapter.phantomBreaker.name=&4Phantom&0 Breakers & Placers
booklet.actuallyadditions.chapter.phantomBreaker.text.1=Phantom Breakers and Placers have very similar mechanics to Phantomfaces: They can be connected to Blocks via Phantom Connectors and interact with the environment. Phantom Breakers and Placers only have a range of 3 blocks, however, in which they can destroy and place blocks in connected places. Shift-right-clicking will supply you with information about the connection, right-clicking normally will open its interface. booklet.actuallyadditions.chapter.phantomBreaker.text.1=Phantom Breakers and Placers have very similar mechanics to Phantomfaces: They can be connected to Blocks via Phantom Connectors and interact with the environment. Phantom Breakers and Placers only have a range of 3 blocks, however, in which they can destroy and place blocks in connected places. Shift-right-clicking will supply you with information about the connection, right-clicking normally will open its interface.
booklet.actuallyadditions.chapter.phantomBreaker.text.2=The Phantom Placer places Blocks that you supply it with. booklet.actuallyadditions.chapter.phantomBreaker.text.2=The Phantom Placer places Blocks that you supply it with.
booklet.actuallyadditions.chapter.phantomBreaker.text.3=The Phantom Placer breaks blocks and stores them in its internal inventory. booklet.actuallyadditions.chapter.phantomBreaker.text.3=The Phantom Placer breaks blocks and stores them in its internal inventory.