mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-26 04:59:23 +01:00
Booklet rework, part 1.
This is an API breaking change, by the way.
This commit is contained in:
parent
66aec5cfdf
commit
f35a041a55
64 changed files with 531 additions and 3306 deletions
|
@ -10,9 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.api;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
|
||||
import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler;
|
||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||
|
@ -31,7 +31,7 @@ public final class ActuallyAdditionsAPI{
|
|||
|
||||
public static final String MOD_ID = "actuallyadditions";
|
||||
public static final String API_ID = MOD_ID+"api";
|
||||
public static final String API_VERSION = "26";
|
||||
public static final String API_VERSION = "27";
|
||||
|
||||
public static final List<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<CrusherRecipe>();
|
||||
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<BallOfFurReturn>();
|
||||
|
@ -46,7 +46,7 @@ public final class ActuallyAdditionsAPI{
|
|||
//This is added to automatically, you don't need to add anything to this list
|
||||
public static final List<IBookletChapter> ALL_CHAPTERS = new ArrayList<IBookletChapter>();
|
||||
//This is added to automatically, you don't need to add anything to this list
|
||||
public static final List<BookletPage> BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA = new ArrayList<BookletPage>();
|
||||
public static final List<IBookletPage> BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA = new ArrayList<IBookletPage>();
|
||||
public static final List<WeightedOre> STONE_ORES = new ArrayList<WeightedOre>();
|
||||
public static final List<WeightedOre> NETHERRACK_ORES = new ArrayList<WeightedOre>();
|
||||
|
||||
|
@ -90,66 +90,6 @@ public final class ActuallyAdditionsAPI{
|
|||
public static Lens lensDisenchanting;
|
||||
public static Lens lensMining;
|
||||
|
||||
/**
|
||||
* Adds a Recipe to the Crusher Recipe Registry
|
||||
* The second output will be nothing
|
||||
*
|
||||
* @param input The input's OreDictionary name
|
||||
* @param outputOne The first output's OreDictionary name
|
||||
* @param outputOneAmount The amount of the first output
|
||||
*/
|
||||
@Deprecated //Use new version below
|
||||
public static void addCrusherRecipe(String input, String outputOne, int outputOneAmount){
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Recipe to the Crusher Recipe Registry
|
||||
*
|
||||
* @param input The input's OreDictionary name
|
||||
* @param outputOne The first output's OreDictionary name
|
||||
* @param outputOneAmount The amount of the first output
|
||||
* @param outputTwo The second output's OreDictionary name
|
||||
* @param outputTwoAmount The amount of the second output
|
||||
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
|
||||
*/
|
||||
@Deprecated //Use new version below
|
||||
public static void addCrusherRecipe(String input, String outputOne, int outputOneAmount, String outputTwo, int outputTwoAmount, int outputTwoChance){
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Recipe to the Crusher Recipe Registry
|
||||
* The second output will be nothing
|
||||
*
|
||||
* @param input The input as an ItemStack
|
||||
* @param outputOne The first output as an ItemStack
|
||||
*/
|
||||
@Deprecated //Use new version below
|
||||
public static void addCrusherRecipe(ItemStack input, ItemStack outputOne){
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Recipe to the Crusher Recipe Registry
|
||||
* The second output will be nothing
|
||||
*
|
||||
* @param input The input as an ItemStack
|
||||
* @param outputOne The first output's OreDictionary name
|
||||
* @param outputOneAmount The amount of the first output
|
||||
*/
|
||||
@Deprecated //Use new version below
|
||||
public static void addCrusherRecipe(ItemStack input, String outputOne, int outputOneAmount){
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Recipe to the Crusher Recipe Registry
|
||||
* The second output will be nothing
|
||||
*
|
||||
* @param input The input as an ItemStack
|
||||
* @param outputOne The first output's OreDictionary name
|
||||
*/
|
||||
@Deprecated //Use new version below
|
||||
public static void addCrusherRecipe(String input, ItemStack outputOne){
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an ore with a specific weight to the list of ores that the lens of the miner will generate inside of stone.
|
||||
* Higher weight means higher occurence.
|
||||
|
@ -266,23 +206,6 @@ public final class ActuallyAdditionsAPI{
|
|||
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a recipe to the Atomic Reconstructor conversion lenses
|
||||
*
|
||||
* @param input The input's OreDictionary name
|
||||
* @param output The output's OreDictionary name
|
||||
* @param energyUse The amount of RF used per conversion
|
||||
* @param type The type of lens used for the conversion. To use the default type, use method below
|
||||
* Note how this always has to be the same instance of the lens type that the item also has for it to work!
|
||||
*/
|
||||
@Deprecated //Use ItemStack recipes
|
||||
public static void addReconstructorLensConversionRecipe(String input, String output, int energyUse, LensConversion type){
|
||||
}
|
||||
|
||||
@Deprecated //Use ItemStack recipes
|
||||
public static void addReconstructorLensConversionRecipe(String input, String output, int energyUse){
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item and the way it is modified to the Atomic Reconstructor's color lens.
|
||||
* This also works for blocks, but they have to be in their item form.
|
||||
|
@ -313,15 +236,4 @@ public final class ActuallyAdditionsAPI{
|
|||
public static void addBookletEntry(IBookletEntry entry){
|
||||
BOOKLET_ENTRIES.add(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a page to the pages with ItemStack data
|
||||
* This should be done with every page that uses getItemStacksForPage()
|
||||
*
|
||||
* @param page The page to add
|
||||
*/
|
||||
@Deprecated //Search will now be done on all pages that are in the book
|
||||
public static void addPageWithItemStackData(BookletPage page){
|
||||
BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* 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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.api.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class BookletPage{
|
||||
|
||||
protected final HashMap<String, String> textReplacements = new HashMap<String, String>();
|
||||
public boolean arePageStacksWildcard;
|
||||
protected IBookletChapter chapter;
|
||||
protected boolean hasNoText;
|
||||
|
||||
public void onOpened(IBookletGui gui){
|
||||
|
||||
}
|
||||
|
||||
public void onClosed(IBookletGui gui){
|
||||
|
||||
}
|
||||
|
||||
public boolean onActionPerformed(IBookletGui gui, GuiButton button){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the page, for the page number etc.
|
||||
* Don't make two pages in the same chapter with the same ID.
|
||||
*/
|
||||
public abstract int getID();
|
||||
|
||||
/**
|
||||
* Gets the localized text to be displayed
|
||||
*/
|
||||
public abstract String getText();
|
||||
|
||||
/**
|
||||
* This render method ica called before super.drawScreen() is called in the GUI
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed);
|
||||
|
||||
/**
|
||||
* This render method ica called after super.drawScreen() is called in the GUI
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed);
|
||||
|
||||
/**
|
||||
* Equivalent to updateScreen() in GuiScreen
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void updateScreen(int ticksElapsed);
|
||||
|
||||
/**
|
||||
* Gets the ItemStacks that are part of or displayed on this page (for JEI Handler and search)
|
||||
*/
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the FluidStacks that are part of or displayed on this page (for JEI Handler and search)
|
||||
*/
|
||||
public FluidStack[] getFluidStacksForPage(){
|
||||
return new FluidStack[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the text that is displayed when an Item is hovered over that can be clicked on to go to its page
|
||||
*/
|
||||
public abstract String getClickToSeeRecipeString();
|
||||
|
||||
public IBookletChapter getChapter(){
|
||||
return this.chapter;
|
||||
}
|
||||
|
||||
public void setChapter(IBookletChapter chapter){
|
||||
this.chapter = chapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stacks on the page to be wildcard, meaning the metadata doesn't matter
|
||||
* This applies for all stacks at once
|
||||
*/
|
||||
public BookletPage setPageStacksWildcard(){
|
||||
this.arePageStacksWildcard = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BookletPage setNoText(){
|
||||
this.hasNoText = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BookletPage addTextReplacement(String text, int replacement){
|
||||
return this.addTextReplacement(text, Integer.toString(replacement));
|
||||
}
|
||||
|
||||
public BookletPage addTextReplacement(String text, String replacement){
|
||||
this.textReplacements.put(text, replacement);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -14,11 +14,7 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
public interface IBookletChapter{
|
||||
|
||||
BookletPage[] getPages();
|
||||
|
||||
BookletPage getPageById(int id);
|
||||
|
||||
int getPageId(BookletPage page);
|
||||
IBookletPage[] getAllPages();
|
||||
|
||||
String getLocalizedName();
|
||||
|
||||
|
@ -30,4 +26,5 @@ public interface IBookletChapter{
|
|||
|
||||
String getIdentifier();
|
||||
|
||||
int getPageNum(IBookletPage page);
|
||||
}
|
||||
|
|
|
@ -10,11 +10,13 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.api.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.IEntryGui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IBookletEntry{
|
||||
|
||||
List<IBookletChapter> getChapters();
|
||||
List<IBookletChapter> getAllChapters();
|
||||
|
||||
void setChapters(List<IBookletChapter> chapters);
|
||||
|
||||
|
@ -26,4 +28,5 @@ public interface IBookletEntry{
|
|||
|
||||
void addChapter(IBookletChapter chapter);
|
||||
|
||||
IEntryGui createGui();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.api.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.IPageGui;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IBookletPage{
|
||||
|
||||
ItemStack[] getItemStacksForPage();
|
||||
|
||||
FluidStack[] getFluidStacksForPage();
|
||||
|
||||
IBookletChapter getChapter();
|
||||
|
||||
void setChapter(IBookletChapter chapter);
|
||||
|
||||
IPageGui createGui();
|
||||
|
||||
String getInfoText();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* This file ("IBookGui.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.api.booklet.internal;
|
||||
|
||||
public interface IBookletGui{
|
||||
|
||||
void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale);
|
||||
|
||||
void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* This file ("IEntryGui.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.api.booklet.internal;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
|
||||
public interface IEntryGui extends IBookletGui{
|
||||
|
||||
IBookletEntry getEntry();
|
||||
|
||||
int getEntryPage();
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* This file ("IPageGui.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.api.booklet.internal;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
|
||||
public interface IPageGui extends IBookletGui{
|
||||
|
||||
IBookletPage getPage();
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* This file ("IBookletGui.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.api.internal;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is a helper interface for BookletPage
|
||||
* This is not supposed to be implemented.
|
||||
* <p>
|
||||
* Can be cast to GuiScreen.
|
||||
*/
|
||||
public interface IBookletGui{
|
||||
|
||||
/**
|
||||
* This method should be used when drawing an ItemStack to a booklet page
|
||||
* It displays the hoverover text of the item and also contains the "show more info"-text and clickable part
|
||||
*
|
||||
* @param renderTransferButton if the "show more info"-text and clickable part should exist
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
void renderTooltipAndTransferButton(BookletPage from, ItemStack stack, int x, int y, boolean renderTransferButton, boolean mousePressed);
|
||||
|
||||
int getXSize();
|
||||
|
||||
int getYSize();
|
||||
|
||||
int getGuiLeft();
|
||||
|
||||
int getGuiTop();
|
||||
|
||||
void drawRect(int startX, int startY, int u, int v, int xSize, int ySize);
|
||||
|
||||
IEntrySet getCurrentEntrySet();
|
||||
|
||||
List<GuiButton> getButtonList();
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* This file ("IEntrySet.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.api.internal;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IEntrySet{
|
||||
|
||||
void setEntry(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex);
|
||||
|
||||
void removeEntry();
|
||||
|
||||
void writeToNBT(NBTTagCompound compound);
|
||||
|
||||
void readFromNBT(NBTTagCompound compound);
|
||||
|
||||
BookletPage getCurrentPage();
|
||||
|
||||
IBookletEntry getCurrentEntry();
|
||||
|
||||
IBookletChapter getCurrentChapter();
|
||||
|
||||
int getPageInIndex();
|
||||
|
||||
void setPage(BookletPage page);
|
||||
|
||||
void setEntry(IBookletEntry entry);
|
||||
|
||||
void setChapter(IBookletChapter chapter);
|
||||
|
||||
void setPageInIndex(int page);
|
||||
}
|
|
@ -10,15 +10,10 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.api.internal;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -42,15 +37,5 @@ public interface IMethodHandler{
|
|||
|
||||
boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile);
|
||||
|
||||
BookletPage generateTextPage(int id);
|
||||
|
||||
BookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY);
|
||||
|
||||
BookletPage generateCraftingPage(int id, IRecipe... recipes);
|
||||
|
||||
BookletPage generateFurnacePage(int id, ItemStack input, ItemStack result);
|
||||
|
||||
IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, BookletPage... pages);
|
||||
|
||||
boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance);
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ public class ActuallyAdditions{
|
|||
if(mapping.name != null){
|
||||
String name = mapping.name.toLowerCase(Locale.ROOT);
|
||||
if(name.startsWith(ModUtil.MOD_ID+":")){
|
||||
if(name.contains("paxel") || name.contains("itemspecial") || name.contains("blockbookstand") || name.contains("rarmor") || name.contains("bucket") || name.contains("modulereconstructor")){
|
||||
if(name.contains("paxel") || name.contains("itemspecial") || name.contains("blockbookstand") || name.contains("rarmor") || name.contains("bucket") || name.contains("modulereconstructor") || name.contains("stand")){
|
||||
mapping.ignore();
|
||||
ModUtil.LOGGER.info("Missing Mapping "+mapping.name+" is getting ignored. This is intentional.");
|
||||
}
|
||||
|
|
|
@ -1,165 +0,0 @@
|
|||
/*
|
||||
* This file ("BlockBookletStand.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockBookletStand extends BlockContainerBase implements IHudDisplay{
|
||||
|
||||
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 3);
|
||||
|
||||
private static final AxisAlignedBB AABB_1 = new AxisAlignedBB(0, 3*0.0625, 0, 1, 14*0.0625, 0.0625);
|
||||
private static final AxisAlignedBB AABB_2 = new AxisAlignedBB(0, 3*0.0625, 0, 0.0625, 14*0.0625, 1);
|
||||
private static final AxisAlignedBB AABB_3 = new AxisAlignedBB(1-0.0625, 3*0.0625, 0, 1, 14*0.0625, 1);
|
||||
private static final AxisAlignedBB AABB_4 = new AxisAlignedBB(1, 3*0.0625, 1-0.0625, 0, 14*0.0625, 1);
|
||||
|
||||
public BlockBookletStand(String name){
|
||||
super(Material.WOOD, name);
|
||||
this.setHarvestLevel("axe", 0);
|
||||
this.setHardness(1.0F);
|
||||
this.setResistance(4.0F);
|
||||
this.setSoundType(SoundType.WOOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
|
||||
int meta = this.getMetaFromState(state);
|
||||
switch(meta){
|
||||
case 0:
|
||||
return AABB_4;
|
||||
case 1:
|
||||
return AABB_1;
|
||||
case 2:
|
||||
return AABB_3;
|
||||
case 3:
|
||||
return AABB_2;
|
||||
}
|
||||
return super.getBoundingBox(state, source, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BOOK_STAND.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.RARE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
||||
|
||||
if(rotation == 0){
|
||||
world.setBlockState(pos, this.getStateFromMeta(0), 2);
|
||||
}
|
||||
if(rotation == 1){
|
||||
world.setBlockState(pos, this.getStateFromMeta(3), 2);
|
||||
}
|
||||
if(rotation == 2){
|
||||
world.setBlockState(pos, this.getStateFromMeta(1), 2);
|
||||
}
|
||||
if(rotation == 3){
|
||||
world.setBlockState(pos, this.getStateFromMeta(2), 2);
|
||||
}
|
||||
|
||||
TileEntityBookletStand tile = (TileEntityBookletStand)world.getTileEntity(pos);
|
||||
if(tile != null){
|
||||
if(tile.assignedPlayer == null){
|
||||
tile.assignedPlayer = player.getName();
|
||||
tile.markDirty();
|
||||
tile.sendUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2){
|
||||
return new TileEntityBookletStand();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
|
||||
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
|
||||
if(tile instanceof TileEntityBookletStand){
|
||||
EntrySet set = ((TileEntityBookletStand)tile).assignedEntry;
|
||||
|
||||
String strg1;
|
||||
String strg2;
|
||||
if(set.getCurrentEntry() == null){
|
||||
strg1 = "No entry saved! Save one if";
|
||||
strg2 = "you are the player who placed it!";
|
||||
}
|
||||
else if(set.getCurrentChapter() == null){
|
||||
strg1 = set.getCurrentEntry().getLocalizedName();
|
||||
strg2 = "Page "+set.getPageInIndex();
|
||||
}
|
||||
else{
|
||||
strg1 = set.getCurrentChapter().getLocalizedName();
|
||||
strg2 = "Page "+set.getCurrentPage().getID();
|
||||
|
||||
AssetUtil.renderStackToGui(set.getCurrentChapter().getDisplayItemStack() != null ? set.getCurrentChapter().getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+10, 1F);
|
||||
}
|
||||
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg1, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+8, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg2, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+18, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PropertyInteger getMetaProperty(){
|
||||
return META;
|
||||
}
|
||||
}
|
|
@ -101,7 +101,6 @@ public final class InitBlocks{
|
|||
public static Block blockPillarQuartzWall;
|
||||
public static Block blockPillarQuartzStair;
|
||||
public static Block blockPillarQuartzSlab;
|
||||
public static Block blockBookletStand;
|
||||
public static Block blockDisplayStand;
|
||||
public static Block blockShockSuppressor;
|
||||
public static Block blockEmpowerer;
|
||||
|
@ -121,7 +120,6 @@ public final class InitBlocks{
|
|||
blockShockSuppressor = new BlockShockSuppressor("blockShockSuppressor");
|
||||
blockDisplayStand = new BlockDisplayStand("blockDisplayStand");
|
||||
blockPlayerInterface = new BlockPlayerInterface("blockPlayerInterface");
|
||||
blockBookletStand = new BlockBookletStand("blockBookletStand");
|
||||
blockItemViewer = new BlockItemViewer("blockItemViewer");
|
||||
blockFireworkBox = new BlockFireworkBox("blockFireworkBox");
|
||||
blockMiner = new BlockMiner("blockMiner");
|
||||
|
|
|
@ -1,614 +0,0 @@
|
|||
/*
|
||||
* This file ("BookletUtils.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.IndexButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.TexturedButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllSearch;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class BookletUtils{
|
||||
|
||||
/**
|
||||
* Tries to open a URL in the Browser
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void openBrowser(String url){
|
||||
openBrowser(url, url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to open a URL in the Browser
|
||||
*
|
||||
* @param url The URL
|
||||
* @param shiftUrl The URL to open when Shift is held
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void openBrowser(String url, String shiftUrl){
|
||||
try{
|
||||
if(Desktop.isDesktopSupported()){
|
||||
if(shiftUrl.equals(url) || GuiScreen.isShiftKeyDown()){
|
||||
Desktop.getDesktop().browse(new URI(shiftUrl));
|
||||
}
|
||||
else{
|
||||
Desktop.getDesktop().browse(new URI(url));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.error("Something bad happened when trying to open a URL!", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the Title of the current chapter, current index entry or just "Actually Additions" if neither is present
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void drawTitle(GuiBooklet booklet){
|
||||
booklet.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC);
|
||||
//Upper title
|
||||
booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize/2-142/2, booklet.guiTop-12, 0, 240, 142, 12);
|
||||
//Lower title
|
||||
booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize/2-142/2, booklet.guiTop+booklet.ySize, 0, 243, 142, 13);
|
||||
|
||||
//Draw No Entry title
|
||||
if(booklet.currentEntrySet.getCurrentEntry() == null){
|
||||
String strg = TextFormatting.DARK_GREEN+StringUtil.localize(booklet.bookletName);
|
||||
booklet.getFontRenderer().drawString(strg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(strg)/2-3, booklet.guiTop+12, 0);
|
||||
strg = TextFormatting.DARK_GREEN+StringUtil.localize("info."+ModUtil.MOD_ID+".booklet.manualName.2");
|
||||
booklet.getFontRenderer().drawString(strg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(strg)/2-3, booklet.guiTop+12+booklet.getFontRenderer().FONT_HEIGHT, 0);
|
||||
|
||||
String versionStrg;
|
||||
String playerName = Minecraft.getMinecraft().thePlayer.getName();
|
||||
|
||||
if(Util.isDevVersion()){
|
||||
versionStrg = "Dev's Edition";
|
||||
}
|
||||
else{
|
||||
String modVersion = Util.getMajorModVersion();
|
||||
if(playerName.equalsIgnoreCase("dqmhose")){
|
||||
versionStrg = "Pants Edition";
|
||||
}
|
||||
else if(playerName.equalsIgnoreCase("TwoOfEight") || playerName.equalsIgnoreCase("BootyToast")){
|
||||
versionStrg = "Illustrator's Edition";
|
||||
}
|
||||
else if(playerName.equalsIgnoreCase("KittyVanCat")){
|
||||
versionStrg = "Cat's Edition";
|
||||
}
|
||||
else if(playerName.equalsIgnoreCase("canitzp")){
|
||||
versionStrg = "P's Edition";
|
||||
}
|
||||
else if(playerName.equalsIgnoreCase("Ellpeck")){
|
||||
versionStrg = "Dev's Edition";
|
||||
}
|
||||
else if(playerName.equalsIgnoreCase("direwolf20")){
|
||||
versionStrg = "Edition 20";
|
||||
}
|
||||
else if(playerName.equalsIgnoreCase("dannydjdk") || playerName.equalsIgnoreCase("andrew_period")){
|
||||
versionStrg = "Derp's Edition";
|
||||
}
|
||||
else if(playerName.equalsIgnoreCase("mezz")){
|
||||
versionStrg = "Just Enough Edition";
|
||||
}
|
||||
else{
|
||||
versionStrg = StringUtil.localize("info."+ModUtil.MOD_ID+".booklet.edition")+" "+modVersion;
|
||||
}
|
||||
}
|
||||
|
||||
strg = TextFormatting.GOLD+TextFormatting.ITALIC.toString()+"-"+versionStrg+"-";
|
||||
booklet.getFontRenderer().drawString(strg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(strg)/2-3, booklet.guiTop+33, 0);
|
||||
}
|
||||
|
||||
String strg = booklet.currentEntrySet.getCurrentChapter() == null ? (booklet.currentEntrySet.getCurrentEntry() == null ? StringUtil.localize("itemGroup."+ModUtil.MOD_ID) : booklet.currentEntrySet.getCurrentEntry().getLocalizedName()) : booklet.currentEntrySet.getCurrentChapter().getLocalizedName();
|
||||
booklet.drawCenteredString(booklet.getFontRenderer(), strg, booklet.guiLeft+booklet.xSize/2, booklet.guiTop-9, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an Achievement Info if the page has items that trigger achievements
|
||||
*
|
||||
* @param pre If the hover info texts or the icon should be drawn
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void drawAchievementInfo(GuiBooklet booklet, boolean pre, int mouseX, int mouseY){
|
||||
if(booklet.currentEntrySet.getCurrentChapter() == null){
|
||||
return;
|
||||
}
|
||||
|
||||
List<TheAchievements> achievements = null;
|
||||
for(BookletPage page : booklet.currentEntrySet.getCurrentChapter().getPages()){
|
||||
ItemStack[] stacks = page.getItemStacksForPage();
|
||||
if(page != null && stacks != null){
|
||||
for(ItemStack stack : stacks){
|
||||
if(stack != null){
|
||||
for(TheAchievements achievement : TheAchievements.values()){
|
||||
if(ItemUtil.contains(achievement.itemsToBeGotten, stack, true)){
|
||||
if(pre){
|
||||
booklet.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC);
|
||||
booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize+1, booklet.guiTop-18, 166, 154, 22, 21);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
if(mouseX >= booklet.guiLeft+booklet.xSize+1 && mouseX < booklet.guiLeft+booklet.xSize+1+22 && mouseY >= booklet.guiTop-18 && mouseY < booklet.guiTop-18+21){
|
||||
if(achievements == null){
|
||||
achievements = new ArrayList<TheAchievements>();
|
||||
}
|
||||
if(!achievements.contains(achievement)){
|
||||
achievements.add(achievement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(achievements != null){
|
||||
List<String> infoList = null;
|
||||
for(TheAchievements achievement : achievements){
|
||||
if(infoList == null){
|
||||
infoList = new ArrayList<String>();
|
||||
infoList.add(TextFormatting.GOLD+"Achievements related to this chapter:");
|
||||
}
|
||||
infoList.add("-"+StringUtil.localize(achievement.chieve.statId));
|
||||
infoList.add(TextFormatting.GRAY+"("+achievement.chieve.getDescription()+")");
|
||||
}
|
||||
|
||||
if(infoList != null){
|
||||
booklet.drawHoveringText(infoList, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-renders the booklet page, including
|
||||
* -the number of a page and its content (text, crafting recipe etc.)
|
||||
* -the number of a page in a chapter
|
||||
* -the amount of words and chars in the index (Just for teh lulz)
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderPre(GuiBooklet booklet, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(booklet.currentEntrySet.getCurrentEntry() != null){
|
||||
//Renders Booklet Page Number and Content
|
||||
if(booklet.currentEntrySet.getCurrentChapter() != null && booklet.currentEntrySet.getCurrentPage() != null){
|
||||
booklet.drawCenteredString(booklet.getFontRenderer(), booklet.currentEntrySet.getCurrentPage().getID()+"/"+booklet.currentEntrySet.getCurrentChapter().getPages().length, booklet.guiLeft+booklet.xSize/2, booklet.guiTop+171, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
booklet.currentEntrySet.getCurrentPage().renderPre(booklet, mouseX, mouseY, ticksElapsed, mousePressed);
|
||||
}
|
||||
//Renders Chapter Page Number
|
||||
else{
|
||||
booklet.drawCenteredString(booklet.getFontRenderer(), booklet.currentEntrySet.getPageInIndex()+"/"+booklet.indexPageAmount, booklet.guiLeft+booklet.xSize/2, booklet.guiTop+171, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
//Renders the amount of words and chars the book has
|
||||
else{
|
||||
String countStrg = StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID+".amountOfWordsAndChars", ClientProxy.bookletWordCount, ClientProxy.bookletCharCount);
|
||||
booklet.getFontRenderer().drawString(TextFormatting.ITALIC+countStrg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(countStrg)/2, booklet.guiTop+booklet.ySize+1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws all of the hovering texts for the buttons that need explanation in the booklet
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void doHoverTexts(GuiBooklet booklet, int mouseX, int mouseY){
|
||||
//Update all of the buttons' hovering texts
|
||||
for(Object button : booklet.getButtonList()){
|
||||
if(button instanceof GuiButton && ((GuiButton)button).visible && ((GuiButton)button).isMouseOver()){
|
||||
if(button instanceof BookmarkButton){
|
||||
((BookmarkButton)button).drawHover(mouseX, mouseY);
|
||||
}
|
||||
else if(button instanceof TexturedButton){
|
||||
booklet.drawHoveringText(((TexturedButton)button).textList, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the search bar, should be called when it is getting typed into
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void updateSearchBar(GuiBooklet booklet){
|
||||
boolean change = false;
|
||||
|
||||
IBookletEntry current = booklet.currentEntrySet.getCurrentEntry();
|
||||
boolean isAllSearch = current instanceof BookletEntryAllSearch;
|
||||
|
||||
if(booklet.searchField.getText() != null && !booklet.searchField.getText().isEmpty()){
|
||||
if(!isAllSearch){
|
||||
openIndexEntry(booklet, ActuallyAdditionsAPI.allAndSearch, 1, false);
|
||||
current = booklet.currentEntrySet.getCurrentEntry();
|
||||
}
|
||||
|
||||
current.getChapters().clear();
|
||||
for(IBookletChapter chapter : ActuallyAdditionsAPI.ALL_CHAPTERS){
|
||||
String searchFieldText = booklet.searchField.getText().toLowerCase(Locale.ROOT);
|
||||
if(chapter.getLocalizedName().toLowerCase(Locale.ROOT).contains(searchFieldText) || getChapterStacksContainString(searchFieldText, chapter)){
|
||||
current.getChapters().add(chapter);
|
||||
}
|
||||
}
|
||||
|
||||
change = true;
|
||||
}
|
||||
else if(isAllSearch){
|
||||
current.setChapters(ActuallyAdditionsAPI.ALL_CHAPTERS);
|
||||
change = true;
|
||||
}
|
||||
|
||||
if(change){
|
||||
openIndexEntry(booklet, current, booklet.currentEntrySet.getPageInIndex(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static boolean getChapterStacksContainString(String text, IBookletChapter chapter){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
for(BookletPage page : chapter.getPages()){
|
||||
ItemStack[] pageStacks = page.getItemStacksForPage();
|
||||
if(pageStacks != null){
|
||||
for(ItemStack stack : pageStacks){
|
||||
if(stack != null && stack.getItem() != null){
|
||||
if(doesTooltipContainString(stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips), text)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FluidStack[] pageFluids = page.getFluidStacksForPage();
|
||||
if(pageFluids != null){
|
||||
for(FluidStack stack : pageFluids){
|
||||
if(stack != null && stack.getFluid() != null){
|
||||
if(doesTooltipContainString(Collections.singletonList(stack.getLocalizedName()), text)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static boolean doesTooltipContainString(List<String> tooltip, String text){
|
||||
for(String s : tooltip){
|
||||
if(s != null && !s.isEmpty()){
|
||||
if(s.toLowerCase(Locale.ROOT).contains(text)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void openIndexEntry(GuiBooklet booklet, IBookletEntry entry, int page, boolean resetTextField){
|
||||
if(booklet.currentEntrySet.getCurrentPage() != null){
|
||||
booklet.currentEntrySet.getCurrentPage().onClosed(booklet);
|
||||
}
|
||||
booklet.currentEntrySet.setPage(null);
|
||||
booklet.currentEntrySet.setChapter(null);
|
||||
|
||||
booklet.currentEntrySet.setEntry(entry);
|
||||
booklet.indexPageAmount = entry == null ? 1 : entry.getChapters().size()/booklet.chapterButtons.length+1;
|
||||
booklet.currentEntrySet.setPageInIndex(entry == null ? 1 : (booklet.indexPageAmount <= page || page <= 0 ? booklet.indexPageAmount : page));
|
||||
|
||||
booklet.buttonPreviousScreen.visible = entry != null;
|
||||
booklet.buttonForward.visible = booklet.currentEntrySet.getPageInIndex() < booklet.indexPageAmount;
|
||||
booklet.buttonBackward.visible = booklet.currentEntrySet.getPageInIndex() > 1;
|
||||
|
||||
booklet.buttonViewOnline.visible = false;
|
||||
|
||||
for(int i = 0; i < booklet.chapterButtons.length; i++){
|
||||
IndexButton button = (IndexButton)booklet.chapterButtons[i];
|
||||
if(entry == null){
|
||||
if(i >= GuiBooklet.INDEX_BUTTONS_OFFSET){
|
||||
boolean entryExists = ActuallyAdditionsAPI.BOOKLET_ENTRIES.size() > i-GuiBooklet.INDEX_BUTTONS_OFFSET;
|
||||
button.visible = entryExists;
|
||||
if(entryExists){
|
||||
button.displayString = "- "+ActuallyAdditionsAPI.BOOKLET_ENTRIES.get(i-GuiBooklet.INDEX_BUTTONS_OFFSET).getLocalizedNameWithFormatting();
|
||||
button.chap = null;
|
||||
}
|
||||
}
|
||||
else{
|
||||
button.visible = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
boolean entryExists = entry.getChapters().size() > i+(booklet.chapterButtons.length*booklet.currentEntrySet.getPageInIndex()-booklet.chapterButtons.length);
|
||||
button.visible = entryExists;
|
||||
if(entryExists){
|
||||
IBookletChapter chap = entry.getChapters().get(i+(booklet.chapterButtons.length*booklet.currentEntrySet.getPageInIndex()-booklet.chapterButtons.length));
|
||||
button.displayString = chap.getLocalizedNameWithFormatting();
|
||||
button.chap = chap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resetTextField){
|
||||
booklet.searchField.setText("");
|
||||
updateSearchBar(booklet);
|
||||
}
|
||||
|
||||
booklet.shouldSaveDataNextClose = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when one of the buttons to open an index or a chapter is pressed
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void handleChapterButtonClick(GuiBooklet booklet, GuiButton button){
|
||||
int place = ArrayUtils.indexOf(booklet.chapterButtons, button);
|
||||
if(place >= 0){
|
||||
if(booklet.currentEntrySet.getCurrentEntry() != null){
|
||||
if(booklet.currentEntrySet.getCurrentChapter() == null){
|
||||
if(place < booklet.currentEntrySet.getCurrentEntry().getChapters().size()){
|
||||
//Clear the search bar when entering a chapter
|
||||
booklet.searchField.setText("");
|
||||
updateSearchBar(booklet);
|
||||
|
||||
IBookletChapter chap = booklet.currentEntrySet.getCurrentEntry().getChapters().get(place+(booklet.chapterButtons.length*booklet.currentEntrySet.getPageInIndex()-booklet.chapterButtons.length));
|
||||
openChapter(booklet, chap, chap.getPages()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(place-GuiBooklet.INDEX_BUTTONS_OFFSET < ActuallyAdditionsAPI.BOOKLET_ENTRIES.size()){
|
||||
openIndexEntry(booklet, ActuallyAdditionsAPI.BOOKLET_ENTRIES.get(place-GuiBooklet.INDEX_BUTTONS_OFFSET), 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a chapter in the booklet.
|
||||
* Can only be done when the chapter is not null and an index entry is opened in the booklet
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void openChapter(GuiBooklet booklet, IBookletChapter chapter, BookletPage page){
|
||||
if(chapter == null || booklet.currentEntrySet.getCurrentEntry() == null){
|
||||
return;
|
||||
}
|
||||
|
||||
booklet.currentEntrySet.setChapter(chapter);
|
||||
|
||||
if(booklet.currentEntrySet.getCurrentPage() != null){
|
||||
booklet.currentEntrySet.getCurrentPage().onClosed(booklet);
|
||||
}
|
||||
BookletPage pageToSet = page != null && doesChapterHavePage(chapter, page) ? page : chapter.getPages()[0];
|
||||
booklet.currentEntrySet.setPage(pageToSet);
|
||||
pageToSet.onOpened(booklet);
|
||||
|
||||
booklet.buttonForward.visible = getNextPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null;
|
||||
booklet.buttonBackward.visible = getPrevPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null;
|
||||
booklet.buttonPreviousScreen.visible = true;
|
||||
|
||||
booklet.buttonViewOnline.visible = true;
|
||||
|
||||
for(GuiButton chapterButton : booklet.chapterButtons){
|
||||
chapterButton.visible = false;
|
||||
}
|
||||
|
||||
booklet.shouldSaveDataNextClose = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a chapter has a certain page
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static boolean doesChapterHavePage(IBookletChapter chapter, BookletPage page){
|
||||
for(BookletPage aPage : chapter.getPages()){
|
||||
if(aPage == page){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next available page in the booklet (or null if there is none)
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static BookletPage getNextPage(IBookletChapter chapter, BookletPage page){
|
||||
for(int i = 0; i < chapter.getPages().length; i++){
|
||||
if(chapter.getPages()[i] == page){
|
||||
if(i+1 < chapter.getPages().length){
|
||||
return chapter.getPages()[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the previous available page in the booklet (or null if there is none)
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static BookletPage getPrevPage(IBookletChapter chapter, BookletPage page){
|
||||
for(int i = 0; i < chapter.getPages().length; i++){
|
||||
if(chapter.getPages()[i] == page){
|
||||
if(i-1 >= 0){
|
||||
return chapter.getPages()[i-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the "next page"-button is pressed
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void handleNextPage(GuiBooklet booklet){
|
||||
if(booklet.currentEntrySet.getCurrentEntry() != null){
|
||||
if(booklet.currentEntrySet.getCurrentPage() != null){
|
||||
BookletPage page = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage());
|
||||
if(page != null){
|
||||
booklet.currentEntrySet.getCurrentPage().onClosed(booklet);
|
||||
booklet.currentEntrySet.setPage(page);
|
||||
page.onOpened(booklet);
|
||||
}
|
||||
|
||||
booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null;
|
||||
booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null;
|
||||
}
|
||||
else{
|
||||
if(booklet.currentEntrySet.getPageInIndex()+1 <= booklet.indexPageAmount){
|
||||
openIndexEntry(booklet, booklet.currentEntrySet.getCurrentEntry(), booklet.currentEntrySet.getPageInIndex()+1, !(booklet.currentEntrySet.getCurrentEntry() instanceof BookletEntryAllSearch));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
booklet.shouldSaveDataNextClose = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the "previous page"-button is pressed
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void handlePreviousPage(GuiBooklet booklet){
|
||||
if(booklet.currentEntrySet.getCurrentEntry() != null){
|
||||
if(booklet.currentEntrySet.getCurrentPage() != null){
|
||||
BookletPage page = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage());
|
||||
if(page != null){
|
||||
booklet.currentEntrySet.getCurrentPage().onClosed(booklet);
|
||||
booklet.currentEntrySet.setPage(page);
|
||||
page.onOpened(booklet);
|
||||
}
|
||||
|
||||
booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null;
|
||||
booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null;
|
||||
}
|
||||
else{
|
||||
if(booklet.currentEntrySet.getPageInIndex()-1 > 0){
|
||||
openIndexEntry(booklet, booklet.currentEntrySet.getCurrentEntry(), booklet.currentEntrySet.getPageInIndex()-1, !(booklet.currentEntrySet.getCurrentEntry() instanceof BookletEntryAllSearch));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
booklet.shouldSaveDataNextClose = true;
|
||||
}
|
||||
|
||||
public static BookletPage getFirstPageForStack(ItemStack stack){
|
||||
ArrayList<BookletPage> pages = getPagesForStack(stack);
|
||||
return pages.isEmpty() ? null : pages.get(0);
|
||||
}
|
||||
|
||||
public static BookletPage getFirstPageForStack(FluidStack stack){
|
||||
ArrayList<BookletPage> pages = getPagesForStack(stack);
|
||||
return pages.isEmpty() ? null : pages.get(0);
|
||||
}
|
||||
|
||||
public static ArrayList<BookletPage> getPagesForStack(ItemStack stack){
|
||||
ArrayList<BookletPage> possiblePages = new ArrayList<BookletPage>();
|
||||
for(BookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA){
|
||||
if(ItemUtil.contains(page.getItemStacksForPage(), stack, page.arePageStacksWildcard)){
|
||||
possiblePages.add(page);
|
||||
}
|
||||
}
|
||||
return possiblePages;
|
||||
}
|
||||
|
||||
public static ArrayList<BookletPage> getPagesForStack(FluidStack stack){
|
||||
ArrayList<BookletPage> possiblePages = new ArrayList<BookletPage>();
|
||||
for(BookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA){
|
||||
for(FluidStack pageStack : page.getFluidStacksForPage()){
|
||||
if(pageStack != null && pageStack.isFluidEqual(stack)){
|
||||
possiblePages.add(page);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return possiblePages;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void saveBookPage(GuiBooklet gui, NBTTagCompound compound){
|
||||
//Save Entry etc.
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
gui.currentEntrySet.writeToNBT(tag);
|
||||
compound.setTag("SavedEntry", tag);
|
||||
compound.setString("SearchWord", gui.searchField.getText());
|
||||
|
||||
//Save Bookmarks
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(int i = 0; i < gui.bookmarkButtons.length; i++){
|
||||
BookmarkButton button = gui.bookmarkButtons[i];
|
||||
|
||||
NBTTagCompound buttonTag = new NBTTagCompound();
|
||||
button.assignedEntry.writeToNBT(buttonTag);
|
||||
list.appendTag(buttonTag);
|
||||
}
|
||||
compound.setTag("Bookmarks", list);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void openLastBookPage(GuiBooklet gui, NBTTagCompound compound){
|
||||
//Open Entry etc.
|
||||
EntrySet set = new EntrySet(null);
|
||||
set.readFromNBT(compound.getCompoundTag("SavedEntry"));
|
||||
if(set != null){
|
||||
|
||||
BookletUtils.openIndexEntry(gui, set.getCurrentEntry(), set.getPageInIndex(), true);
|
||||
if(set.getCurrentChapter() != null){
|
||||
BookletUtils.openChapter(gui, set.getCurrentChapter(), set.getCurrentPage());
|
||||
}
|
||||
|
||||
String searchText = compound.getString("SearchWord");
|
||||
if(!searchText.isEmpty()){
|
||||
gui.searchField.setText(searchText);
|
||||
BookletUtils.updateSearchBar(gui);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//If everything fails, initialize the front page
|
||||
BookletUtils.openIndexEntry(gui, null, 1, true);
|
||||
}
|
||||
|
||||
//Load Bookmarks
|
||||
NBTTagList list = compound.getTagList("Bookmarks", 10);
|
||||
if(list != null){
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
BookmarkButton button = gui.bookmarkButtons[i];
|
||||
button.assignedEntry.readFromNBT(list.getCompoundTagAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,559 +0,0 @@
|
|||
/*
|
||||
* This file ("GuiBooklet.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IEntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.IndexButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.TexturedButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapter;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.config.GuiConfiguration;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBooklet extends GuiScreen implements IBookletGui{
|
||||
|
||||
public static final ResourceLocation RES_LOC = AssetUtil.getBookletGuiLocation("guiBooklet");
|
||||
public static final ResourceLocation RES_LOC_ADDON = AssetUtil.getBookletGuiLocation("guiBookletAddon");
|
||||
|
||||
public static final int CHAPTER_BUTTONS_AMOUNT = 13;
|
||||
public static final int INDEX_BUTTONS_OFFSET = 3;
|
||||
private static final int[] AND_HIS_NAME_IS = new int[]{Keyboard.KEY_C, Keyboard.KEY_E, Keyboard.KEY_N, Keyboard.KEY_A};
|
||||
public final int xSize;
|
||||
public final int ySize;
|
||||
public final IEntrySet currentEntrySet = new EntrySet(null);
|
||||
public final GuiButton[] chapterButtons = new GuiButton[CHAPTER_BUTTONS_AMOUNT];
|
||||
public final BookmarkButton[] bookmarkButtons = new BookmarkButton[8];
|
||||
public final GuiScreen parentScreen;
|
||||
private final boolean tryOpenMainPage;
|
||||
private final boolean saveOnClose;
|
||||
public int guiLeft;
|
||||
public int guiTop;
|
||||
public int indexPageAmount;
|
||||
public GuiButton buttonForward;
|
||||
public GuiButton buttonBackward;
|
||||
public GuiButton buttonPreviousScreen;
|
||||
public GuiButton buttonUpdate;
|
||||
public GuiButton buttonTwitter;
|
||||
public GuiButton buttonForum;
|
||||
public GuiButton buttonAchievements;
|
||||
public GuiButton buttonConfig;
|
||||
public GuiButton buttonWebsite;
|
||||
public GuiButton buttonPatreon;
|
||||
public GuiButton buttonViewOnline;
|
||||
public GuiTextField searchField;
|
||||
public boolean shouldSaveDataNextClose;
|
||||
public String bookletName;
|
||||
public GuiButton buttonIntroduction;
|
||||
private int ticksElapsed;
|
||||
private boolean mousePressed;
|
||||
private int hisNameIsAt;
|
||||
|
||||
public GuiBooklet(GuiScreen parentScreen, boolean tryOpenMainPage, boolean saveOnClose){
|
||||
this.xSize = 146;
|
||||
this.ySize = 180;
|
||||
this.parentScreen = parentScreen;
|
||||
this.tryOpenMainPage = tryOpenMainPage;
|
||||
this.saveOnClose = saveOnClose;
|
||||
}
|
||||
|
||||
public FontRenderer getFontRenderer(){
|
||||
return this.fontRendererObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getButtonList(){
|
||||
return this.buttonList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float f){
|
||||
//Fixes Unicode flag
|
||||
boolean unicodeBefore = this.fontRendererObj.getUnicodeFlag();
|
||||
this.fontRendererObj.setUnicodeFlag(true);
|
||||
|
||||
//To Player:
|
||||
//
|
||||
//FastCraft's a must, definitely
|
||||
//But the bigger unicode option sucks real
|
||||
//It screws with my book and makes me feel ill
|
||||
//So don't fuck with everything unintentionally
|
||||
//
|
||||
//(This fixes your fuckery)
|
||||
GlStateManager.scale(1.0F, 1.0F, 1.0F);
|
||||
|
||||
//Draws the Background
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(RES_LOC);
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
//Draws the search bar
|
||||
this.drawTexturedModalRect(this.guiLeft+146, this.guiTop+160, 146, 80, 70, 14);
|
||||
if(!this.searchField.isFocused() && (this.searchField.getText() == null || this.searchField.getText().isEmpty())){
|
||||
this.drawString(this.fontRendererObj, TextFormatting.ITALIC+"Click to search...", this.guiLeft+148, this.guiTop+162, 0xFFFFFF);
|
||||
}
|
||||
|
||||
//Draws Achievement Info
|
||||
BookletUtils.drawAchievementInfo(this, true, x, y);
|
||||
|
||||
this.fontRendererObj.setUnicodeFlag(false);
|
||||
//Draws the title
|
||||
BookletUtils.drawTitle(this);
|
||||
|
||||
if(this.buttonIntroduction.visible){
|
||||
StringUtil.drawSplitString(this.fontRendererObj, TextFormatting.GREEN+"Hi! It looks like you're using this manual! Would you like help? "+TextFormatting.RESET+"\nClick the button below to save a couple of "+TextFormatting.GOLD+"useful chapters as bookmarks"+TextFormatting.RESET+" on the bottom of the GUI! \nIf you don't want this, shift-click the button instead.", this.guiLeft+150, this.guiTop+10, 100, 0xFFFFFF, true);
|
||||
|
||||
this.mc.getTextureManager().bindTexture(RES_LOC_ADDON);
|
||||
this.drawTexturedModalRect(this.guiLeft+240, this.guiTop-10, 226, 0, 30, 55);
|
||||
this.mc.getTextureManager().bindTexture(RES_LOC);
|
||||
}
|
||||
this.fontRendererObj.setUnicodeFlag(true);
|
||||
|
||||
//Pre-Renders the current page's content etc.
|
||||
BookletUtils.renderPre(this, x, y, this.ticksElapsed, this.mousePressed);
|
||||
|
||||
//Buttons and search field
|
||||
if(this.currentEntrySet.getCurrentPage() != null){
|
||||
this.fontRendererObj.setUnicodeFlag(false);
|
||||
}
|
||||
for(GuiButton button : this.buttonList){
|
||||
button.drawButton(this.mc, x, y);
|
||||
}
|
||||
this.fontRendererObj.setUnicodeFlag(true);
|
||||
|
||||
this.searchField.drawTextBox();
|
||||
|
||||
//Renders the current page's content
|
||||
if(this.currentEntrySet.getCurrentEntry() != null && this.currentEntrySet.getCurrentChapter() != null && this.currentEntrySet.getCurrentPage() != null){
|
||||
this.currentEntrySet.getCurrentPage().render(this, x, y, this.ticksElapsed, this.mousePressed);
|
||||
}
|
||||
|
||||
this.fontRendererObj.setUnicodeFlag(false);
|
||||
//Draws hovering texts for buttons
|
||||
BookletUtils.doHoverTexts(this, x, y);
|
||||
BookletUtils.drawAchievementInfo(this, false, x, y);
|
||||
this.fontRendererObj.setUnicodeFlag(unicodeBefore);
|
||||
|
||||
//Resets mouse
|
||||
this.mousePressed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char theChar, int key){
|
||||
if(!this.searchField.isFocused() && AND_HIS_NAME_IS.length > this.hisNameIsAt && AND_HIS_NAME_IS[this.hisNameIsAt] == key){
|
||||
if(this.hisNameIsAt+1 >= AND_HIS_NAME_IS.length){
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundHandler.duhDuhDuhDuuuh, 0.5F));
|
||||
ModUtil.LOGGER.info("AND HIS NAME IS JOHN CENA DUH DUH DUH DUUUH");
|
||||
this.hisNameIsAt = 0;
|
||||
}
|
||||
else{
|
||||
this.hisNameIsAt++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.hisNameIsAt = 0;
|
||||
|
||||
if(key == Keyboard.KEY_ESCAPE || (key == this.mc.gameSettings.keyBindInventory.getKeyCode() && !this.searchField.isFocused())){
|
||||
if(this.parentScreen != null){
|
||||
this.mc.displayGuiScreen(this.parentScreen);
|
||||
}
|
||||
else{
|
||||
this.mc.displayGuiScreen(null);
|
||||
this.mc.setIngameFocus();
|
||||
}
|
||||
}
|
||||
else if(this.searchField.isFocused()){
|
||||
this.searchField.textboxKeyTyped(theChar, key);
|
||||
BookletUtils.updateSearchBar(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawHoveringText(List list, int x, int y){
|
||||
super.drawHoveringText(list, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int par1, int par2, int par3) throws IOException{
|
||||
this.searchField.mouseClicked(par1, par2, par3);
|
||||
//Left mouse button
|
||||
if(par3 == 0 && this.currentEntrySet.getCurrentChapter() != null){
|
||||
this.mousePressed = true;
|
||||
}
|
||||
//Right mouse button
|
||||
else if(par3 == 1){
|
||||
if(this.currentEntrySet.getCurrentChapter() != null){
|
||||
BookletUtils.openIndexEntry(this, this.currentEntrySet.getCurrentEntry(), this.currentEntrySet.getPageInIndex(), true);
|
||||
}
|
||||
else{
|
||||
BookletUtils.openIndexEntry(this, null, 1, true);
|
||||
}
|
||||
}
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
if(this.currentEntrySet.getCurrentPage() != null){
|
||||
if(this.currentEntrySet.getCurrentPage().onActionPerformed(this, button)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Handles introduction
|
||||
if(button == this.buttonIntroduction){
|
||||
this.buttonIntroduction.visible = false;
|
||||
|
||||
if(!isShiftKeyDown()){
|
||||
for(int i = 0; i < InitBooklet.chaptersIntroduction.length; i++){
|
||||
BookletChapter chap = InitBooklet.chaptersIntroduction[i];
|
||||
this.bookmarkButtons[i].assignedEntry.setEntry(chap.getPages()[0], chap, chap.getEntry(), ActuallyAdditionsAPI.BOOKLET_ENTRIES.indexOf(chap.getEntry())/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1);
|
||||
}
|
||||
this.shouldSaveDataNextClose = true;
|
||||
}
|
||||
|
||||
NBTTagCompound extraData = new NBTTagCompound();
|
||||
extraData.setBoolean("IntroductionDone", true);
|
||||
PacketHandlerHelper.sendChangePlayerDataPacket(extraData);
|
||||
}
|
||||
//Handles update
|
||||
else if(button == this.buttonUpdate){
|
||||
if(UpdateChecker.needsUpdateNotify){
|
||||
BookletUtils.openBrowser(UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK);
|
||||
}
|
||||
}
|
||||
//Handles View Online
|
||||
else if(button == this.buttonViewOnline){
|
||||
IBookletChapter chapter = this.currentEntrySet.getCurrentChapter();
|
||||
if(chapter != null){
|
||||
BookletUtils.openBrowser("http://ellpeck.de/actaddmanual/#"+chapter.getIdentifier());
|
||||
}
|
||||
}
|
||||
//Handles Website
|
||||
else if(button == this.buttonWebsite){
|
||||
BookletUtils.openBrowser("http://ellpeck.de");
|
||||
}
|
||||
//Handles Patreon
|
||||
else if(button == this.buttonPatreon){
|
||||
BookletUtils.openBrowser("http://www.patreon.com/Ellpeck");
|
||||
}
|
||||
//Handles Twitter
|
||||
else if(button == this.buttonTwitter){
|
||||
BookletUtils.openBrowser("http://twitter.com/ActAddMod");
|
||||
}
|
||||
//Handles forum
|
||||
else if(button == this.buttonForum){
|
||||
BookletUtils.openBrowser("http://ellpeck.de/actadd");
|
||||
}
|
||||
//Handles config
|
||||
else if(button == this.buttonConfig){
|
||||
this.mc.displayGuiScreen(new GuiConfiguration(this));
|
||||
}
|
||||
//Handles achievements
|
||||
else if(button == this.buttonAchievements){
|
||||
this.mc.displayGuiScreen(new GuiAAAchievements(this, this.mc.thePlayer.getStatFileWriter()));
|
||||
}
|
||||
else if(button == this.buttonForward){
|
||||
BookletUtils.handleNextPage(this);
|
||||
}
|
||||
else if(button == this.buttonBackward){
|
||||
BookletUtils.handlePreviousPage(this);
|
||||
}
|
||||
//Handles gonig from page to chapter or from chapter to index
|
||||
else if(button == this.buttonPreviousScreen){
|
||||
if(this.currentEntrySet.getCurrentChapter() != null){
|
||||
BookletUtils.openIndexEntry(this, this.currentEntrySet.getCurrentEntry(), this.currentEntrySet.getPageInIndex(), true);
|
||||
}
|
||||
else{
|
||||
BookletUtils.openIndexEntry(this, null, 1, true);
|
||||
}
|
||||
}
|
||||
//Handles Bookmark button
|
||||
else if(button instanceof BookmarkButton){
|
||||
((BookmarkButton)button).onPressed();
|
||||
}
|
||||
else{
|
||||
BookletUtils.handleChapterButtonClick(this, button);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
int flavor = 1;
|
||||
if(this.mc.theWorld.rand.nextFloat() <= 0.1){
|
||||
flavor = MathHelper.getRandomIntegerInRange(this.mc.theWorld.rand, 2, 7);
|
||||
}
|
||||
this.bookletName = "info."+ModUtil.MOD_ID+".booklet.manualName.1."+flavor;
|
||||
|
||||
this.guiLeft = (this.width-this.xSize)/2;
|
||||
this.guiTop = (this.height-this.ySize)/2-10;
|
||||
|
||||
this.buttonForward = new TexturedButton(0, this.guiLeft+this.xSize-26, this.guiTop+this.ySize+1, 164, 0, 18, 10, Collections.singletonList(TextFormatting.GOLD+"Next Page"));
|
||||
this.buttonList.add(this.buttonForward);
|
||||
|
||||
this.buttonBackward = new TexturedButton(1, this.guiLeft+8, this.guiTop+this.ySize+1, 146, 0, 18, 10, Collections.singletonList(TextFormatting.GOLD+"Previous Page"));
|
||||
this.buttonList.add(this.buttonBackward);
|
||||
|
||||
this.buttonPreviousScreen = new TexturedButton(2, this.guiLeft+this.xSize/2-7, this.guiTop+this.ySize+1, 182, 0, 15, 10, Collections.singletonList(TextFormatting.GOLD+"Back"));
|
||||
this.buttonList.add(this.buttonPreviousScreen);
|
||||
|
||||
ArrayList updateHover = new ArrayList();
|
||||
if(UpdateChecker.checkFailed){
|
||||
updateHover.add(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ModUtil.MOD_ID+".update.failed")).getFormattedText());
|
||||
}
|
||||
else if(UpdateChecker.needsUpdateNotify){
|
||||
updateHover.add(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ModUtil.MOD_ID+".update.generic")).getFormattedText());
|
||||
updateHover.add(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID+".update.versionCompare", ModUtil.VERSION, UpdateChecker.updateVersionString)).getFormattedText());
|
||||
updateHover.add(StringUtil.localize("info."+ModUtil.MOD_ID+".update.buttonOptions"));
|
||||
}
|
||||
this.buttonUpdate = new TexturedButton(4, this.guiLeft-11, this.guiTop-11, 245, 0, 11, 11, updateHover);
|
||||
this.buttonUpdate.visible = UpdateChecker.needsUpdateNotify || UpdateChecker.checkFailed;
|
||||
this.buttonList.add(this.buttonUpdate);
|
||||
|
||||
this.buttonTwitter = new TexturedButton(5, this.guiLeft, this.guiTop+10, 213, 0, 8, 8, Collections.singletonList(TextFormatting.GOLD+"Open @ActAddMod on Twitter in Browser"));
|
||||
this.buttonList.add(this.buttonTwitter);
|
||||
|
||||
this.buttonForum = new TexturedButton(6, this.guiLeft, this.guiTop+20, 221, 0, 8, 8, Collections.singletonList(TextFormatting.GOLD+"Open CurseForge Page in Browser"));
|
||||
this.buttonList.add(this.buttonForum);
|
||||
|
||||
this.buttonAchievements = new TexturedButton(7, this.guiLeft+138, this.guiTop, 205, 0, 8, 8, Collections.singletonList(TextFormatting.GOLD+"Show Achievements"));
|
||||
this.buttonList.add(this.buttonAchievements);
|
||||
|
||||
ArrayList websiteHover = new ArrayList();
|
||||
websiteHover.add(TextFormatting.GOLD+"Open Author's Website");
|
||||
websiteHover.add("(There's some cool stuff there!)");
|
||||
websiteHover.add(TextFormatting.GRAY+""+TextFormatting.ITALIC+"Would you call this Product Placement?");
|
||||
this.buttonWebsite = new TexturedButton(-99, this.guiLeft, this.guiTop+30, 229, 0, 8, 8, websiteHover);
|
||||
this.buttonList.add(this.buttonWebsite);
|
||||
|
||||
List<String> patreonHover = new ArrayList<String>();
|
||||
patreonHover.add("Like the mod?");
|
||||
patreonHover.add("Why don't support me on "+TextFormatting.GOLD+"Patreon"+TextFormatting.RESET+"?");
|
||||
this.buttonPatreon = new TexturedButton(-100, this.guiLeft, this.guiTop, 237, 0, 8, 8, patreonHover);
|
||||
this.buttonList.add(this.buttonPatreon);
|
||||
|
||||
this.buttonViewOnline = new TexturedButton(-101, this.guiLeft+146, this.guiTop+180, 245, 44, 11, 11, Collections.singletonList(TextFormatting.GOLD+"View Online"));
|
||||
this.buttonList.add(this.buttonViewOnline);
|
||||
|
||||
ArrayList configHover = new ArrayList();
|
||||
configHover.add(TextFormatting.GOLD+"Show Configuration GUI");
|
||||
configHover.addAll(this.fontRendererObj.listFormattedStringToWidth("It is highly recommended that you restart your game after changing anything as that prevents possible bugs occuring!", 200));
|
||||
this.buttonConfig = new TexturedButton(8, this.guiLeft+138, this.guiTop+10, 197, 0, 8, 8, configHover);
|
||||
this.buttonList.add(this.buttonConfig);
|
||||
|
||||
for(int i = 0; i < this.chapterButtons.length; i++){
|
||||
this.chapterButtons[i] = new IndexButton(9+i, this.guiLeft+15, this.guiTop+10+(i*12), 115, 10, "", this);
|
||||
this.buttonList.add(this.chapterButtons[i]);
|
||||
}
|
||||
|
||||
for(int i = 0; i < this.bookmarkButtons.length; i++){
|
||||
int x = this.guiLeft+this.xSize/2-(this.bookmarkButtons.length/2*16)+(i*16);
|
||||
this.bookmarkButtons[i] = new BookmarkButton(this.chapterButtons[this.chapterButtons.length-1].id+1+i, x, this.guiTop+this.ySize+13, this);
|
||||
this.buttonList.add(this.bookmarkButtons[i]);
|
||||
}
|
||||
|
||||
this.searchField = new GuiTextField(4500, this.fontRendererObj, this.guiLeft+148, this.guiTop+162, 70, 10);
|
||||
this.searchField.setMaxStringLength(30);
|
||||
this.searchField.setEnableBackgroundDrawing(false);
|
||||
|
||||
this.currentEntrySet.removeEntry();
|
||||
|
||||
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(Minecraft.getMinecraft().thePlayer);
|
||||
|
||||
this.buttonIntroduction = new TexturedButton(-3531, this.guiLeft+150, this.guiTop+128, 245, 0, 11, 11);
|
||||
this.buttonList.add(this.buttonIntroduction);
|
||||
this.buttonIntroduction.visible = !data.theCompound.getBoolean("IntroductionDone");
|
||||
|
||||
if(ItemBooklet.forcedEntry == null){
|
||||
//Open last entry or introductory entry
|
||||
if(this.tryOpenMainPage && !data.theCompound.getBoolean("BookAlreadyOpened")){
|
||||
BookletUtils.openIndexEntry(this, InitBooklet.chapterIntro.entry, 1, true);
|
||||
BookletUtils.openChapter(this, InitBooklet.chapterIntro, null);
|
||||
|
||||
NBTTagCompound extraData = new NBTTagCompound();
|
||||
extraData.setBoolean("BookAlreadyOpened", true);
|
||||
PacketHandlerHelper.sendChangePlayerDataPacket(extraData);
|
||||
}
|
||||
else{
|
||||
BookletUtils.openLastBookPage(this, data.theCompound.getCompoundTag("BookletData"));
|
||||
}
|
||||
this.shouldSaveDataNextClose = false;
|
||||
}
|
||||
else{
|
||||
//Open forced entry
|
||||
BookletUtils.openIndexEntry(this, ItemBooklet.forcedEntry.getCurrentEntry(), ItemBooklet.forcedEntry.getPageInIndex(), true);
|
||||
BookletUtils.openChapter(this, ItemBooklet.forcedEntry.getCurrentChapter(), ItemBooklet.forcedEntry.getCurrentPage());
|
||||
ItemBooklet.forcedEntry = null;
|
||||
|
||||
this.shouldSaveDataNextClose = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
//For scrolling through pages
|
||||
public void handleMouseInput() throws IOException{
|
||||
int wheel = Mouse.getEventDWheel();
|
||||
if(wheel != 0){
|
||||
if(wheel < 0){
|
||||
BookletUtils.handleNextPage(this);
|
||||
}
|
||||
else if(wheel > 0){
|
||||
BookletUtils.handlePreviousPage(this);
|
||||
}
|
||||
}
|
||||
super.handleMouseInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(){
|
||||
super.updateScreen();
|
||||
this.searchField.updateCursorCounter();
|
||||
|
||||
if(this.currentEntrySet.getCurrentEntry() != null && this.currentEntrySet.getCurrentChapter() != null && this.currentEntrySet.getCurrentPage() != null){
|
||||
this.currentEntrySet.getCurrentPage().updateScreen(this.ticksElapsed);
|
||||
}
|
||||
|
||||
boolean buttonThere = UpdateChecker.needsUpdateNotify || UpdateChecker.checkFailed;
|
||||
this.buttonUpdate.visible = buttonThere;
|
||||
if(buttonThere){
|
||||
if(this.ticksElapsed%8 == 0){
|
||||
TexturedButton button = (TexturedButton)this.buttonUpdate;
|
||||
button.setTexturePos(245, button.texturePosY == 0 ? 22 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
this.ticksElapsed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed(){
|
||||
if(this.saveOnClose && this.shouldSaveDataNextClose){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
//Happens when you get thrown out with the book open
|
||||
if(mc.theWorld != null && mc.thePlayer != null){
|
||||
NBTTagCompound bookletData = new NBTTagCompound();
|
||||
BookletUtils.saveBookPage(this, bookletData);
|
||||
|
||||
NBTTagCompound extraData = new NBTTagCompound();
|
||||
extraData.setTag("BookletData", bookletData);
|
||||
|
||||
PacketHandlerHelper.sendChangePlayerDataPacket(extraData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTooltipAndTransferButton(BookletPage from, ItemStack stack, int x, int y, boolean renderTransferButton, boolean mousePressed){
|
||||
boolean flagBefore = this.mc.fontRendererObj.getUnicodeFlag();
|
||||
this.mc.fontRendererObj.setUnicodeFlag(false);
|
||||
|
||||
List list = stack.getTooltip(this.mc.thePlayer, this.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, TextFormatting.GRAY+(String)list.get(k));
|
||||
}
|
||||
}
|
||||
|
||||
if(renderTransferButton){
|
||||
BookletPage page = BookletUtils.getFirstPageForStack(stack);
|
||||
if(page != null && page != from){
|
||||
list.add(from.getClickToSeeRecipeString());
|
||||
|
||||
if(mousePressed){
|
||||
BookletUtils.openIndexEntry(this, page.getChapter().getEntry(), ActuallyAdditionsAPI.BOOKLET_ENTRIES.indexOf(page.getChapter().getEntry())/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true);
|
||||
BookletUtils.openChapter(this, page.getChapter(), page);
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.drawHoveringText(list, x, y);
|
||||
|
||||
this.mc.fontRendererObj.setUnicodeFlag(flagBefore);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getXSize(){
|
||||
return this.xSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYSize(){
|
||||
return this.ySize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGuiLeft(){
|
||||
return this.guiLeft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGuiTop(){
|
||||
return this.guiTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRect(int startX, int startY, int u, int v, int xSize, int ySize){
|
||||
this.drawTexturedModalRect(startX, startY, u, v, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntrySet getCurrentEntrySet(){
|
||||
return this.currentEntrySet;
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* This file ("GuiBookletStand.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBookletStand extends GuiBooklet{
|
||||
|
||||
private final TileEntityBookletStand theStand;
|
||||
private GuiButton buttonSetPage;
|
||||
|
||||
public GuiBookletStand(TileEntityBase theStand){
|
||||
super(null, false, false);
|
||||
this.theStand = (TileEntityBookletStand)theStand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
if(button == this.buttonSetPage){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.theStand.getPos().getX());
|
||||
compound.setInteger("Y", this.theStand.getPos().getY());
|
||||
compound.setInteger("Z", this.theStand.getPos().getZ());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("WorldID", this.theStand.getWorld().provider.getDimension());
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.currentEntrySet.writeToNBT(tag);
|
||||
compound.setTag("EntrySet", tag);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.BOOKLET_STAND_BUTTON_HANDLER));
|
||||
}
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
//Remove Bookmark Buttons
|
||||
this.buttonIntroduction.visible = false;
|
||||
for(GuiButton bookmarkButton : this.bookmarkButtons){
|
||||
bookmarkButton.visible = false;
|
||||
}
|
||||
|
||||
this.buttonSetPage = new GuiButton(-100, this.guiLeft+this.xSize+10, this.guiTop+10, 100, 20, "Set Page"){
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int x, int y){
|
||||
boolean unicodeBefore = mc.fontRendererObj.getUnicodeFlag();
|
||||
mc.fontRendererObj.setUnicodeFlag(false);
|
||||
super.drawButton(mc, x, y);
|
||||
mc.fontRendererObj.setUnicodeFlag(unicodeBefore);
|
||||
}
|
||||
};
|
||||
this.buttonList.add(this.buttonSetPage);
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if(player != null && player.getName() != null){
|
||||
this.buttonSetPage.visible = player.getName().equalsIgnoreCase(this.theStand.assignedPlayer);
|
||||
}
|
||||
|
||||
//Open the pages the book was assigned
|
||||
BookletUtils.openIndexEntry(this, this.theStand.assignedEntry.getCurrentEntry(), this.theStand.assignedEntry.getPageInIndex(), true);
|
||||
BookletUtils.openChapter(this, this.theStand.assignedEntry.getCurrentChapter(), this.theStand.assignedEntry.getCurrentPage());
|
||||
}
|
||||
}
|
|
@ -11,17 +11,15 @@
|
|||
package de.ellpeck.actuallyadditions.mod.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapter;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterCoffee;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterCrusher;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntry;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllSearch;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllItems;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.*;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.*;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
|
@ -60,40 +58,43 @@ public final class InitBooklet{
|
|||
ActuallyAdditionsAPI.entryItemsNonRF = new BookletEntry("itemsNoRF");
|
||||
ActuallyAdditionsAPI.entryItemsRF = new BookletEntry("itemsRF");
|
||||
ActuallyAdditionsAPI.entryMisc = new BookletEntry("misc").setSpecial();
|
||||
ActuallyAdditionsAPI.allAndSearch = new BookletEntryAllSearch("allAndSearch").setImportant();
|
||||
ActuallyAdditionsAPI.allAndSearch = new BookletEntryAllItems("allAndSearch").setImportant();
|
||||
}
|
||||
|
||||
public static void postInit(){
|
||||
initChapters();
|
||||
|
||||
int totalCount = 0;
|
||||
int count = 0;
|
||||
int chapCount = 0;
|
||||
int pageCount = 0;
|
||||
int infoCount = 0;
|
||||
for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){
|
||||
for(IBookletChapter chapter : entry.getChapters()){
|
||||
for(IBookletChapter chapter : entry.getAllChapters()){
|
||||
if(!ActuallyAdditionsAPI.ALL_CHAPTERS.contains(chapter)){
|
||||
ActuallyAdditionsAPI.ALL_CHAPTERS.add(chapter);
|
||||
chapCount++;
|
||||
}
|
||||
|
||||
for(BookletPage page : chapter.getPages()){
|
||||
for(IBookletPage page : chapter.getAllPages()){
|
||||
ItemStack[] items = page.getItemStacksForPage();
|
||||
FluidStack[] fluids = page.getFluidStacksForPage();
|
||||
|
||||
if((items != null && items.length > 0) || (fluids != null && fluids.length > 0)){
|
||||
if(!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)){
|
||||
ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page);
|
||||
count++;
|
||||
infoCount++;
|
||||
}
|
||||
}
|
||||
|
||||
totalCount++;
|
||||
pageCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModUtil.LOGGER.info("Registered "+count+" out of "+totalCount+" booklet pages as containing information about items or fluids!");
|
||||
ModUtil.LOGGER.info("Registered a total of "+chapCount+" booklet chapters, where "+infoCount+" out of "+pageCount+" booklet pages contain information about items or fluids!");
|
||||
}
|
||||
|
||||
private static void initChapters(){
|
||||
/* TODO Reenable this
|
||||
//Getting Started
|
||||
chapterIntro = new BookletChapter("intro", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3));
|
||||
new BookletChapter("reviews", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.BOOK), new PageTextOnly(1));
|
||||
|
@ -230,5 +231,5 @@ public final class InitBooklet{
|
|||
new BookletChapter("growthRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemGrowthRing), new PageCrafting(1, ItemCrafting.recipeGrowthRing));
|
||||
new BookletChapter("waterRemovalRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemWaterRemovalRing), new PageCrafting(1, ItemCrafting.recipeWaterRing));
|
||||
new BookletChapter("batteries", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemBatteryTriple), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBattery).setNoText(), new PageCrafting(3, ItemCrafting.recipeBatteryDouble).setNoText(), new PageCrafting(4, ItemCrafting.recipeBatteryTriple).setNoText(), new PageCrafting(5, ItemCrafting.recipeBatteryQuadruple).setNoText(), new PageCrafting(6, ItemCrafting.recipeBatteryQuintuple).setNoText());
|
||||
}
|
||||
*/}
|
||||
}
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* This file ("BookmarkButton.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.button;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BookmarkButton extends GuiButton{
|
||||
|
||||
private final GuiBooklet booklet;
|
||||
public EntrySet assignedEntry = new EntrySet(null);
|
||||
|
||||
public BookmarkButton(int id, int x, int y, GuiBooklet booklet){
|
||||
super(id, x, y, 16, 16, "");
|
||||
this.booklet = booklet;
|
||||
}
|
||||
|
||||
public void onPressed(){
|
||||
if(this.assignedEntry.getCurrentEntry() != null){
|
||||
if(GuiScreen.isShiftKeyDown()){
|
||||
this.assignedEntry.removeEntry();
|
||||
this.booklet.shouldSaveDataNextClose = true;
|
||||
}
|
||||
else{
|
||||
BookletUtils.openIndexEntry(this.booklet, this.assignedEntry.getCurrentEntry(), this.assignedEntry.getPageInIndex(), true);
|
||||
BookletUtils.openChapter(this.booklet, this.assignedEntry.getCurrentChapter(), this.assignedEntry.getCurrentPage());
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(this.booklet.currentEntrySet.getCurrentEntry() != null){
|
||||
this.assignedEntry.setEntry(this.booklet.currentEntrySet.getCurrentPage(), this.booklet.currentEntrySet.getCurrentChapter(), this.booklet.currentEntrySet.getCurrentEntry(), this.booklet.currentEntrySet.getPageInIndex());
|
||||
this.booklet.shouldSaveDataNextClose = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int x, int y){
|
||||
if(this.visible){
|
||||
minecraft.getTextureManager().bindTexture(GuiBooklet.RES_LOC);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.hovered = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height;
|
||||
int k = this.getHoverState(this.hovered);
|
||||
if(k == 0){
|
||||
k = 1;
|
||||
}
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.blendFunc(770, 771);
|
||||
int renderHeight = 25;
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 146+(this.assignedEntry.getCurrentEntry() == null ? 0 : 16), 194-renderHeight+k*renderHeight, this.width, renderHeight);
|
||||
this.mouseDragged(minecraft, x, y);
|
||||
|
||||
if(this.assignedEntry.getCurrentEntry() != null){
|
||||
GlStateManager.pushMatrix();
|
||||
AssetUtil.renderStackToGui(this.assignedEntry.getCurrentChapter() != null && this.assignedEntry.getCurrentChapter().getDisplayItemStack() != null ? this.assignedEntry.getCurrentChapter().getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), this.xPosition+2, this.yPosition+1, 0.725F);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawHover(int mouseX, int mouseY){
|
||||
ArrayList list = new ArrayList();
|
||||
if(this.assignedEntry.getCurrentEntry() != null){
|
||||
if(this.assignedEntry.getCurrentChapter() != null){
|
||||
list.add(TextFormatting.GOLD+this.assignedEntry.getCurrentChapter().getLocalizedName()+", Page "+this.assignedEntry.getCurrentPage().getID());
|
||||
}
|
||||
else{
|
||||
list.add(TextFormatting.GOLD+this.assignedEntry.getCurrentEntry().getLocalizedName()+", Page "+this.assignedEntry.getPageInIndex());
|
||||
}
|
||||
list.add("Click to open");
|
||||
list.add(TextFormatting.ITALIC+"Shift-Click to remove");
|
||||
}
|
||||
else{
|
||||
list.add(TextFormatting.GOLD+"None");
|
||||
list.add("Click to save current page");
|
||||
}
|
||||
this.booklet.drawHoveringText(list, mouseX, mouseY);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* This file ("IndexButton.java") is part of the Actually Additions mod for Minecraft.
|
||||
* This file ("EntryButton.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://ellpeck.de/actaddlicense
|
||||
|
@ -10,24 +10,23 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.button;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class IndexButton extends GuiButton{
|
||||
public class EntryButton extends GuiButton{
|
||||
|
||||
private final GuiBooklet gui;
|
||||
public IBookletChapter chap;
|
||||
public ItemStack stackToRender;
|
||||
|
||||
public IndexButton(int id, int x, int y, int width, int height, String text, GuiBooklet gui){
|
||||
public EntryButton(int id, int x, int y, int width, int height, String text, ItemStack stackToRender){
|
||||
super(id, x, y, width, height, text);
|
||||
this.gui = gui;
|
||||
this.stackToRender = stackToRender;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,22 +40,22 @@ public class IndexButton extends GuiButton{
|
|||
this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
|
||||
int textOffsetX = 0;
|
||||
if(this.chap != null){
|
||||
if(this.chap.getDisplayItemStack() != null){
|
||||
GlStateManager.pushMatrix();
|
||||
AssetUtil.renderStackToGui(this.chap.getDisplayItemStack(), this.xPosition-4, this.yPosition, 0.725F);
|
||||
GlStateManager.popMatrix();
|
||||
textOffsetX = 10;
|
||||
}
|
||||
if(this.stackToRender != null){
|
||||
GlStateManager.pushMatrix();
|
||||
AssetUtil.renderStackToGui(this.stackToRender, this.xPosition-4, this.yPosition, 0.725F);
|
||||
GlStateManager.popMatrix();
|
||||
textOffsetX = 10;
|
||||
}
|
||||
|
||||
float scale = 0.8F;
|
||||
|
||||
if(this.hovered){
|
||||
GlStateManager.pushMatrix();
|
||||
AssetUtil.drawHorizontalGradientRect(this.xPosition+textOffsetX-1, this.yPosition+this.height-1, this.xPosition+this.gui.getFontRenderer().getStringWidth(this.displayString)+textOffsetX+1, this.yPosition+this.height, 0x80 << 24 | 22271, 22271, this.zLevel);
|
||||
AssetUtil.drawHorizontalGradientRect(this.xPosition+textOffsetX-1, this.yPosition+this.height-2, this.xPosition+(int)(minecraft.fontRendererObj.getStringWidth(this.displayString)*scale)+textOffsetX+1, this.yPosition+this.height-1, 0x80 << 24 | 22271, 22271, this.zLevel);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
this.gui.getFontRenderer().drawString(this.displayString, this.xPosition+textOffsetX, this.yPosition+(this.height-8)/2, 0);
|
||||
StringUtil.renderScaledAsciiString(minecraft.fontRendererObj, this.displayString, this.xPosition+textOffsetX, this.yPosition+(this.height-8)/2, 0, false, scale);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,54 +11,42 @@
|
|||
package de.ellpeck.actuallyadditions.mod.booklet.chapter;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
public class BookletChapter implements IBookletChapter{
|
||||
|
||||
public final BookletPage[] pages;
|
||||
public final IBookletPage[] pages;
|
||||
public final IBookletEntry entry;
|
||||
public final ItemStack displayStack;
|
||||
private final String identifier;
|
||||
public TextFormatting color;
|
||||
|
||||
public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, BookletPage... pages){
|
||||
this.pages = pages.clone();
|
||||
|
||||
public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages){
|
||||
this.pages = pages;
|
||||
this.identifier = identifier;
|
||||
entry.addChapter(this);
|
||||
ActuallyAdditionsAPI.allAndSearch.addChapter(this);
|
||||
this.entry = entry;
|
||||
this.displayStack = displayStack;
|
||||
this.color = TextFormatting.RESET;
|
||||
|
||||
for(BookletPage page : this.pages){
|
||||
this.entry.addChapter(this);
|
||||
ActuallyAdditionsAPI.allAndSearch.addChapter(this);
|
||||
|
||||
for(IBookletPage page : this.pages){
|
||||
page.setChapter(this);
|
||||
}
|
||||
|
||||
this.color = TextFormatting.RESET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookletPage[] getPages(){
|
||||
public IBookletPage[] getAllPages(){
|
||||
return this.pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookletPage getPageById(int id){
|
||||
return this.getPages()[id-1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageId(BookletPage page){
|
||||
return ArrayUtils.indexOf(this.getPages(), page)+1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedName(){
|
||||
return StringUtil.localize("booklet."+ModUtil.MOD_ID+".chapter."+this.getIdentifier()+".name");
|
||||
|
@ -84,6 +72,16 @@ public class BookletChapter implements IBookletChapter{
|
|||
return this.identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageNum(IBookletPage page){
|
||||
for(int i = 0; i < this.pages.length; i++){
|
||||
if(this.pages[i] == page){
|
||||
return i+1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public BookletChapter setImportant(){
|
||||
this.color = TextFormatting.DARK_GREEN;
|
||||
return this;
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* This file ("BookletChapterCoffee.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.chapter;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.BookletPageAA;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PageCoffeeRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BookletChapterCoffee extends BookletChapter{
|
||||
|
||||
public BookletChapterCoffee(String unlocalizedName, IBookletEntry entry, ItemStack displayStack, BookletPage... pages){
|
||||
super(unlocalizedName, entry, displayStack, getPages(pages));
|
||||
}
|
||||
|
||||
private static BookletPage[] getPages(BookletPage... pages){
|
||||
ArrayList<BookletPage> allPages = new ArrayList<BookletPage>();
|
||||
allPages.addAll(Arrays.asList(pages));
|
||||
|
||||
for(CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS){
|
||||
BookletPageAA page = new PageCoffeeRecipe(allPages.size()+1, ingredient);
|
||||
if(!(ingredient instanceof ItemCoffee.MilkIngredient)){
|
||||
page.setNoText();
|
||||
}
|
||||
allPages.add(page);
|
||||
}
|
||||
|
||||
return allPages.toArray(new BookletPage[allPages.size()]);
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* 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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.chapter;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BookletChapterCrusher extends BookletChapter{
|
||||
|
||||
public BookletChapterCrusher(String unlocalizedName, IBookletEntry entry, ItemStack displayStack, BookletPage... pages){
|
||||
super(unlocalizedName, entry, displayStack, getPages(pages));
|
||||
}
|
||||
|
||||
private static BookletPage[] getPages(BookletPage... pages){
|
||||
ArrayList<BookletPage> allPages = new ArrayList<BookletPage>();
|
||||
allPages.addAll(Arrays.asList(pages));
|
||||
|
||||
for(CrusherRecipe recipe : CrusherCrafting.MISC_RECIPES){
|
||||
allPages.add(new PageCrusherRecipe(allPages.size()+1, recipe).setNoText());
|
||||
}
|
||||
|
||||
return allPages.toArray(new BookletPage[allPages.size()]);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.booklet.entry;
|
|||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.IEntryGui;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
@ -34,7 +35,7 @@ public class BookletEntry implements IBookletEntry{
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<IBookletChapter> getChapters(){
|
||||
public List<IBookletChapter> getAllChapters(){
|
||||
return this.chapters;
|
||||
}
|
||||
|
||||
|
@ -64,6 +65,11 @@ public class BookletEntry implements IBookletEntry{
|
|||
this.chapters.add(chapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntryGui createGui(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public BookletEntry setImportant(){
|
||||
this.color = TextFormatting.DARK_GREEN;
|
||||
return this;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* This file ("BookletEntryAllSearch.java") is part of the Actually Additions mod for Minecraft.
|
||||
* This file ("BookletEntryAllItems.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://ellpeck.de/actaddlicense
|
||||
|
@ -10,10 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.entry;
|
||||
|
||||
public class BookletEntryAllSearch extends BookletEntry{
|
||||
public class BookletEntryAllItems extends BookletEntry{
|
||||
|
||||
public BookletEntryAllSearch(String unlocalizedName){
|
||||
super(unlocalizedName);
|
||||
public BookletEntryAllItems(String identifier){
|
||||
super(identifier);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
* This file ("EntrySet.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.entry;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IEntrySet;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class EntrySet implements IEntrySet{
|
||||
|
||||
private BookletPage page;
|
||||
private IBookletChapter chapter;
|
||||
private IBookletEntry entry;
|
||||
private int pageInIndex;
|
||||
|
||||
public EntrySet(IBookletEntry entry){
|
||||
this(null, null, entry, 1);
|
||||
}
|
||||
|
||||
public EntrySet(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex){
|
||||
this.setEntry(page, chapter, entry, pageInIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
if(compound != null){
|
||||
String entryName = compound.getString("Entry");
|
||||
if(!entryName.isEmpty()){
|
||||
for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){
|
||||
if(entryName.equals(entry.getIdentifier())){
|
||||
int indexPage = compound.getInteger("PageInIndex");
|
||||
|
||||
String chapterName = compound.getString("Chapter");
|
||||
if(!chapterName.isEmpty()){
|
||||
for(IBookletChapter chapter : entry.getChapters()){
|
||||
if(chapterName.equals(chapter.getIdentifier())){
|
||||
int page = compound.getInteger("Page");
|
||||
if(page != -1){
|
||||
this.page = chapter.getPageById(page);
|
||||
this.chapter = chapter;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.entry = entry;
|
||||
this.pageInIndex = indexPage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntry(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex){
|
||||
this.page = page;
|
||||
this.chapter = chapter;
|
||||
this.entry = entry;
|
||||
this.pageInIndex = pageInIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntry(){
|
||||
this.setEntry(null, null, null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound){
|
||||
compound.setInteger("PageInIndex", this.pageInIndex);
|
||||
compound.setString("Entry", this.entry != null ? this.entry.getIdentifier() : "");
|
||||
compound.setString("Chapter", this.chapter != null ? this.chapter.getIdentifier() : "");
|
||||
compound.setInteger("Page", this.page != null ? this.page.getChapter().getPageId(this.page) : -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookletPage getCurrentPage(){
|
||||
return this.page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletEntry getCurrentEntry(){
|
||||
return this.entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletChapter getCurrentChapter(){
|
||||
return this.chapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageInIndex(){
|
||||
return this.pageInIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPage(BookletPage page){
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntry(IBookletEntry entry){
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChapter(IBookletChapter chapter){
|
||||
this.chapter = chapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPageInIndex(int page){
|
||||
this.pageInIndex = page;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* This file ("GuiBooklet.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBooklet extends GuiScreen implements IBookletGui{
|
||||
|
||||
public static final int BUTTONS_PER_PAGE = 12;
|
||||
public static final ResourceLocation RES_LOC_GUI = AssetUtil.getBookletGuiLocation("guiBooklet");
|
||||
public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("guiBookletGadgets");
|
||||
|
||||
protected GuiScreen parent;
|
||||
|
||||
protected int xSize;
|
||||
protected int ySize;
|
||||
protected int guiLeft;
|
||||
protected int guiTop;
|
||||
|
||||
public GuiBooklet(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
|
||||
this.xSize = 281;
|
||||
this.ySize = 180;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
this.guiLeft = (this.width-this.xSize)/2;
|
||||
this.guiTop = (this.height-this.ySize)/2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks){
|
||||
this.mc.getTextureManager().bindTexture(RES_LOC_GUI);
|
||||
drawModalRectWithCustomSizedTexture(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize, 512, 512);
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException{
|
||||
if(this.parent != null && keyCode == Keyboard.KEY_ESCAPE){
|
||||
this.mc.displayGuiScreen(this.parent);
|
||||
}
|
||||
else{
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale){
|
||||
StringUtil.renderScaledAsciiString(this.fontRendererObj, text, x, y, color, shadow, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length){
|
||||
StringUtil.renderSplitScaledAsciiString(this.fontRendererObj, text, x, y, color, shadow, scale, length);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* This file ("GuiEntry.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.IEntryGui;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiEntry extends GuiBooklet implements IEntryGui{
|
||||
|
||||
//The page in the entry. Say you have 2 more chapters than fit on one double page, then those 2 would be displayed on entryPage 1 instead.
|
||||
private final int entryPage;
|
||||
private final IBookletEntry entry;
|
||||
|
||||
public GuiEntry(GuiScreen parent, IBookletEntry entry, int entryPage){
|
||||
super(parent);
|
||||
this.entry = entry;
|
||||
this.entryPage = entryPage;
|
||||
}
|
||||
|
||||
public GuiEntry(GuiScreen parent, IBookletEntry entry, IBookletChapter chapterForPageCalc){
|
||||
this(parent, entry, calcEntryPage(entry, chapterForPageCalc));
|
||||
}
|
||||
|
||||
private static int calcEntryPage(IBookletEntry entry, IBookletChapter chapterForPageCalc){
|
||||
int index = entry.getAllChapters().indexOf(chapterForPageCalc);
|
||||
return index/(BUTTONS_PER_PAGE*2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletEntry getEntry(){
|
||||
return this.entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntryPage(){
|
||||
return this.entryPage;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* This file ("GuiMainPage.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.EntryButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiMainPage extends GuiBooklet{
|
||||
|
||||
public GuiMainPage(GuiScreen parent){
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
for(int x = 0; x < 2; x++){
|
||||
for(int y = 0; y < BUTTONS_PER_PAGE; y++){
|
||||
int id = y+x*BUTTONS_PER_PAGE;
|
||||
if(ActuallyAdditionsAPI.BOOKLET_ENTRIES.size() > id){
|
||||
IBookletEntry entry = ActuallyAdditionsAPI.BOOKLET_ENTRIES.get(id);
|
||||
this.buttonList.add(new EntryButton(id, this.guiLeft+12, this.guiTop+12+y*16, 115, 10, entry.getLocalizedNameWithFormatting(), null));
|
||||
}
|
||||
else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* This file ("GuiPage.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.IPageGui;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiPage extends GuiBooklet implements IPageGui{
|
||||
|
||||
private final IBookletPage page;
|
||||
|
||||
public GuiPage(GuiScreen parent, IBookletPage page){
|
||||
super(parent);
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletPage getPage(){
|
||||
return this.page;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* This file ("BookletUtils.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.misc;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public final class BookletUtils{
|
||||
|
||||
public static IBookletPage findFirstPageForStack(ItemStack stack){
|
||||
for(IBookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA){
|
||||
ItemStack[] stacks = page.getItemStacksForPage();
|
||||
if(stacks != null && stacks.length > 0){
|
||||
for(ItemStack pageStack : stacks){
|
||||
if(ItemUtil.areItemsEqual(pageStack, stack, true)){
|
||||
return page;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet;
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.misc;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
|
@ -16,10 +16,13 @@ import net.minecraft.client.gui.GuiScreen;
|
|||
import net.minecraft.client.gui.achievement.GuiAchievements;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* (Partially excerpted from Botania by Vazkii with permission, thanks!)
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAAAchievements extends GuiAchievements{
|
||||
|
||||
public GuiAAAchievements(GuiScreen screen, StatisticsManager statistics){
|
|
@ -10,34 +10,63 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.IPageGui;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BookletPageAA extends BookletPage{
|
||||
public class BookletPage implements IBookletPage{
|
||||
|
||||
protected IBookletChapter chapter;
|
||||
|
||||
protected final int localizationKey;
|
||||
protected List<FluidStack> fluidsForPage = new ArrayList<FluidStack>();
|
||||
protected List<ItemStack> itemsForPage = new ArrayList<ItemStack>();
|
||||
|
||||
public BookletPageAA(int localizationKey){
|
||||
protected boolean hasNoText;
|
||||
protected final HashMap<String, String> textReplacements = new HashMap<String, String>();
|
||||
protected final int localizationKey;
|
||||
|
||||
public BookletPage(int localizationKey){
|
||||
this.localizationKey = localizationKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID(){
|
||||
return this.chapter.getPageId(this);
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
return this.itemsForPage.toArray(new ItemStack[this.itemsForPage.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(){
|
||||
public FluidStack[] getFluidStacksForPage(){
|
||||
return this.fluidsForPage.toArray(new FluidStack[this.fluidsForPage.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletChapter getChapter(){
|
||||
return this.chapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChapter(IBookletChapter chapter){
|
||||
this.chapter = chapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPageGui createGui(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoText(){
|
||||
if(this.hasNoText){
|
||||
return null;
|
||||
}
|
||||
|
@ -56,33 +85,13 @@ public class BookletPageAA extends BookletPage{
|
|||
return base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(int ticksElapsed){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack[] getFluidStacksForPage(){
|
||||
return this.fluidsForPage.toArray(new FluidStack[this.fluidsForPage.size()]);
|
||||
}
|
||||
|
||||
public BookletPageAA addFluidToPage(Fluid fluid){
|
||||
public BookletPage addFluidToPage(Fluid fluid){
|
||||
this.fluidsForPage.add(new FluidStack(fluid, 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickToSeeRecipeString(){
|
||||
return TextFormatting.GOLD+StringUtil.localize("booklet."+ModUtil.MOD_ID+".clickToSeeRecipe");
|
||||
public BookletPage addItemToPage(ItemStack stack){
|
||||
this.itemsForPage.add(stack);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* This file ("PageButton.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
public abstract class PageButton extends PageTextOnly{
|
||||
|
||||
private GuiButton button;
|
||||
|
||||
public PageButton(int id){
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpened(IBookletGui gui){
|
||||
String text = StringUtil.localize("booklet."+ModUtil.MOD_ID+".chapter."+this.chapter.getIdentifier()+".page."+this.localizationKey+".button");
|
||||
int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text);
|
||||
this.button = new GuiButton(-1239, gui.getGuiLeft()+gui.getXSize()/2-width/2-8, gui.getGuiTop()+gui.getYSize()-40, width+15, 20, text);
|
||||
gui.getButtonList().add(this.button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(IBookletGui gui){
|
||||
gui.getButtonList().remove(this.button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionPerformed(IBookletGui gui, GuiButton button){
|
||||
return button == this.button && this.onAction();
|
||||
}
|
||||
|
||||
public abstract boolean onAction();
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* This file ("PageCoffeeRecipe.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PageCoffeeRecipe extends BookletPageAA{
|
||||
|
||||
public final CoffeeIngredient ingredient;
|
||||
|
||||
public PageCoffeeRecipe(int id, CoffeeIngredient ingredient){
|
||||
super(id);
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GuiBooklet.RES_LOC);
|
||||
gui.drawRect(gui.getGuiLeft()+19, gui.getGuiTop()+20, 146, 94, 99, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
String strg = "Coffee Machine Recipe";
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0);
|
||||
|
||||
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false);
|
||||
}
|
||||
|
||||
if(this.ingredient.maxAmplifier > 0){
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString("Maximum Amplifier: "+this.ingredient.maxAmplifier, gui.getGuiLeft()+19+5, gui.getGuiTop()+20+60, 0);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 2; i++){
|
||||
for(int j = 0; j < 4; j++){
|
||||
ItemStack stack;
|
||||
int coordsOffsetX;
|
||||
int coordsOffsetY;
|
||||
|
||||
switch(j){
|
||||
case 0:
|
||||
stack = new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal());
|
||||
coordsOffsetX = 39;
|
||||
coordsOffsetY = 8;
|
||||
break;
|
||||
case 1:
|
||||
stack = new ItemStack(InitItems.itemCoffeeBean);
|
||||
coordsOffsetX = 5;
|
||||
coordsOffsetY = 8;
|
||||
break;
|
||||
case 2:
|
||||
stack = new ItemStack(InitItems.itemCoffee);
|
||||
ActuallyAdditionsAPI.methodHandler.addEffectToStack(stack, this.ingredient);
|
||||
coordsOffsetX = 39;
|
||||
coordsOffsetY = 39;
|
||||
break;
|
||||
default:
|
||||
stack = this.ingredient.ingredient;
|
||||
coordsOffsetX = 82;
|
||||
coordsOffsetY = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
if(stack != null){
|
||||
if(stack.getItemDamage() == Util.WILDCARD){
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
|
||||
boolean tooltip = i == 1;
|
||||
|
||||
int xShow = gui.getGuiLeft()+19+coordsOffsetX;
|
||||
int yShow = gui.getGuiTop()+20+coordsOffsetY;
|
||||
if(!tooltip){
|
||||
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
|
||||
}
|
||||
else{
|
||||
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
||||
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, j != 2, mousePressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,201 +0,0 @@
|
|||
/*
|
||||
* 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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PageCrafting extends BookletPageAA{
|
||||
|
||||
private final IRecipe[] recipes;
|
||||
private int recipePos;
|
||||
|
||||
public PageCrafting(int id, ArrayList<IRecipe> recipes){
|
||||
this(id, recipes.toArray(new IRecipe[recipes.size()]));
|
||||
}
|
||||
|
||||
public PageCrafting(int id, IRecipe... recipes){
|
||||
super(id);
|
||||
this.recipes = recipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(this.recipes != null && this.recipes.length > 0 && this.recipes[this.recipePos] != null){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GuiBooklet.RES_LOC);
|
||||
gui.drawRect(gui.getGuiLeft()+27, gui.getGuiTop()+20, 146, 20, 99, 60);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
IRecipe recipe = this.recipes != null && this.recipes.length > 0 ? this.recipes[this.recipePos] : null;
|
||||
|
||||
if(recipe == null){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, TextFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID+".recipeDisabled"), gui.getGuiLeft()+14, gui.getGuiTop()+15, 115, 0, false);
|
||||
}
|
||||
else{
|
||||
String strg = StringUtil.localize("booklet."+ModUtil.MOD_ID+"."+(recipe instanceof ShapedRecipes ? "shapedRecipe" : (recipe instanceof ShapelessRecipes ? "shapelessRecipe" : (recipe instanceof ShapelessOreRecipe ? "shapelessOreRecipe" : "shapedOreRecipe"))));
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0);
|
||||
}
|
||||
|
||||
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+90, 115, 0, false);
|
||||
}
|
||||
|
||||
if(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;
|
||||
for(int i = 0; i < shaped.recipeItems.length; i++){
|
||||
ItemStack stack = shaped.recipeItems[i];
|
||||
if(stack != null){
|
||||
stacks[i] = stack.copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(recipe instanceof ShapelessRecipes){
|
||||
ShapelessRecipes shapeless = (ShapelessRecipes)recipe;
|
||||
for(int i = 0; i < shapeless.recipeItems.size(); i++){
|
||||
ItemStack stack = shapeless.recipeItems.get(i);
|
||||
if(stack != null){
|
||||
stacks[i] = stack.copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(recipe instanceof ShapedOreRecipe){
|
||||
ShapedOreRecipe shaped = (ShapedOreRecipe)recipe;
|
||||
try{
|
||||
width = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4);
|
||||
height = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5);
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.error("Something went wrong trying to get the Crafting Recipe in the booklet to display!", e);
|
||||
}
|
||||
for(int i = 0; i < shaped.getInput().length; i++){
|
||||
Object input = shaped.getInput()[i];
|
||||
if(input != null){
|
||||
ItemStack stack = input instanceof ItemStack ? (ItemStack)input : (((List<ItemStack>)input).isEmpty() ? null : ((List<ItemStack>)input).get(0));
|
||||
if(stack != null){
|
||||
stacks[i] = stack.copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(recipe instanceof ShapelessOreRecipe){
|
||||
ShapelessOreRecipe shapeless = (ShapelessOreRecipe)recipe;
|
||||
for(int i = 0; i < shapeless.getInput().size(); i++){
|
||||
Object input = shapeless.getInput().get(i);
|
||||
ItemStack stack = input instanceof ItemStack ? (ItemStack)input : (((List<ItemStack>)input).isEmpty() ? null : ((List<ItemStack>)input).get(0));
|
||||
if(stack != null){
|
||||
stacks[i] = stack.copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int xShowOutput = gui.getGuiLeft()+27+82;
|
||||
int yShowOutput = gui.getGuiTop()+20+22;
|
||||
AssetUtil.renderStackToGui(recipe.getRecipeOutput(), xShowOutput, yShowOutput, 1.0F);
|
||||
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){
|
||||
stack.stackSize = 1;
|
||||
if(stack.getItemDamage() == Util.WILDCARD){
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
int xShow = gui.getGuiLeft()+27+4+x*18;
|
||||
int yShow = gui.getGuiTop()+20+4+y*18;
|
||||
if(!tooltip){
|
||||
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
|
||||
}
|
||||
else{
|
||||
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
||||
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, true, mousePressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mouseX >= xShowOutput && mouseX <= xShowOutput+16 && mouseY >= yShowOutput && mouseY <= yShowOutput+16){
|
||||
gui.renderTooltipAndTransferButton(this, recipe.getRecipeOutput(), mouseX, mouseY, false, mousePressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateScreen(int ticksElapsed){
|
||||
if(ticksElapsed%15 == 0){
|
||||
if(this.recipePos+1 >= this.recipes.length){
|
||||
this.recipePos = 0;
|
||||
}
|
||||
else{
|
||||
this.recipePos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
if(this.recipes != null && this.recipes.length > 0){
|
||||
ItemStack[] stacks = new ItemStack[this.recipes.length];
|
||||
for(int i = 0; i < this.recipes.length; i++){
|
||||
if(this.recipes[i] != null){
|
||||
ItemStack output = this.recipes[i].getRecipeOutput();
|
||||
if(output != null){
|
||||
if(!this.arePageStacksWildcard){
|
||||
stacks[i] = output;
|
||||
}
|
||||
else{
|
||||
ItemStack wildcardOutput = output.copy();
|
||||
wildcardOutput.setItemDamage(Util.WILDCARD);
|
||||
stacks[i] = wildcardOutput;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* This file ("PageCrusherRecipe.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
public class PageCrusherRecipe extends BookletPageAA{
|
||||
|
||||
public final CrusherRecipe recipe;
|
||||
|
||||
public PageCrusherRecipe(int id, CrusherRecipe recipe){
|
||||
super(id);
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(this.recipe != null){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GuiBooklet.RES_LOC);
|
||||
gui.drawRect(gui.getGuiLeft()+37, gui.getGuiTop()+20, 60, 180, 60, 60);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(this.recipe == null){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, TextFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID+".recipeDisabled"), gui.getGuiLeft()+14, gui.getGuiTop()+15, 115, 0, false);
|
||||
}
|
||||
else{
|
||||
String strg = "Crusher Recipe";
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0);
|
||||
}
|
||||
|
||||
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false);
|
||||
}
|
||||
|
||||
if(this.recipe != null){
|
||||
if(this.recipe.outputTwoChance > 0){
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(this.recipe.outputTwoChance+"%", gui.getGuiLeft()+37+62, gui.getGuiTop()+20+33, 0);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 2; i++){
|
||||
for(int j = 0; j < 3; j++){
|
||||
ItemStack stack;
|
||||
switch(j){
|
||||
case 0:
|
||||
stack = this.recipe.inputStack;
|
||||
break;
|
||||
case 1:
|
||||
stack = this.recipe.outputOneStack;
|
||||
break;
|
||||
default:
|
||||
stack = this.recipe.outputTwoStack;
|
||||
break;
|
||||
}
|
||||
|
||||
if(stack != null){
|
||||
if(stack.getItemDamage() == Util.WILDCARD){
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
|
||||
boolean tooltip = i == 1;
|
||||
|
||||
int xShow = gui.getGuiLeft()+37+(j == 0 ? 1 : (j == 1 ? 43 : (j == 2 ? 43 : 0)));
|
||||
int yShow = gui.getGuiTop()+20+(j == 0 ? 21 : (j == 1 ? 11 : (j == 2 ? 29 : 0)));
|
||||
if(!tooltip){
|
||||
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
|
||||
}
|
||||
else{
|
||||
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
||||
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, j == 0, mousePressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
return this.recipe == null ? new ItemStack[0] : new ItemStack[]{this.recipe.outputOneStack, this.recipe.outputTwoStack};
|
||||
}
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
/*
|
||||
* This file ("PageEmpowerer.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PageEmpowerer extends BookletPageAA{
|
||||
|
||||
private final EmpowererRecipe[] recipes;
|
||||
private int recipePos;
|
||||
|
||||
public PageEmpowerer(int id, ArrayList<EmpowererRecipe> recipes){
|
||||
this(id, recipes.toArray(new EmpowererRecipe[recipes.size()]));
|
||||
}
|
||||
|
||||
public PageEmpowerer(int id, EmpowererRecipe... recipes){
|
||||
super(id);
|
||||
this.recipes = recipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(this.recipes[this.recipePos] != null){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GuiBooklet.RES_LOC_ADDON);
|
||||
gui.drawRect(gui.getGuiLeft()+22, gui.getGuiTop()+20, 0, 0, 94, 58);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
EmpowererRecipe recipe = this.recipes[this.recipePos];
|
||||
if(recipe == null){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, TextFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID+".recipeDisabled"), gui.getGuiLeft()+14, gui.getGuiTop()+15, 115, 0, false);
|
||||
}
|
||||
else{
|
||||
String strg = "Empowerer";
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0);
|
||||
}
|
||||
|
||||
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false);
|
||||
}
|
||||
|
||||
if(recipe != null){
|
||||
for(int i = 0; i < 2; i++){
|
||||
for(int count = 0; count < 6; count++){
|
||||
ItemStack stack;
|
||||
int x;
|
||||
int y;
|
||||
switch(count){
|
||||
case 0:
|
||||
stack = recipe.input;
|
||||
x = 21;
|
||||
y = 21;
|
||||
break;
|
||||
case 1:
|
||||
stack = recipe.modifier1;
|
||||
x = 21;
|
||||
y = 1;
|
||||
break;
|
||||
case 2:
|
||||
stack = recipe.modifier2;
|
||||
x = 41;
|
||||
y = 21;
|
||||
break;
|
||||
case 3:
|
||||
stack = recipe.modifier3;
|
||||
x = 21;
|
||||
y = 41;
|
||||
break;
|
||||
case 4:
|
||||
stack = recipe.modifier4;
|
||||
x = 1;
|
||||
y = 21;
|
||||
break;
|
||||
default:
|
||||
stack = recipe.output;
|
||||
x = 77;
|
||||
y = 21;
|
||||
break;
|
||||
}
|
||||
|
||||
if(stack.getItemDamage() == Util.WILDCARD){
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
|
||||
int xShow = gui.getGuiLeft()+22+x;
|
||||
int yShow = gui.getGuiTop()+20+y;
|
||||
if(i != 1){
|
||||
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
|
||||
}
|
||||
else{
|
||||
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
||||
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, x != 5, mousePressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateScreen(int ticksElapsed){
|
||||
if(ticksElapsed%15 == 0){
|
||||
if(this.recipePos+1 >= this.recipes.length){
|
||||
this.recipePos = 0;
|
||||
}
|
||||
else{
|
||||
this.recipePos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
if(this.recipes != null){
|
||||
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
for(EmpowererRecipe recipe : this.recipes){
|
||||
if(recipe != null){
|
||||
stacks.add(recipe.output);
|
||||
}
|
||||
}
|
||||
return stacks.toArray(new ItemStack[stacks.size()]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* 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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PageFurnace extends BookletPageAA{
|
||||
|
||||
private final ItemStack result;
|
||||
private final ItemStack input;
|
||||
|
||||
public PageFurnace(int id, ItemStack result){
|
||||
this(id, null, result);
|
||||
}
|
||||
|
||||
public PageFurnace(int id, ItemStack input, ItemStack result){
|
||||
super(id);
|
||||
this.result = result;
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(this.input != null || this.getInputForOutput(this.result) != null){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GuiBooklet.RES_LOC);
|
||||
gui.drawRect(gui.getGuiLeft()+37, gui.getGuiTop()+20, 0, 180, 60, 60);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
ItemStack input = this.input != null ? this.input : this.getInputForOutput(this.result);
|
||||
if(input == null){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, TextFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID+".recipeDisabled"), gui.getGuiLeft()+14, gui.getGuiTop()+15, 115, 0, false);
|
||||
}
|
||||
else{
|
||||
String strg = "Furnace Recipe";
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0);
|
||||
}
|
||||
|
||||
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false);
|
||||
}
|
||||
|
||||
if(input != null){
|
||||
for(int i = 0; i < 2; i++){
|
||||
for(int x = 0; x < 2; x++){
|
||||
ItemStack stack = x == 0 ? input : this.result;
|
||||
if(stack.getItemDamage() == Util.WILDCARD){
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
boolean tooltip = i == 1;
|
||||
|
||||
int xShow = gui.getGuiLeft()+37+1+x*42;
|
||||
int yShow = gui.getGuiTop()+20+21;
|
||||
if(!tooltip){
|
||||
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
|
||||
}
|
||||
else{
|
||||
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
||||
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, x == 0, mousePressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
return this.result == null ? new ItemStack[0] : new ItemStack[]{this.result};
|
||||
}
|
||||
|
||||
private ItemStack getInputForOutput(ItemStack output){
|
||||
for(Map.Entry o : FurnaceRecipes.instance().getSmeltingList().entrySet()){
|
||||
ItemStack stack = (ItemStack)(o).getValue();
|
||||
if(stack.isItemEqual(output)){
|
||||
return (ItemStack)(o).getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* This file ("PageLinkButton.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
|
||||
public class PageLinkButton extends PageButton{
|
||||
|
||||
private final String link;
|
||||
|
||||
public PageLinkButton(int id, String link){
|
||||
super(id);
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onAction(){
|
||||
BookletUtils.openBrowser(this.link);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This file ("PagePicture.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PagePicture extends PageTextOnly{
|
||||
|
||||
private final ResourceLocation resLoc;
|
||||
private final int textStartY;
|
||||
|
||||
public PagePicture(int id, String resLocName, int textStartY){
|
||||
this(id, AssetUtil.getBookletGuiLocation(resLocName), textStartY);
|
||||
}
|
||||
|
||||
public PagePicture(int id, ResourceLocation resLoc, int textStartY){
|
||||
super(id);
|
||||
this.textStartY = textStartY;
|
||||
this.resLoc = resLoc;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
GlStateManager.enableBlend();
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(this.resLoc);
|
||||
gui.drawRect(gui.getGuiLeft(), gui.getGuiTop(), 0, 0, gui.getXSize(), gui.getYSize());
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+this.textStartY, 115, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
* This file ("PageReconstructor.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PageReconstructor extends BookletPageAA{
|
||||
|
||||
private final LensConversionRecipe[] recipes;
|
||||
private int recipePos;
|
||||
|
||||
public PageReconstructor(int id, ArrayList<LensConversionRecipe> recipes){
|
||||
this(id, recipes.toArray(new LensConversionRecipe[recipes.size()]));
|
||||
}
|
||||
|
||||
public PageReconstructor(int id, LensConversionRecipe... recipes){
|
||||
super(id);
|
||||
this.recipes = recipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(this.recipes[this.recipePos] != null){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GuiBooklet.RES_LOC);
|
||||
gui.drawRect(gui.getGuiLeft()+37, gui.getGuiTop()+20, 188, 154, 60, 60);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
LensConversionRecipe recipe = this.recipes[this.recipePos];
|
||||
if(recipe == null){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, TextFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID+".recipeDisabled"), gui.getGuiLeft()+14, gui.getGuiTop()+15, 115, 0, false);
|
||||
}
|
||||
else{
|
||||
String strg = "Atomic Reconstructor";
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0);
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(recipe.energyUse+" RF", gui.getGuiLeft()+80, gui.getGuiTop()+30, 0, false);
|
||||
}
|
||||
|
||||
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false);
|
||||
}
|
||||
|
||||
if(recipe != null){
|
||||
AssetUtil.renderStackToGui(new ItemStack(InitBlocks.blockAtomicReconstructor), gui.getGuiLeft()+37+22, gui.getGuiTop()+20+21, 1.0F);
|
||||
for(int i = 0; i < 2; i++){
|
||||
for(int x = 0; x < 2; x++){
|
||||
ItemStack stack = x == 0 ? recipe.inputStack : recipe.outputStack;
|
||||
|
||||
if(stack.getItemDamage() == Util.WILDCARD){
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
boolean tooltip = i == 1;
|
||||
|
||||
int xShow = gui.getGuiLeft()+37+1+x*42;
|
||||
int yShow = gui.getGuiTop()+20+21;
|
||||
if(!tooltip){
|
||||
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
|
||||
}
|
||||
else{
|
||||
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
||||
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, x == 0, mousePressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateScreen(int ticksElapsed){
|
||||
if(ticksElapsed%15 == 0){
|
||||
if(this.recipePos+1 >= this.recipes.length){
|
||||
this.recipePos = 0;
|
||||
}
|
||||
else{
|
||||
this.recipePos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
if(this.recipes != null){
|
||||
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
for(LensConversionRecipe recipe : this.recipes){
|
||||
if(recipe != null){
|
||||
stacks.add(recipe.outputStack);
|
||||
}
|
||||
}
|
||||
return stacks.toArray(new ItemStack[stacks.size()]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* This file ("PageTextOnly.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PageTextOnly extends BookletPageAA{
|
||||
|
||||
private ItemStack[] stacks;
|
||||
|
||||
public PageTextOnly(int id){
|
||||
super(id);
|
||||
}
|
||||
|
||||
public PageTextOnly setStacks(ItemStack... stacks){
|
||||
this.stacks = stacks;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+9, 115, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
return this.stacks == null ? new ItemStack[0] : this.stacks;
|
||||
}
|
||||
}
|
|
@ -147,7 +147,6 @@ public class CreativeTab extends CreativeTabs{
|
|||
this.add(InitBlocks.blockTreasureChest);
|
||||
|
||||
this.add(InitBlocks.blockBlackLotus);
|
||||
this.add(InitBlocks.blockBookletStand);
|
||||
|
||||
this.add(InitItems.itemBag);
|
||||
this.add(InitItems.itemVoidBag);
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBookletStand;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.*;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
|
@ -169,15 +169,13 @@ public class GuiHandler implements IGuiHandler{
|
|||
case CLOUD:
|
||||
return new GuiSmileyCloud(tile, x, y, z, world);
|
||||
case BOOK:
|
||||
return new GuiBooklet(null, true, true);
|
||||
return new GuiMainPage(null);
|
||||
case DIRECTIONAL_BREAKER:
|
||||
return new GuiDirectionalBreaker(player.inventory, tile);
|
||||
case RANGED_COLLECTOR:
|
||||
return new GuiRangedCollector(player.inventory, tile, x, y, z, world);
|
||||
case MINER:
|
||||
return new GuiMiner(player.inventory, tile);
|
||||
case BOOK_STAND:
|
||||
return new GuiBookletStand(tile);
|
||||
case LASER_RELAY_ITEM_WHITELIST:
|
||||
return new GuiLaserRelayItemWhitelist(player.inventory, tile);
|
||||
case BAG:
|
||||
|
@ -223,7 +221,6 @@ public class GuiHandler implements IGuiHandler{
|
|||
DIRECTIONAL_BREAKER,
|
||||
RANGED_COLLECTOR,
|
||||
MINER,
|
||||
BOOK_STAND,
|
||||
LASER_RELAY_ITEM_WHITELIST,
|
||||
FILTER(false),
|
||||
BAG(false),
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.button;
|
||||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -23,18 +23,20 @@ import java.util.List;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class TexturedButton extends GuiButton{
|
||||
|
||||
private final ResourceLocation resLoc;
|
||||
public final List textList = new ArrayList();
|
||||
public int texturePosX;
|
||||
public int texturePosY;
|
||||
|
||||
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height){
|
||||
this(id, x, y, texturePosX, texturePosY, width, height, new ArrayList());
|
||||
public TexturedButton(ResourceLocation resLoc, int id, int x, int y, int texturePosX, int texturePosY, int width, int height){
|
||||
this(resLoc, id, x, y, texturePosX, texturePosY, width, height, new ArrayList());
|
||||
}
|
||||
|
||||
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height, List hoverTextList){
|
||||
public TexturedButton(ResourceLocation resLoc, int id, int x, int y, int texturePosX, int texturePosY, int width, int height, List hoverTextList){
|
||||
super(id, x, y, width, height, "");
|
||||
this.texturePosX = texturePosX;
|
||||
this.texturePosY = texturePosY;
|
||||
this.resLoc = resLoc;
|
||||
this.textList.addAll(hoverTextList);
|
||||
}
|
||||
|
||||
|
@ -46,7 +48,7 @@ public class TexturedButton extends GuiButton{
|
|||
@Override
|
||||
public void drawButton(Minecraft minecraft, int x, int y){
|
||||
if(this.visible){
|
||||
minecraft.getTextureManager().bindTexture(GuiBooklet.RES_LOC);
|
||||
minecraft.getTextureManager().bindTexture(this.resLoc);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.hovered = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height;
|
||||
int k = this.getHoverState(this.hovered);
|
|
@ -10,14 +10,11 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
@ -38,15 +35,14 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBooklet extends ItemBase implements IHudDisplay{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static EntrySet forcedEntry;
|
||||
//TODO Fix this
|
||||
//@SideOnly(Side.CLIENT)
|
||||
//public static EntrySet forcedEntry;
|
||||
|
||||
public ItemBooklet(String name){
|
||||
super(name);
|
||||
|
@ -61,10 +57,10 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
|
|||
IBlockState state = world.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));
|
||||
BookletPage page = BookletUtils.getFirstPageForStack(blockStack);
|
||||
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
|
||||
if(page != null){
|
||||
if(world.isRemote){
|
||||
forcedEntry = new EntrySet(page, page.getChapter(), page.getChapter().getEntry(), ActuallyAdditionsAPI.BOOKLET_ENTRIES.indexOf(page.getChapter().getEntry())/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1);
|
||||
//forcedEntry = new EntrySet(page, page.getChapter(), page.getChapter().getEntry(), ActuallyAdditionsAPI.BOOKLET_ENTRIES.indexOf(page.getChapter().getEntry())/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1);
|
||||
}
|
||||
this.onItemRightClick(stack, world, player, hand);
|
||||
return EnumActionResult.SUCCESS;
|
||||
|
@ -110,10 +106,10 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
|
|||
ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));
|
||||
int height = resolution.getScaledHeight()/5*3;
|
||||
if(player.isSneaking()){
|
||||
BookletPage page = BookletUtils.getFirstPageForStack(blockStack);
|
||||
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
|
||||
if(page != null){
|
||||
String strg1 = page.getChapter().getLocalizedName();
|
||||
String strg2 = "Page "+page.getID();
|
||||
String strg2 = "Page "+page.getChapter().getPageNum(page);
|
||||
String strg3 = "Right-Click to open...";
|
||||
|
||||
AssetUtil.renderStackToGui(page.getChapter().getDisplayItemStack() != null ? page.getChapter().getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2-10, height+41, 1F);
|
||||
|
|
|
@ -10,11 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.jei;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.TexturedButton;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
|
@ -29,7 +27,7 @@ public abstract class RecipeWrapperWithButton extends BlankRecipeWrapper{
|
|||
protected final TexturedButton theButton;
|
||||
|
||||
public RecipeWrapperWithButton(){
|
||||
this.theButton = new TexturedButton(23782, this.getButtonX(), this.getButtonY(), 146, 154, 20, 20);
|
||||
this.theButton = new TexturedButton(GuiBooklet.RES_LOC_GADGETS, 23782, this.getButtonX(), this.getButtonY(), 0, 0, 20, 20);
|
||||
}
|
||||
|
||||
public abstract int getButtonX();
|
||||
|
@ -41,19 +39,20 @@ public abstract class RecipeWrapperWithButton extends BlankRecipeWrapper{
|
|||
if(this.theButton.mousePressed(minecraft, mouseX, mouseY)){
|
||||
this.theButton.playPressSound(minecraft.getSoundHandler());
|
||||
|
||||
BookletPage page = this.getPage();
|
||||
IBookletPage page = this.getPage();
|
||||
if(page != null){
|
||||
GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen, false, true);
|
||||
//TODO Fix this
|
||||
/*GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen, false, true);
|
||||
Minecraft.getMinecraft().displayGuiScreen(book);
|
||||
BookletUtils.openIndexEntry(book, page.getChapter().getEntry(), ActuallyAdditionsAPI.BOOKLET_ENTRIES.indexOf(page.getChapter().getEntry())/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true);
|
||||
BookletUtils.openChapter(book, page.getChapter(), page);
|
||||
BookletUtils.openChapter(book, page.getChapter(), page);*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract BookletPage getPage();
|
||||
public abstract IBookletPage getPage();
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
|
||||
|
|
|
@ -10,20 +10,20 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
public class BookletRecipeHandler implements IRecipeHandler<BookletPage>{
|
||||
public class BookletRecipeHandler implements IRecipeHandler<IBookletPage>{
|
||||
|
||||
|
||||
@Override
|
||||
public Class getRecipeClass(){
|
||||
return BookletPage.class;
|
||||
return IBookletPage.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeCategoryUid(BookletPage recipe){
|
||||
public String getRecipeCategoryUid(IBookletPage recipe){
|
||||
return this.getRecipeCategoryUid();
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,12 @@ public class BookletRecipeHandler implements IRecipeHandler<BookletPage>{
|
|||
}
|
||||
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(BookletPage recipe){
|
||||
public IRecipeWrapper getRecipeWrapper(IBookletPage recipe){
|
||||
return new BookletRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(BookletPage recipe){
|
||||
public boolean isRecipeValid(IBookletPage recipe){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,8 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PagePicture;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
|
@ -27,9 +26,9 @@ import java.util.List;
|
|||
|
||||
public class BookletRecipeWrapper extends RecipeWrapperWithButton{
|
||||
|
||||
public final BookletPage thePage;
|
||||
public final IBookletPage thePage;
|
||||
|
||||
public BookletRecipeWrapper(BookletPage page){
|
||||
public BookletRecipeWrapper(IBookletPage page){
|
||||
this.thePage = page;
|
||||
}
|
||||
|
||||
|
@ -51,13 +50,13 @@ public class BookletRecipeWrapper extends RecipeWrapperWithButton{
|
|||
|
||||
int maxLines = 4;
|
||||
IBookletChapter chapter = this.thePage.getChapter();
|
||||
String aText = (chapter.getPages()[0] instanceof PagePicture && chapter.getPages().length > 1 ? chapter.getPages()[1] : chapter.getPages()[0]).getText();
|
||||
String aText = chapter.getAllPages()[0].getInfoText();
|
||||
List text = minecraft.fontRendererObj.listFormattedStringToWidth(aText != null ? aText : TextFormatting.DARK_RED+StringUtil.localize("container.nei."+ModUtil.MOD_ID+".booklet.noText"), 150);
|
||||
for(int i = 0; i < Math.min(maxLines, text.size()); i++){
|
||||
minecraft.fontRendererObj.drawString(text.get(i)+(i == maxLines-1 && text.size() > maxLines ? TextFormatting.RESET+""+TextFormatting.BLACK+"..." : ""), 0, 16+25+i*(minecraft.fontRendererObj.FONT_HEIGHT+1), 0, false);
|
||||
}
|
||||
minecraft.fontRendererObj.drawString(TextFormatting.ITALIC+chapter.getLocalizedName(), 25, 85, 0, false);
|
||||
minecraft.fontRendererObj.drawString(TextFormatting.ITALIC+"Page "+this.thePage.getID(), 25, 95, 0, false);
|
||||
minecraft.fontRendererObj.drawString(TextFormatting.ITALIC+"Page "+chapter.getPageNum(this.thePage), 25, 95, 0, false);
|
||||
|
||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
}
|
||||
|
@ -78,7 +77,7 @@ public class BookletRecipeWrapper extends RecipeWrapperWithButton{
|
|||
}
|
||||
|
||||
@Override
|
||||
public BookletPage getPage(){
|
||||
public IBookletPage getPage(){
|
||||
return this.thePage;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
package de.ellpeck.actuallyadditions.mod.jei.coffee;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
|
@ -82,7 +82,7 @@ public class CoffeeMachineRecipeWrapper extends RecipeWrapperWithButton{
|
|||
}
|
||||
|
||||
@Override
|
||||
public BookletPage getPage(){
|
||||
return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockCoffeeMachine));
|
||||
public IBookletPage getPage(){
|
||||
return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockCoffeeMachine));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,17 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
|
||||
|
@ -70,7 +68,7 @@ public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
|
|||
}
|
||||
|
||||
@Override
|
||||
public BookletPage getPage(){
|
||||
return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockGrinder));
|
||||
public IBookletPage getPage(){
|
||||
return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockGrinder));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,20 +10,15 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.empowerer;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class EmpowererRecipeWrapper extends RecipeWrapperWithButton{
|
||||
|
||||
|
@ -55,7 +50,7 @@ public class EmpowererRecipeWrapper extends RecipeWrapperWithButton{
|
|||
}
|
||||
|
||||
@Override
|
||||
public BookletPage getPage(){
|
||||
return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockEmpowerer));
|
||||
public IBookletPage getPage(){
|
||||
return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockEmpowerer));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,14 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.reconstructor;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton{
|
||||
|
||||
|
@ -60,7 +55,7 @@ public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton{
|
|||
}
|
||||
|
||||
@Override
|
||||
public BookletPage getPage(){
|
||||
return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockAtomicReconstructor));
|
||||
public IBookletPage getPage(){
|
||||
return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockAtomicReconstructor));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,18 +11,10 @@
|
|||
package de.ellpeck.actuallyadditions.mod.misc;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapter;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrafting;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PageFurnace;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PagePicture;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PageTextOnly;
|
||||
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -212,31 +204,6 @@ public class MethodHandler implements IMethodHandler{
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookletPage generateTextPage(int id){
|
||||
return new PageTextOnly(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY){
|
||||
return new PagePicture(id, resLoc, textStartY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookletPage generateCraftingPage(int id, IRecipe... recipes){
|
||||
return new PageCrafting(id, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookletPage generateFurnacePage(int id, ItemStack input, ItemStack result){
|
||||
return new PageFurnace(id, input, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, BookletPage... pages){
|
||||
return new BookletChapter(identifier, entry, displayStack, pages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance){
|
||||
boolean hasWorkedOnce = false;
|
||||
|
|
|
@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
|||
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -125,23 +124,6 @@ public final class PacketHandler{
|
|||
}
|
||||
};
|
||||
public static SimpleNetworkWrapper theNetwork;
|
||||
public static final IDataHandler BOOKLET_STAND_BUTTON_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
public void handleData(NBTTagCompound compound){
|
||||
World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
|
||||
EntityPlayer player = (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID"));
|
||||
|
||||
if(player != null && tile instanceof TileEntityBookletStand){
|
||||
TileEntityBookletStand stand = (TileEntityBookletStand)tile;
|
||||
if(player.getName() != null && player.getName().equalsIgnoreCase(stand.assignedPlayer)){
|
||||
stand.assignedEntry.readFromNBT(compound.getCompoundTag("EntrySet"));
|
||||
stand.markDirty();
|
||||
stand.sendUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
public static final IDataHandler CHANGE_PLAYER_DATA_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
public void handleData(NBTTagCompound compound){
|
||||
|
@ -166,7 +148,6 @@ public final class PacketHandler{
|
|||
|
||||
DATA_HANDLERS.add(PARTICLE_HANDLER);
|
||||
DATA_HANDLERS.add(TILE_ENTITY_HANDLER);
|
||||
DATA_HANDLERS.add(BOOKLET_STAND_BUTTON_HANDLER);
|
||||
DATA_HANDLERS.add(GUI_BUTTON_TO_TILE_HANDLER);
|
||||
DATA_HANDLERS.add(GUI_STRING_TO_TILE_HANDLER);
|
||||
DATA_HANDLERS.add(GUI_NUMBER_TO_TILE_HANDLER);
|
||||
|
|
|
@ -12,9 +12,9 @@ package de.ellpeck.actuallyadditions.mod.proxy;
|
|||
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.render.*;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
|
||||
|
@ -70,16 +70,17 @@ public class ClientProxy implements IProxy{
|
|||
bookletCharCount += entry.getLocalizedName().length();
|
||||
bookletText += entry.getLocalizedName()+"\n\n";
|
||||
|
||||
for(IBookletChapter chapter : entry.getChapters()){
|
||||
for(IBookletChapter chapter : entry.getAllChapters()){
|
||||
bookletWordCount += chapter.getLocalizedName().split(" ").length;
|
||||
bookletCharCount += chapter.getLocalizedName().length();
|
||||
bookletText += chapter.getLocalizedName()+"\n";
|
||||
|
||||
for(BookletPage page : chapter.getPages()){
|
||||
if(page.getText() != null){
|
||||
bookletWordCount += page.getText().split(" ").length;
|
||||
bookletCharCount += page.getText().length();
|
||||
bookletText += page.getText()+"\n";
|
||||
for(IBookletPage page : chapter.getAllPages()){
|
||||
String text = page.getInfoText();
|
||||
if(text != null){
|
||||
bookletWordCount += text.split(" ").length;
|
||||
bookletCharCount += text.length();
|
||||
bookletText += text+"\n";
|
||||
}
|
||||
}
|
||||
bookletText += "\n";
|
||||
|
|
|
@ -102,7 +102,6 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
register(TileEntityLaserRelayEnergyExtreme.class);
|
||||
register(TileEntityLaserRelayItemWhitelist.class);
|
||||
register(TileEntityItemViewer.class);
|
||||
register(TileEntityBookletStand.class);
|
||||
register(TileEntityDisplayStand.class);
|
||||
register(TileEntityShockSuppressor.class);
|
||||
register(TileEntityEmpowerer.class);
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* This file ("TileEntityBookletStand.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class TileEntityBookletStand extends TileEntityBase{
|
||||
|
||||
public EntrySet assignedEntry = new EntrySet(null);
|
||||
public String assignedPlayer;
|
||||
|
||||
public TileEntityBookletStand(){
|
||||
super("bookletStand");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||
super.writeSyncableNBT(compound, type);
|
||||
if(type != NBTType.SAVE_BLOCK){
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.assignedEntry.writeToNBT(tag);
|
||||
compound.setTag("SavedEntry", tag);
|
||||
|
||||
if(this.assignedPlayer != null){
|
||||
compound.setString("Player", this.assignedPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||
super.readSyncableNBT(compound, type);
|
||||
if(type != NBTType.SAVE_BLOCK){
|
||||
this.assignedEntry.readFromNBT(compound.getCompoundTag("SavedEntry"));
|
||||
this.assignedPlayer = compound.getString("Player");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.util;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -51,4 +52,26 @@ public final class StringUtil{
|
|||
public static String getFluidInfo(FluidTank tank){
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale){
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
boolean oldUnicode = font.getUnicodeFlag();
|
||||
font.setUnicodeFlag(false);
|
||||
|
||||
font.drawString(text, x/scale, y/scale, color, shadow);
|
||||
|
||||
font.setUnicodeFlag(oldUnicode);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderSplitScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale, int length){
|
||||
List<String> lines = font.listFormattedStringToWidth(text, (int)(length*scale));
|
||||
for(int i = 0; i < lines.size(); i++){
|
||||
renderScaledAsciiString(font, lines.get(i), x, y+(i*font.FONT_HEIGHT), color, shadow, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 25 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 34 KiB |
Loading…
Reference in a new issue