Changed some booklet mechanics in preparation for the changing of some more booklet mechanics in the future

This commit is contained in:
Ellpeck 2015-09-28 23:39:34 +02:00
parent 99878a1eef
commit 760108e446
11 changed files with 41 additions and 38 deletions

View file

@ -70,8 +70,8 @@ public class GuiBooklet extends GuiScreen{
private static final int BUTTON_FORUM_ID = BUTTON_TWITTER_ID+1;
private static final int BUTTON_ACHIEVEMENTS_ID = BUTTON_FORUM_ID+1;
private static final int BUTTON_CONFIG_ID = BUTTON_ACHIEVEMENTS_ID+1;
private int cursorCounter;
private int ticksElapsed;
private boolean mouseClicked;
private GuiScreen parentScreen;
@ -90,12 +90,13 @@ public class GuiBooklet extends GuiScreen{
boolean buttonThere = UpdateChecker.doneChecking && UpdateChecker.updateVersion > UpdateChecker.clientVersion;
this.getButton(BUTTON_UPDATE_ID).visible = buttonThere;
if(buttonThere){
this.cursorCounter++;
if(this.cursorCounter%8 == 0){
if(this.ticksElapsed%8 == 0){
TexturedButton button = (TexturedButton)this.getButton(BUTTON_UPDATE_ID);
button.setTexturePos(245, button.texturePosY == 0 ? 22 : 0);
}
}
this.ticksElapsed++;
}
@SuppressWarnings("unchecked")
@ -238,7 +239,7 @@ public class GuiBooklet extends GuiScreen{
if(this.currentIndexEntry != null){
if(this.currentChapter != null && this.currentPage != null){
this.drawCenteredString(this.unicodeRenderer, this.currentPage.getID()+"/"+this.currentChapter.pages.length, this.guiLeft+this.xSize/2, this.guiTop+172, StringUtil.DECIMAL_COLOR_WHITE);
this.currentPage.renderPre(this, x, y, this.mouseClicked);
this.currentPage.renderPre(this, x, y, this.mouseClicked, this.ticksElapsed);
}
else{
this.drawCenteredString(this.unicodeRenderer, this.pageOpenInIndex+"/"+this.indexPageAmount, this.guiLeft+this.xSize/2, this.guiTop+172, StringUtil.DECIMAL_COLOR_WHITE);
@ -261,7 +262,7 @@ public class GuiBooklet extends GuiScreen{
this.searchField.drawTextBox();
if(this.currentIndexEntry != null && this.currentChapter != null && this.currentPage != null){
this.currentPage.render(this, x, y, this.mouseClicked);
this.currentPage.render(this, x, y, this.mouseClicked, this.ticksElapsed);
}
//Achievements Hover Text

View file

@ -81,15 +81,15 @@ public class BookletPage{
return this.addTextReplacement(text, Integer.toString(replacement));
}
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
}
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
}
public ItemStack getItemStackForPage(){
public ItemStack[] getItemStacksForPage(){
return null;
}
@ -108,7 +108,7 @@ public class BookletPage{
if(checkAndTransfer){
for(BookletPage page : InitBooklet.pagesWithItemStackData){
if(ItemUtil.areItemsEqual(page.getItemStackForPage(), stack, true)){
if(ItemUtil.contains(page.getItemStacksForPage(), stack, true)){
list.add(EnumChatFormatting.GOLD+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".clickToSeeRecipe"));
if(mouseClick){

View file

@ -29,14 +29,14 @@ public class PageCoffeeRecipe extends BookletPage{
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+19, gui.guiTop+20, 146, 94, 99, 60);
}
@SuppressWarnings("unchecked")
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
String strg = "Coffee Machine Recipe";
gui.unicodeRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.unicodeRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0);

View file

@ -37,12 +37,12 @@ public class PageCrafting extends BookletPage{
}
@Override
public ItemStack getItemStackForPage(){
return this.recipe == null ? null : this.recipe.getRecipeOutput();
public ItemStack[] getItemStacksForPage(){
return this.recipe == null ? null : new ItemStack[]{this.recipe.getRecipeOutput()};
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
if(this.recipe != null){
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+27, gui.guiTop+20, 146, 20, 99, 60);
@ -51,7 +51,7 @@ public class PageCrafting extends BookletPage{
@SuppressWarnings("unchecked")
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
if(this.recipe == null){
gui.unicodeRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0);
}

View file

@ -30,7 +30,7 @@ public class PageCrusherRecipe extends BookletPage{
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
if(recipe != null){
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 60, 180, 60, 60);
@ -38,13 +38,13 @@ public class PageCrusherRecipe extends BookletPage{
}
@Override
public ItemStack getItemStackForPage(){
return this.recipe == null ? null : this.recipe.firstOutput;
public ItemStack[] getItemStacksForPage(){
return new ItemStack[]{this.recipe == null ? null : this.recipe.firstOutput};
}
@SuppressWarnings("unchecked")
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
if(recipe == null){
gui.unicodeRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0);
}

View file

@ -37,12 +37,12 @@ public class PageFurnace extends BookletPage{
}
@Override
public ItemStack getItemStackForPage(){
return this.result;
public ItemStack[] getItemStacksForPage(){
return new ItemStack[]{this.result};
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
if(this.input != null || this.getInputForOutput(this.result) != null){
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 0, 180, 60, 60);
@ -51,7 +51,7 @@ public class PageFurnace extends BookletPage{
@SuppressWarnings("unchecked")
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
ItemStack input = this.input != null ? this.input : this.getInputForOutput(this.result);
if(input == null){
gui.unicodeRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0);

View file

@ -31,12 +31,12 @@ public class PageTextOnly extends BookletPage{
}
@Override
public ItemStack getItemStackForPage(){
return this.stack;
public ItemStack[] getItemStacksForPage(){
return new ItemStack[]{this.stack};
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
String text = gui.currentPage.getText();
if(text != null && !text.isEmpty()){
gui.unicodeRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+9, 115, 0);

View file

@ -37,7 +37,7 @@ public class TooltipEvent{
//Booklet Access
if(event.itemStack != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiBooklet)){
for(BookletPage page : InitBooklet.pagesWithItemStackData){
if(ItemUtil.areItemsEqual(event.itemStack, page.getItemStackForPage(), true)){
if(ItemUtil.contains(page.getItemStacksForPage(), event.itemStack, true)){
int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode();
if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){

View file

@ -55,7 +55,7 @@ public class ContainerToolTable extends Container{
if(recipe != null){
ItemStack[] stacks = recipe.itemsNeeded.clone();
for(int i = 0; i < TileEntityToolTable.INPUT_SLOT_AMOUNT; i++){
int place = ItemUtil.getPlaceAt(stacks, table.getStackInSlot(i));
int place = ItemUtil.getPlaceAt(stacks, table.getStackInSlot(i), false);
if(place != -1){
table.decrStackSize(i, 1);
stacks[place] = null;

View file

@ -32,7 +32,7 @@ public class ToolTableHandler{
public static Recipe getRecipeFromSlots(ItemStack[] slots){
//Normal Recipes
for(Recipe recipe : recipes){
if(ItemUtil.containsAll(slots, recipe.itemsNeeded)){
if(ItemUtil.containsAll(slots, recipe.itemsNeeded, false)){
return recipe;
}
}
@ -40,7 +40,7 @@ public class ToolTableHandler{
//Repair Recipes
for(ItemStack slot : slots){
if(slot != null && slot.getItem() instanceof IToolTableRepairItem){
if(ItemUtil.contains(slots, ((IToolTableRepairItem)slot.getItem()).getRepairStack()) && slot.getItemDamage() > 0){
if(ItemUtil.contains(slots, ((IToolTableRepairItem)slot.getItem()).getRepairStack(), false) && slot.getItemDamage() > 0){
ItemStack returnStack = slot.copy();
returnStack.setItemDamage(Math.max(0, returnStack.getItemDamage()-((IToolTableRepairItem)returnStack.getItem()).repairPerStack()));
return new Recipe(returnStack, slot, ((IToolTableRepairItem)returnStack.getItem()).getRepairStack());

View file

@ -49,9 +49,9 @@ public class ItemUtil{
/**
* Returns true if stacksOne contains every ItemStack in stackTwo
*/
public static boolean containsAll(ItemStack[] stacksOne, ItemStack[] stacksTwo){
public static boolean containsAll(ItemStack[] stacksOne, ItemStack[] stacksTwo, boolean checkWildcard){
for(ItemStack stackTwo : stacksTwo){
if(!contains(stacksOne, stackTwo)){
if(!contains(stacksOne, stackTwo, checkWildcard)){
return false;
}
}
@ -61,19 +61,21 @@ public class ItemUtil{
/**
* Returns true if array contains stack or if both contain null
*/
public static boolean contains(ItemStack[] array, ItemStack stack){
return getPlaceAt(array, stack) != -1;
public static boolean contains(ItemStack[] array, ItemStack stack, boolean checkWildcard){
return getPlaceAt(array, stack, checkWildcard) != -1;
}
/**
* Returns the place of stack in array, -1 if not present
*/
public static int getPlaceAt(ItemStack[] array, ItemStack stack){
public static int getPlaceAt(ItemStack[] array, ItemStack stack, boolean checkWildcard){
if(array != null && array.length > 0){
for(int i = 0; i < array.length; i++){
if((stack == null && array[i] == null) || (stack != null && array[i] != null && array[i].isItemEqual(stack))){
if((stack == null && array[i] == null) || areItemsEqual(stack, array[i], checkWildcard)){
return i;
}
}
}
return -1;
}