Search in sources :

Example 1 with ItemSaltedFood

use of com.axanthic.loi.items.ItemSaltedFood in project Lands-of-Icaria by Axanthic-Game-Studios.

the class RecipeSalt method matches.

@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
    ItemStack foodStack = ItemStack.EMPTY;
    ItemStack saltStack = ItemStack.EMPTY;
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if (!stack.isEmpty()) {
            if (foodStack.isEmpty() && stack.getItem() instanceof ItemFood && !(stack.getItem() instanceof ItemSaltedFood))
                foodStack = stack;
            else if (saltStack.isEmpty() && saltIngredient.apply(stack))
                saltStack = stack;
            else
                return false;
        }
    }
    if (foodStack.isEmpty() || saltStack.isEmpty())
        return false;
    if (blacklistIngredient.apply(foodStack) != LOIConfig.misc.saltListIsWhite)
        return false;
    return true;
}
Also used : ItemFood(net.minecraft.item.ItemFood) ItemSaltedFood(com.axanthic.loi.items.ItemSaltedFood) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemSaltedFood

use of com.axanthic.loi.items.ItemSaltedFood in project Lands-of-Icaria by Axanthic-Game-Studios.

the class LOIItemStackRenderer method renderByItem.

public void renderByItem(ItemStack stack, float partialTicks) {
    Item item = stack.getItem();
    if (item instanceof ItemBlockMobHead) {
        if (TileEntitySpecialRendererMobHead.instance != null) {
            GlStateManager.pushMatrix();
            GlStateManager.disableCull();
            TileEntitySpecialRendererMobHead.instance.renderSkull(0.0F, 0.1F, 0.0F, EnumFacing.DOWN, 0.0F, ((BlockMobHead) ((ItemBlock) item).getBlock()).name, -1, 1.6F);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }
    if (item instanceof ItemSaltedFood) {
        GlStateManager.pushMatrix();
        GlStateManager.translate(0.5F, 0.5F, 0.5F);
        if (stack.hasTagCompound()) {
            ItemStack foodStack = ItemSaltedFood.getContainedItem(stack.getTagCompound());
            if (!foodStack.isEmpty())
                Minecraft.getMinecraft().getRenderItem().renderItem(foodStack, ItemCameraTransforms.TransformType.NONE);
        }
        Minecraft.getMinecraft().getRenderItem().renderItem(saltOverlay, ItemCameraTransforms.TransformType.NONE);
        GlStateManager.popMatrix();
    }
    if (item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof BlockGrinder) {
        if (TileEntitySpecialRendererGrinder.instance != null) {
            GlStateManager.pushMatrix();
            GlStateManager.disableCull();
            TileEntitySpecialRendererGrinder.instance.renderInventory();
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }
    if (item instanceof ItemScroll) {
        ItemScroll scroll = ((ItemScroll) item);
        if (!Minecraft.getMinecraft().player.isInvisible()) {
            EnumHand rightHand = EnumHand.MAIN_HAND;
            EnumHand leftHand = EnumHand.OFF_HAND;
            if (Minecraft.getMinecraft().player.getPrimaryHand() == EnumHandSide.LEFT) {
                rightHand = EnumHand.OFF_HAND;
                leftHand = EnumHand.MAIN_HAND;
            }
            // render player arms
            if (BakedModelScroll.transform == TransformType.FIRST_PERSON_RIGHT_HAND) {
                GlStateManager.translate(((float) Minecraft.getMinecraft().displayWidth) / ((float) Minecraft.getMinecraft().displayHeight) * 0.5F, 0.9F, 0.4F);
                GlStateManager.disableCull();
                GlStateManager.pushMatrix();
                GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
                if (Minecraft.getMinecraft().player.getHeldItem(leftHand).isEmpty() && rightHand != EnumHand.OFF_HAND)
                    renderArm(EnumHandSide.LEFT);
                GlStateManager.translate(0.0F, 0.3F, -0.7F);
                GlStateManager.rotate(-60.0F, 1.0F, 0.0F, 0.0F);
                renderArm(EnumHandSide.RIGHT);
                GlStateManager.popMatrix();
                GlStateManager.enableCull();
            }
            if (BakedModelScroll.transform == TransformType.FIRST_PERSON_LEFT_HAND) {
                GlStateManager.translate(((float) Minecraft.getMinecraft().displayWidth) / ((float) Minecraft.getMinecraft().displayHeight) * -0.5F + 1.68F, 0.9F, 0.4F);
                GlStateManager.disableCull();
                GlStateManager.pushMatrix();
                GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
                GlStateManager.translate(-0.1F, 0.03F, -0.7F);
                if (Minecraft.getMinecraft().player.getHeldItem(rightHand).isEmpty() && leftHand != EnumHand.OFF_HAND)
                    renderArm(EnumHandSide.RIGHT);
                GlStateManager.translate(0.1F, 0.27F, 0.7F);
                GlStateManager.rotate(60.0F, 1.0F, 0.0F, 0.0F);
                renderArm(EnumHandSide.LEFT);
                GlStateManager.popMatrix();
                GlStateManager.enableCull();
            }
        }
        // render scroll background
        GlStateManager.scale(0.76F, 0.76F, 0.76F);
        GlStateManager.disableLighting();
        Minecraft.getMinecraft().getTextureManager().bindTexture(RES_SCROLL_BACKGROUND);
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferbuilder = tessellator.getBuffer();
        GlStateManager.translate(-1.0F, -0.6F, -0.2F);
        GlStateManager.scale(0.0078125F, 0.0078125F, 0.0078125F);
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
        bufferbuilder.pos(0.0D, 0.0D, 0.0D).tex(0.0D, 1.0D).endVertex();
        bufferbuilder.pos(142.0D, 0.0D, 0.0D).tex(1.0D, 1.0D).endVertex();
        bufferbuilder.pos(142.0D, 142.0D, 0.0D).tex(1.0D, 0.0D).endVertex();
        bufferbuilder.pos(0.0D, 142.0D, 0.0D).tex(0.0D, 0.0D).endVertex();
        tessellator.draw();
        GlStateManager.translate(71.0F, 44.5F, 0.01F);
        // render scroll title
        GlStateManager.pushMatrix();
        GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
        FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
        String title = I18n.translateToLocal("spell." + scroll.getName() + ".name");
        fontRenderer.drawString(title, -fontRenderer.getStringWidth(title) / 2, -60, 0x82735A);
        GlStateManager.popMatrix();
        GlStateManager.scale(25.0F, 25.0F, 0.001F);
        // render ingredients
        Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        GlStateManager.pushMatrix();
        GlStateManager.scale(0.6F, 0.6F, 1.0F);
        GlStateManager.translate(0.55F - scroll.getRecipe().order.size() * 0.55F, 2.5F, 0.0F);
        for (int i = 0; i < scroll.getRecipe().order.size(); ++i) {
            Minecraft.getMinecraft().getRenderItem().renderItem(scroll.getRecipe().getInputs().get(scroll.getRecipe().order.get(i)).getMatchingStacks()[0], ItemCameraTransforms.TransformType.GUI);
            GlStateManager.translate(1.1F, 0.0F, 0.0F);
        }
        GlStateManager.popMatrix();
        // render result
        Minecraft.getMinecraft().getRenderItem().renderItem(scroll.getRecipe().recipeOutput, ItemCameraTransforms.TransformType.GUI);
        GlStateManager.enableLighting();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BlockGrinder(com.axanthic.loi.blocks.BlockGrinder) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) ItemBlock(net.minecraft.item.ItemBlock) Item(net.minecraft.item.Item) ItemBlockMobHead(com.axanthic.loi.items.ItemBlockMobHead) EnumHand(net.minecraft.util.EnumHand) ItemSaltedFood(com.axanthic.loi.items.ItemSaltedFood) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) ItemScroll(com.axanthic.loi.items.ItemScroll)

Aggregations

ItemSaltedFood (com.axanthic.loi.items.ItemSaltedFood)2 ItemStack (net.minecraft.item.ItemStack)2 BlockGrinder (com.axanthic.loi.blocks.BlockGrinder)1 ItemBlockMobHead (com.axanthic.loi.items.ItemBlockMobHead)1 ItemScroll (com.axanthic.loi.items.ItemScroll)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 Item (net.minecraft.item.Item)1 ItemBlock (net.minecraft.item.ItemBlock)1 ItemFood (net.minecraft.item.ItemFood)1 EnumHand (net.minecraft.util.EnumHand)1