Search in sources :

Example 6 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project LogisticsPipes by RS485.

the class LogisticsNewSolidBlockWorldRenderer method renderWorldBlock.

public void renderWorldBlock(IBlockAccess world, LogisticsSolidTileEntity blockTile, RenderBlocks renderer, int x, int y, int z) {
    Tessellator tess = Tessellator.instance;
    SimpleServiceLocator.cclProxy.getRenderState().reset();
    SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
    SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
    BlockRotation rotation = BlockRotation.ZERO;
    int brightness = 0;
    IIconTransformation icon;
    if (blockTile != null) {
        BlockRotation.getRotation(blockTile.getRotation());
        brightness = new DoubleCoordinates(blockTile).getBlock(world).getMixedBrightnessForBlock(world, blockTile.xCoord, blockTile.yCoord, blockTile.zCoord);
        icon = SimpleServiceLocator.cclProxy.createIconTransformer(LogisticsSolidBlock.getNewIcon(world, blockTile.xCoord, blockTile.yCoord, blockTile.zCoord));
    } else {
        brightness = LogisticsPipes.LogisticsSolidBlock.getMixedBrightnessForBlock(world, x, y, z);
        icon = SimpleServiceLocator.cclProxy.createIconTransformer(LogisticsSolidBlock.getNewIcon(world, x, y, z));
    }
    tess.setColorOpaque_F(1F, 1F, 1F);
    tess.setBrightness(brightness);
    //Draw
    LogisticsNewSolidBlockWorldRenderer.block.get(rotation).render(new LPTranslation(x, y, z), icon);
    if (blockTile != null) {
        DoubleCoordinates pos = new DoubleCoordinates(blockTile);
        for (CoverSides side : CoverSides.values()) {
            boolean render = true;
            DoubleCoordinates newPos = CoordinateUtils.sum(pos, side.getDir(rotation));
            TileEntity sideTile = newPos.getTileEntity(blockTile.getWorldObj());
            if (sideTile instanceof LogisticsTileGenericPipe) {
                LogisticsTileGenericPipe tilePipe = (LogisticsTileGenericPipe) sideTile;
                if (tilePipe.renderState.pipeConnectionMatrix.isConnected(side.getDir(rotation).getOpposite())) {
                    render = false;
                }
            }
            if (render) {
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Inner.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
            }
        }
    }
}
Also used : LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Tessellator(net.minecraft.client.renderer.Tessellator) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) IIconTransformation(logisticspipes.proxy.object3d.interfaces.IIconTransformation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 7 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project LogisticsPipes by RS485.

the class LogisticsPipeItemRenderer method renderPipeItem.

private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
    //don't break other mods' guis when holding a pipe
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
    //force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
    // GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
    Tessellator tessellator = Tessellator.instance;
    Block block = LogisticsPipes.LogisticsPipeBlock;
    IIcon icon = item.getItem().getIconFromDamage(0);
    if (icon == null) {
        icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
    }
    block.setBlockBounds(LogisticsPipeItemRenderer.PIPE_MIN_POS, 0.0F, LogisticsPipeItemRenderer.PIPE_MIN_POS, LogisticsPipeItemRenderer.PIPE_MAX_POS, 1.0F, LogisticsPipeItemRenderer.PIPE_MAX_POS);
    //block.setBlockBounds(PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MAX_POS, PIPE_MAX_POS, PIPE_MAX_POS);
    block.setBlockBoundsForItemRender();
    render.setRenderBoundsFromBlock(block);
    GL11.glTranslatef(translateX, translateY, translateZ);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1F, 0.0F);
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    // nicely leave the rendering how it was
    GL11.glPopAttrib();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IIcon(net.minecraft.util.IIcon) Block(net.minecraft.block.Block)

Example 8 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project LogisticsPipes by RS485.

the class LogisticsNewPipeItemRenderer method renderPipeItem.

private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
    GL11.glPushMatrix();
    // don't break other mods' guis when holding a pipe
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
    // force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
    // GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
    Tessellator tessellator = Tessellator.instance;
    GL11.glTranslatef(translateX, translateY, translateZ);
    Block block = LogisticsPipes.LogisticsPipeBlock;
    if (item.getItem() instanceof ItemLogisticsPipe) {
        ItemLogisticsPipe lItem = (ItemLogisticsPipe) item.getItem();
        int renderList = lItem.getNewPipeRenderList();
        if (renderList == -1) {
            lItem.setNewPipeRenderList(GL11.glGenLists(1));
            renderList = lItem.getNewPipeRenderList();
            GL11.glNewList(renderList, GL11.GL_COMPILE);
            tessellator.startDrawingQuads();
            generatePipeRenderList(lItem.getNewPipeIconIndex());
            tessellator.draw();
            GL11.glEndList();
        }
        GL11.glCallList(renderList);
    }
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopAttrib();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) Block(net.minecraft.block.Block) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe)

Example 9 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project LogisticsPipes by RS485.

the class LogisticsNewPipeItemRenderer method renderBlockItem.

private void renderBlockItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
    //don't break other mods' guis when holding a pipe
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
    //force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glTranslatef(translateX, translateY, translateZ);
    Block block = LogisticsPipes.LogisticsPipeBlock;
    Tessellator tess = Tessellator.instance;
    BlockRotation rotation = BlockRotation.ZERO;
    tess.startDrawingQuads();
    IIconTransformation icon = SimpleServiceLocator.cclProxy.createIconTransformer(Textures.LOGISTICS_REQUEST_TABLE_NEW);
    //Draw
    LogisticsNewSolidBlockWorldRenderer.block.get(rotation).render(new I3DOperation[] { icon });
    for (CoverSides side : CoverSides.values()) {
        LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation).render(new I3DOperation[] { icon });
    }
    tess.draw();
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    // nicely leave the rendering how it was
    GL11.glPopAttrib();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) CoverSides(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.CoverSides) Block(net.minecraft.block.Block) IIconTransformation(logisticspipes.proxy.object3d.interfaces.IIconTransformation) BlockRotation(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.BlockRotation)

Example 10 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project LogisticsPipes by RS485.

the class GuiCheckBox method drawButton.

/**
	 * Draws this button to the screen.
	 */
@Override
public void drawButton(Minecraft minecraft, int par2, int par3) {
    if (visible) {
        boolean var5 = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
        int var6 = getHoverState(var5);
        //GL11.glBindTexture(GL11.GL_TEXTURE_2D, minecraft.renderEngine.getTexture("/logisticspipes/gui/checkbox-" + (state?"on":"out") + "" + (var6 == 2?"-mouse":"") + ".png"));
        minecraft.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/gui/checkbox-" + (state ? "on" : "out") + "" + (var6 == 2 ? "-mouse" : "") + ".png"));
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        Tessellator var9 = Tessellator.instance;
        var9.startDrawingQuads();
        var9.addVertexWithUV(xPosition, yPosition + height, zLevel, 0, 1);
        var9.addVertexWithUV(xPosition + width, yPosition + height, zLevel, 1, 1);
        var9.addVertexWithUV(xPosition + width, yPosition, zLevel, 1, 0);
        var9.addVertexWithUV(xPosition, yPosition, zLevel, 0, 0);
        var9.draw();
        /*
			            drawTexturedModalRect(xPosition  			, yPosition				, 0		, 0 ,0);
			            drawTexturedModalRect(xPosition + width / 2	, yPosition				, 0		, 1, 0);

			            drawTexturedModalRect(xPosition  			, yPosition + height / 2, 0		, 0 ,1);
			            drawTexturedModalRect(xPosition + width / 2	, yPosition + height / 2, 0		, 1, 1);
			 */
        mouseDragged(minecraft, par2, par3);
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) ResourceLocation(net.minecraft.util.ResourceLocation)

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