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

71 lines
2.6 KiB
Java
Raw Normal View History

package de.ellpeck.actuallyadditions.booklet.page;
2016-11-10 21:07:15 +01:00
2019-05-02 09:10:29 +02:00
import java.util.List;
import java.util.Map;
2016-11-12 00:29:01 +01:00
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.common.util.StackUtil;
import de.ellpeck.actuallyadditions.common.util.StringUtil;
2016-11-10 21:07:15 +01:00
import net.minecraft.item.ItemStack;
2016-11-12 00:29:01 +01:00
import net.minecraft.item.crafting.FurnaceRecipes;
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 PageFurnace extends BookletPage {
2016-11-10 21:07:15 +01:00
2016-11-12 00:29:01 +01:00
private final ItemStack input;
private final ItemStack output;
2019-05-02 09:10:29 +02:00
public PageFurnace(int localizationKey, ItemStack output) {
2016-11-22 22:54:35 +01:00
this(localizationKey, output, 0);
}
2019-05-02 09:10:29 +02:00
public PageFurnace(int localizationKey, ItemStack output, int priority) {
2016-11-22 22:54:35 +01:00
super(localizationKey, priority);
2016-11-12 00:29:01 +01:00
this.output = output;
this.input = getInputForOutput(output);
}
2019-05-02 09:10:29 +02:00
private static ItemStack getInputForOutput(ItemStack output) {
for (Map.Entry<ItemStack, ItemStack> entry : FurnaceRecipes.instance().getSmeltingList().entrySet()) {
ItemStack stack = entry.getValue();
2019-05-02 09:10:29 +02:00
if (StackUtil.isValid(stack)) {
if (stack.isItemEqual(output)) { return entry.getKey(); }
}
}
2017-11-02 22:49:53 +01:00
return ItemStack.EMPTY;
}
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 + 23, startY + 10, 0, 146, 80, 26, 0);
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".furnaceRecipe") + ")", startX + 32, startY + 42, 0, false, gui.getMediumFontSize());
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 57);
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.input, startX + 23 + 1, startY + 10 + 5, 1F, true);
gui.addOrModifyItemRenderer(this.output, startX + 23 + 59, startY + 10 + 5, 1F, false);
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.output);
}
2016-11-10 21:07:15 +01:00
}