Search in sources :

Example 41 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project SecurityCraft by Geforce132.

the class ItemCameraMonitorRenderer method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if (type == ItemRenderType.FIRST_PERSON_MAP) {
        // Draw the base monitor texture.
        ((TextureManager) data[1]).bindTexture(new ResourceLocation("securitycraft:textures/gui/camera/cameraBackground.png"));
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0 - 7, 128 + 7, 0.0D, 0.0D, 1.0D);
        tessellator.addVertexWithUV(128 + 7, 128 + 7, 0.0D, 1.0D, 1.0D);
        tessellator.addVertexWithUV(128 + 7, 0 - 7, 0.0D, 1.0D, 0.0D);
        tessellator.addVertexWithUV(0 - 7, 0 - 7, 0.0D, 0.0D, 0.0D);
        tessellator.draw();
        if (item != null && item.getItem() instanceof ItemCameraMonitor && ((ItemCameraMonitor) item.getItem()).hasCameraAdded(item.getTagCompound())) {
            CameraView view = ((ItemCameraMonitor) item.getItem()).getCameraView(item.getTagCompound());
            if (SecurityCraft.instance.hasViewForCoords(view.toNBTString())) {
                IWorldView worldView = SecurityCraft.instance.getViewFromCoords(view.toNBTString()).getView();
                if (worldView.isReady() && worldView.getTexture() != 0) {
                    // Bind the IWorldView texture then draw it.
                    GL11.glDisable(3008);
                    GL11.glDisable(2896);
                    GL11.glBindTexture(GL11.GL_TEXTURE_2D, worldView.getTexture());
                    tessellator.startDrawingQuads();
                    tessellator.addVertexWithUV(128 + 7, 0 - 7, 0.0D, 0.0D, 1.0D);
                    tessellator.addVertexWithUV(0 - 7, 0 - 7, 0.0D, -1.0D, 1.0D);
                    tessellator.addVertexWithUV(0 - 7, 128 + 7, 0.0D, -1.0D, 0.0D);
                    tessellator.addVertexWithUV(128 + 7, 128 + 7, 0.0D, 0.0D, 0.0D);
                    tessellator.draw();
                    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
                    GL11.glEnable(3008);
                    GL11.glEnable(2896);
                // 
                }
                // Update the camera.
                worldView.markDirty();
            }
        }
    }
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) Tessellator(net.minecraft.client.renderer.Tessellator) ItemCameraMonitor(net.geforcemods.securitycraft.items.ItemCameraMonitor) ResourceLocation(net.minecraft.util.ResourceLocation) CameraView(net.geforcemods.securitycraft.misc.CameraView) IWorldView(com.xcompwiz.lookingglass.api.view.IWorldView)

Example 42 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project SecurityCraft by Geforce132.

the class TileEntityAlarmRenderer method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity par1TileEntity, double x, double y, double z, float par5) {
    int meta = par1TileEntity.hasWorldObj() ? par1TileEntity.getBlockMetadata() : par1TileEntity.blockMetadata;
    float rotationX = 0F;
    float rotationY = 0F;
    float rotationZ = 1F;
    if (par1TileEntity.hasWorldObj()) {
        Tessellator tessellator = Tessellator.instance;
        float f = par1TileEntity.getWorld().getLightBrightness(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord);
        int l = par1TileEntity.getWorld().getLightBrightnessForSkyBlocks(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord, 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        tessellator.setColorOpaque_F(f, f, f);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
    }
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    GL11.glPushMatrix();
    if (meta == 0) {
        rotationX = -1F;
        rotationY = -10000F;
        GL11.glTranslatef(0F, -2F, 0F);
    } else if (meta == 1) {
        rotationX = -1F;
        rotationY = 1F;
        rotationZ = 0F;
        GL11.glTranslatef(1F, -1F, 0F);
    } else if (meta == 2) {
        rotationX = -1F;
        rotationY = -1F;
        rotationZ = 0F;
        GL11.glTranslatef(-1F, -1F, 0F);
    } else if (meta == 3) {
        rotationX = 0F;
        rotationY = -1F;
        rotationZ = 1F;
        GL11.glTranslatef(0F, -1F, 1F);
    } else if (meta == 4) {
        rotationX = 0F;
        rotationY = 1F;
        rotationZ = 1F;
        GL11.glTranslatef(0F, -1F, -1F);
    } else if (meta == 5)
        rotationX = 0F;
    GL11.glRotatef(180F, rotationX, rotationY, rotationZ);
    alarmModel.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Example 43 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project SecurityCraft by Geforce132.

the class TileEntityClaymoreRenderer method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity par1TileEntity, double x, double y, double z, float par5) {
    claymoreModel.setActive(par1TileEntity.hasWorldObj() && par1TileEntity.blockType != null && par1TileEntity.blockType == SCContent.claymoreActive);
    int meta = par1TileEntity.hasWorldObj() ? par1TileEntity.getBlockMetadata() : par1TileEntity.blockMetadata;
    float rotation = 0F;
    if (par1TileEntity.hasWorldObj()) {
        Tessellator tessellator = Tessellator.instance;
        float f = par1TileEntity.getWorld().getLightBrightness(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord);
        int l = par1TileEntity.getWorld().getLightBrightnessForSkyBlocks(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord, 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        tessellator.setColorOpaque_F(f, f, f);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
    }
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    GL11.glPushMatrix();
    if (meta == 1)
        rotation = 0F;
    else if (meta == 2)
        rotation = 1F;
    else if (meta == 3)
        rotation = -10000F;
    else if (meta == 4)
        rotation = -1F;
    GL11.glRotatef(180F, rotation, 0.0F, 1.0F);
    claymoreModel.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Example 44 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project SecurityCraft by Geforce132.

the class TileEntityFrameRenderer method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity par1TileEntity, double x, double y, double z, float par5) {
    int meta = par1TileEntity.hasWorldObj() ? par1TileEntity.getBlockMetadata() : par1TileEntity.blockMetadata;
    IWorldView lgView = null;
    float rotation = 0F;
    Tessellator tessellator = Tessellator.instance;
    if (par1TileEntity.hasWorldObj()) {
        float f = par1TileEntity.getWorld().getLightBrightness(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord);
        int l = par1TileEntity.getWorld().getLightBrightnessForSkyBlocks(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord, 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        tessellator.setColorOpaque_F(f, f, f);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
    }
    if (par1TileEntity.hasWorldObj() && lgView == null && ((TileEntityFrame) par1TileEntity).hasCameraLocation() && SecurityCraft.instance.hasViewForCoords(((TileEntityFrame) par1TileEntity).getCameraView().toNBTString()) && ((TileEntityFrame) par1TileEntity).shouldShowView())
        lgView = SecurityCraft.instance.getViewFromCoords(((TileEntityFrame) par1TileEntity).getCameraView().toNBTString()).getView();
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
    Minecraft.getMinecraft().renderEngine.bindTexture(frameTexture);
    GL11.glPushMatrix();
    if (par1TileEntity.hasWorldObj()) {
        if (meta == 2)
            rotation = 0F;
        else if (meta == 4)
            rotation = 1F;
        else if (meta == 3)
            rotation = -10000F;
        else if (meta == 5)
            rotation = -1F;
    } else
        rotation = -1F;
    GL11.glRotatef(180F, rotation, 0.0F, 1.0F);
    frameModel.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    if (lgView != null) {
        if (lgView.getTexture() != 0) {
            GL11.glTranslatef(0.625F, 0.375F, -0.475F);
            GL11.glRotated(180D, 0D, 1D, 0D);
            GL11.glDisable(3008);
            GL11.glDisable(2896);
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, lgView.getTexture());
            tessellator.startDrawingQuads();
            tessellator.addVertexWithUV(0.25, 1, 0, 1, 0);
            tessellator.addVertexWithUV(0.25, 0.25, 0, 1, 1);
            tessellator.addVertexWithUV(1, 0.25, 0, 0, 1);
            tessellator.addVertexWithUV(1, 1, 0, 0, 0);
            tessellator.draw();
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
            GL11.glEnable(3008);
            GL11.glEnable(2896);
        }
        lgView.markDirty();
    }
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) TileEntityFrame(net.geforcemods.securitycraft.tileentity.TileEntityFrame) IWorldView(com.xcompwiz.lookingglass.api.view.IWorldView)

Example 45 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project SecurityCraft by Geforce132.

the class TileEntityIMSRenderer method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity par1TileEntity, double x, double y, double z, float par5) {
    int bombsRemaining = (par1TileEntity != null && par1TileEntity.hasWorldObj()) ? ((TileEntityIMS) par1TileEntity).getBombsRemaining() : 4;
    float rotationX = 0F;
    float rotationY = 0F;
    float rotationZ = 1F;
    if (par1TileEntity.hasWorldObj()) {
        Tessellator tessellator = Tessellator.instance;
        float f = par1TileEntity.getWorld().getLightBrightness(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord);
        int l = par1TileEntity.getWorld().getLightBrightnessForSkyBlocks(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord, 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        tessellator.setColorOpaque_F(f, f, f);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
    }
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    GL11.glPushMatrix();
    GL11.glRotatef(180F, rotationX, rotationY, rotationZ);
    imsModel.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, bombsRemaining);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Aggregations

Tessellator (net.minecraft.client.renderer.Tessellator)618 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)290 WorldRenderer (net.minecraft.client.renderer.WorldRenderer)54 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)42 BlockPos (net.minecraft.util.math.BlockPos)37 ResourceLocation (net.minecraft.util.ResourceLocation)31 Vec3d (net.minecraft.util.math.Vec3d)30 EnumFacing (net.minecraft.util.EnumFacing)24 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)23 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)19 IIcon (net.minecraft.util.IIcon)19 Random (java.util.Random)18 IBlockState (net.minecraft.block.state.IBlockState)17 Minecraft (net.minecraft.client.Minecraft)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 World (net.minecraft.world.World)14 Block (net.minecraft.block.Block)13 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)13 ArrayList (java.util.ArrayList)12 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)12