Search in sources :

Example 1 with TileEntitySCTE

use of net.geforcemods.securitycraft.api.TileEntitySCTE in project SecurityCraft by Geforce132.

the class GuiSCManual method updateRecipeAndIcons.

private void updateRecipeAndIcons() {
    if (this.currentPage < 0) {
        recipe = null;
        this.hoverCheckers.clear();
        return;
    }
    this.hoverCheckers.clear();
    if (mod_SecurityCraft.instance.manualPages.get(currentPage).hasCustomRecipe()) {
        this.recipe = mod_SecurityCraft.instance.manualPages.get(currentPage).getRecipe();
    } else {
        for (Object object : CraftingManager.getInstance().getRecipeList()) {
            if (object instanceof ShapedRecipes) {
                ShapedRecipes recipe = (ShapedRecipes) object;
                if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == mod_SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
                    this.recipe = recipe.recipeItems;
                    break;
                }
            } else if (object instanceof ShapelessRecipes) {
                ShapelessRecipes recipe = (ShapelessRecipes) object;
                if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == mod_SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
                    this.recipe = this.toItemStackArray(recipe.recipeItems);
                    break;
                }
            }
            this.recipe = null;
        }
    }
    if (recipe != null) {
        outer: for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if ((i * 3) + j == recipe.length)
                    break outer;
                if (recipe[(i * 3) + j] != null)
                    hoverCheckers.add(new CustomHoverChecker(144 + (i * 20), 144 + (i * 20) + 16, (k + 100) + (j * 20), (k + 100) + (j * 20) + 16, 20, recipe[(i * 3) + j].getDisplayName()));
            }
        }
    } else {
        String name = mod_SecurityCraft.instance.manualPages.get(currentPage).getItemName();
        //make first character lower case and remove spaces
        name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length()).replace(" ", "");
        hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, I18n.translateToLocal("gui.scManual.recipe." + name)));
    }
    Item item = mod_SecurityCraft.instance.manualPages.get(currentPage).getItem();
    TileEntity te = ((item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof ITileEntityProvider) ? ((ITileEntityProvider) ((ItemBlock) item).getBlock()).createNewTileEntity(Minecraft.getMinecraft().theWorld, 0) : null);
    Block itemBlock = ((item instanceof ItemBlock) ? ((ItemBlock) item).getBlock() : null);
    if (te != null) {
        if (te instanceof IOwnable) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 29, (k + 29) + 16, 20, I18n.translateToLocal("gui.scManual.ownableBlock")));
        }
        if (te instanceof IPasswordProtected) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 55, (k + 55) + 16, 20, I18n.translateToLocal("gui.scManual.passwordProtectedBlock")));
        }
        if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView()) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 81, (k + 81) + 16, 20, I18n.translateToLocal("gui.scManual.viewActivatedBlock")));
        }
        if (itemBlock instanceof IExplosive) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 107, (k + 107) + 16, 20, I18n.translateToLocal("gui.scManual.explosiveBlock")));
        }
        if (te instanceof CustomizableSCTE) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 213, (k + 213) + 16, 20, I18n.translateToLocal("gui.scManual.customizableBlock")));
        }
    }
}
Also used : ShapedRecipes(net.minecraft.item.crafting.ShapedRecipes) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) CustomHoverChecker(net.geforcemods.securitycraft.gui.components.CustomHoverChecker) TileEntitySCTE(net.geforcemods.securitycraft.api.TileEntitySCTE) ItemBlock(net.minecraft.item.ItemBlock) TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) ITileEntityProvider(net.minecraft.block.ITileEntityProvider) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IOwnable(net.geforcemods.securitycraft.api.IOwnable) IExplosive(net.geforcemods.securitycraft.api.IExplosive) ShapelessRecipes(net.minecraft.item.crafting.ShapelessRecipes)

Example 2 with TileEntitySCTE

use of net.geforcemods.securitycraft.api.TileEntitySCTE in project SecurityCraft by Geforce132.

the class GuiSCManual method drawScreen.

@Override
public void drawScreen(int par1, int par2, float par3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    if (update) {
        updateRecipeAndIcons();
        update = false;
    }
    if (this.currentPage == -1) {
        this.mc.getTextureManager().bindTexture(infoBookTitlePage);
    } else {
        if (this.recipe != null)
            this.mc.getTextureManager().bindTexture(infoBookTexture);
        else
            this.mc.getTextureManager().bindTexture(infoBookTextureSpecial);
    }
    this.drawTexturedModalRect(k, 5, 0, 0, 256, 250);
    if (this.currentPage > -1) {
        this.fontRendererObj.drawString(I18n.translateToLocal(mod_SecurityCraft.instance.manualPages.get(currentPage).getItem().getUnlocalizedName() + ".name"), k + 39, 27, 0, false);
        this.fontRendererObj.drawSplitString(mod_SecurityCraft.instance.manualPages.get(currentPage).getHelpInfo(), k + 18, 45, 225, 0);
    } else {
        this.fontRendererObj.drawString(I18n.translateToLocal("gui.scManual.intro.1"), k + 39, 27, 0, false);
        this.fontRendererObj.drawString(I18n.translateToLocal("gui.scManual.intro.2"), k + 60, 159, 0, false);
        if (I18n.canTranslate("gui.scManual.author")) {
            this.fontRendererObj.drawString(I18n.translateToLocal("gui.scManual.author"), k + 65, 170, 0, false);
        }
    }
    for (int i = 0; i < this.buttonList.size(); i++) {
        this.buttonList.get(i).drawButton(this.mc, par1, par2);
    }
    if (this.currentPage > -1) {
        Item item = mod_SecurityCraft.instance.manualPages.get(currentPage).getItem();
        GuiUtils.drawItemStackToGui(mc, item, k + 19, 22, !(mod_SecurityCraft.instance.manualPages.get(currentPage).getItem() instanceof ItemBlock));
        this.mc.getTextureManager().bindTexture(infoBookIcons);
        TileEntity te = ((item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof ITileEntityProvider) ? ((ITileEntityProvider) ((ItemBlock) item).getBlock()).createNewTileEntity(Minecraft.getMinecraft().theWorld, 0) : null);
        Block itemBlock = ((item instanceof ItemBlock) ? ((ItemBlock) item).getBlock() : null);
        if (itemBlock != null) {
            if (itemBlock instanceof IExplosive) {
                this.drawTexturedModalRect(k + 107, 117, 54, 1, 18, 18);
            }
            if (te != null) {
                if (te instanceof IOwnable) {
                    this.drawTexturedModalRect(k + 29, 118, 1, 1, 16, 16);
                }
                if (te instanceof IPasswordProtected) {
                    this.drawTexturedModalRect(k + 55, 118, 18, 1, 17, 16);
                }
                if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView()) {
                    this.drawTexturedModalRect(k + 81, 118, 36, 1, 17, 16);
                }
                if (te instanceof CustomizableSCTE) {
                    this.drawTexturedModalRect(k + 213, 118, 72, 1, 16, 16);
                }
            }
        }
        if (recipe != null) {
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    if (((i * 3) + j) >= recipe.length) {
                        break;
                    }
                    if (this.recipe[(i * 3) + j] == null) {
                        continue;
                    }
                    if (this.recipe[(i * 3) + j].getItem() instanceof ItemBlock) {
                        GuiUtils.drawItemStackToGui(mc, Block.getBlockFromItem(this.recipe[(i * 3) + j].getItem()), (k + 100) + (j * 20), 144 + (i * 20), !(this.recipe[(i * 3) + j].getItem() instanceof ItemBlock));
                    } else {
                        GuiUtils.drawItemStackToGui(mc, this.recipe[(i * 3) + j].getItem(), this.recipe[(i * 3) + j].getItemDamage(), (k + 100) + (j * 20), 144 + (i * 20), !(this.recipe[(i * 3) + j].getItem() instanceof ItemBlock));
                    }
                }
            }
        }
        for (CustomHoverChecker chc : hoverCheckers) {
            if (chc != null && chc.checkHover(par1, par2)) {
                if (chc.getName() != null)
                    drawHoveringText(mc.fontRendererObj.listFormattedStringToWidth(chc.getName(), 250), par1, par2, mc.fontRendererObj);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) ITileEntityProvider(net.minecraft.block.ITileEntityProvider) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) CustomHoverChecker(net.geforcemods.securitycraft.gui.components.CustomHoverChecker) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IOwnable(net.geforcemods.securitycraft.api.IOwnable) TileEntitySCTE(net.geforcemods.securitycraft.api.TileEntitySCTE) IExplosive(net.geforcemods.securitycraft.api.IExplosive) ItemBlock(net.minecraft.item.ItemBlock)

Aggregations

CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)2 IExplosive (net.geforcemods.securitycraft.api.IExplosive)2 IOwnable (net.geforcemods.securitycraft.api.IOwnable)2 IPasswordProtected (net.geforcemods.securitycraft.api.IPasswordProtected)2 TileEntitySCTE (net.geforcemods.securitycraft.api.TileEntitySCTE)2 CustomHoverChecker (net.geforcemods.securitycraft.gui.components.CustomHoverChecker)2 Block (net.minecraft.block.Block)2 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)2 Item (net.minecraft.item.Item)2 ItemBlock (net.minecraft.item.ItemBlock)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ShapedRecipes (net.minecraft.item.crafting.ShapedRecipes)1 ShapelessRecipes (net.minecraft.item.crafting.ShapelessRecipes)1