ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCoffeeMachine.java

68 lines
2.9 KiB
Java
Raw Normal View History

package de.ellpeck.actuallyadditions.booklet.page;
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
import java.util.List;
2016-11-12 00:29:01 +01:00
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.common.items.InitItems;
import de.ellpeck.actuallyadditions.common.items.metalists.TheMiscItems;
2016-11-12 00:29:01 +01:00
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.client.config.GuiUtils;
2017-02-18 00:54:58 +01:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
public class PageCoffeeMachine extends BookletPage {
2016-11-12 00:29:01 +01:00
private final CoffeeIngredient ingredient;
private final ItemStack outcome;
private int counter = 0;
private int rotate = 0;
private final ItemStack[] stacks;
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
public PageCoffeeMachine(int localizationKey, CoffeeIngredient ingredient) {
2016-11-12 00:29:01 +01:00
super(localizationKey);
this.ingredient = ingredient;
this.stacks = ingredient.getInput().getMatchingStacks();
this.outcome = new ItemStack(InitItems.itemCoffee);
ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.outcome, this.ingredient);
2016-11-12 00:29:01 +01:00
}
@Override
2017-02-18 00:54:58 +01:00
@SideOnly(Side.CLIENT)
2019-05-02 09:10:29 +02:00
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
2016-11-12 00:29:01 +01:00
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
2019-05-02 09:10:29 +02:00
GuiUtils.drawTexturedModalRect(startX + 5, startY + 10, 0, 74, 117, 72, 0);
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
gui.renderScaledAsciiString("(Coffee Maker Recipe)", startX + 6, startY + 78, 0, false, gui.getMediumFontSize());
gui.renderSplitScaledAsciiString("Hover over this to see the effect!", startX + 5, startY + 51, 0, false, gui.getSmallFontSize(), 35);
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 90);
2019-02-27 19:53:05 +01:00
2019-05-02 09:10:29 +02:00
if (this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 5 + 82, startY + 10 + 1, 1F, true);
2016-11-12 00:29:01 +01:00
}
@Override
2017-02-18 00:54:58 +01:00
@SideOnly(Side.CLIENT)
2019-05-02 09:10:29 +02:00
public void initGui(GuiBookletBase gui, int startX, int startY) {
2016-11-12 00:29:01 +01:00
super.initGui(gui, startX, startY);
2019-05-02 09:10:29 +02:00
gui.addOrModifyItemRenderer(this.stacks[0], startX + 5 + 82, startY + 10 + 1, 1F, true);
gui.addOrModifyItemRenderer(this.outcome, startX + 5 + 36, startY + 10 + 42, 1F, false);
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
gui.addOrModifyItemRenderer(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), startX + 5 + 37, startY + 10 + 1, 1F, true);
gui.addOrModifyItemRenderer(new ItemStack(InitItems.itemCoffee), startX + 5 + 1, startY + 10 + 1, 1F, true);
2016-11-12 00:29:01 +01:00
}
@Override
2019-05-02 09:10:29 +02:00
public void getItemStacksForPage(List<ItemStack> list) {
super.getItemStacksForPage(list);
list.add(this.outcome);
}
2016-11-12 00:29:01 +01:00
}