Search in sources :

Example 6 with ItemBackpack

use of net.mcft.copy.betterstorage.item.ItemBackpack in project BetterStorage by copygirl.

the class TileEntityBackpackRenderer method renderTileEntityAt.

public void renderTileEntityAt(TileEntityBackpack backpack, double x, double y, double z, float partialTicks) {
    if ((backpack.getWorldObj() == null) && (backpack.blockType == null))
        return;
    ItemBackpack item = ((TileBackpack) backpack.getBlockType()).getItemType();
    ItemStack stack = ((backpack.stack != null) ? backpack.stack : new ItemStack(item));
    ModelBackpack backpackModel = item.getModel();
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glTranslated(x, y + 2.0, z + 1.0);
    GL11.glScalef(1.0F, -1.0F, -1.0F);
    GL11.glTranslated(0.5, 0.5, 0.5);
    ForgeDirection orientation = ForgeDirection.getOrientation(backpack.getBlockMetadata());
    int rotation = DirectionUtils.getRotation(orientation);
    GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
    float angle = backpack.prevLidAngle + (backpack.lidAngle - backpack.prevLidAngle) * partialTicks;
    angle = 1.0F - angle;
    angle = 1.0F - angle * angle;
    backpackModel.setLidRotation((float) (angle * Math.PI / 4.0));
    int renderPasses = item.getRenderPasses(0);
    for (int pass = 0; pass < renderPasses; pass++) {
        String type = ((pass == 0) ? null : "overlay");
        bindTexture(new ResourceLocation(item.getArmorTexture(stack, null, 0, type)));
        RenderUtils.setColorFromInt(item.getColorFromItemStack(stack, pass));
        backpackModel.renderAll();
    }
    if ((backpack.stack != null) && (backpack.stack.isItemEnchanted())) {
        float f9 = (backpack.ticksExisted + partialTicks) / 3;
        RenderUtils.bindTexture(Resources.enchantedEffect);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glColor4f(0.5F, 0.5F, 0.5F, 1.0F);
        GL11.glDepthMask(false);
        GL11.glPolygonOffset(-1.0F, -1.0F);
        GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
        for (int k = 0; k < 2; ++k) {
            GL11.glDisable(GL11.GL_LIGHTING);
            float f11 = 0.65F;
            GL11.glColor4f(0.5F * f11, 0.25F * f11, 0.8F * f11, 1.0F);
            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glLoadIdentity();
            float f12 = f9 * (0.001F + k * 0.003F) * 20.0F;
            float f13 = 0.33333334F;
            GL11.glScalef(f13, f13, f13);
            GL11.glRotatef(30.0F - k * 60.0F, 0.0F, 0.0F, 1.0F);
            GL11.glTranslatef(0.0F, f12, 0.0F);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            backpackModel.renderAll();
        }
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
        GL11.glPolygonOffset(0.0F, 0.0F);
        GL11.glDepthMask(true);
        GL11.glLoadIdentity();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_BLEND);
    }
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
Also used : ModelBackpack(net.mcft.copy.betterstorage.client.model.ModelBackpack) ResourceLocation(net.minecraft.util.ResourceLocation) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ItemBackpack(net.mcft.copy.betterstorage.item.ItemBackpack) TileBackpack(net.mcft.copy.betterstorage.tile.TileBackpack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemBackpack (net.mcft.copy.betterstorage.item.ItemBackpack)6 ItemStack (net.minecraft.item.ItemStack)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ModelBackpack (net.mcft.copy.betterstorage.client.model.ModelBackpack)1 ModelBackpackArmor (net.mcft.copy.betterstorage.client.model.ModelBackpackArmor)1 EntityFrienderman (net.mcft.copy.betterstorage.entity.EntityFrienderman)1 InventoryStacks (net.mcft.copy.betterstorage.inventory.InventoryStacks)1 ItemBucketSlime (net.mcft.copy.betterstorage.item.ItemBucketSlime)1 ItemDrinkingHelmet (net.mcft.copy.betterstorage.item.ItemDrinkingHelmet)1 ItemEnderBackpack (net.mcft.copy.betterstorage.item.ItemEnderBackpack)1 ItemPresentBook (net.mcft.copy.betterstorage.item.ItemPresentBook)1 ItemCardboardAxe (net.mcft.copy.betterstorage.item.cardboard.ItemCardboardAxe)1 ItemCardboardHoe (net.mcft.copy.betterstorage.item.cardboard.ItemCardboardHoe)1 ItemCardboardPickaxe (net.mcft.copy.betterstorage.item.cardboard.ItemCardboardPickaxe)1 ItemCardboardSheet (net.mcft.copy.betterstorage.item.cardboard.ItemCardboardSheet)1 ItemCardboardShovel (net.mcft.copy.betterstorage.item.cardboard.ItemCardboardShovel)1 ItemCardboardSword (net.mcft.copy.betterstorage.item.cardboard.ItemCardboardSword)1