Search in sources :

Example 1 with IFastRenderMetaTileEntity

use of gregtech.api.metatileentity.IFastRenderMetaTileEntity in project GregTech by GregTechCE.

the class MetaTileEntityTESR method renderCoverFast.

/**
 * Used Specifically to render covers that are IFastRenderMetaTileEntity
 * Adapted from renderTileEntityFastPart
 * *
 */
private void renderCoverFast(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage, float alpha, List<Tuple<IFastRenderMetaTileEntity, EnumFacing>> coverList) {
    Matrix4 translation = (new Matrix4()).translate(x, y, z);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();
    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    } else {
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    for (Tuple<IFastRenderMetaTileEntity, EnumFacing> tuple : coverList) {
        CCRenderState renderState = CCRenderState.instance();
        renderState.reset();
        renderState.bind(buffer);
        renderState.setBrightness(te.getWorld(), te.getPos().offset(tuple.getSecond()));
        tuple.getFirst().renderMetaTileEntityFast(renderState, translation, partialTicks);
    }
    buffer.setTranslation(0, 0, 0);
    tessellator.draw();
    RenderHelper.enableStandardItemLighting();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EnumFacing(net.minecraft.util.EnumFacing) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) CCRenderState(codechicken.lib.render.CCRenderState) Matrix4(codechicken.lib.vec.Matrix4)

Example 2 with IFastRenderMetaTileEntity

use of gregtech.api.metatileentity.IFastRenderMetaTileEntity in project GregTech by GregTechCE.

the class MetaTileEntityTESR method renderTileEntityFast.

@Override
public void renderTileEntityFast(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) {
    MetaTileEntity metaTileEntity = te.getMetaTileEntity();
    if (metaTileEntity instanceof IFastRenderMetaTileEntity) {
        CCRenderState renderState = CCRenderState.instance();
        renderState.reset();
        renderState.bind(buffer);
        renderState.setBrightness(te.getWorld(), te.getPos());
        Matrix4 translation = new Matrix4().translate(x, y, z);
        ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, translation, partialTicks);
    }
}
Also used : MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) CCRenderState(codechicken.lib.render.CCRenderState) Matrix4(codechicken.lib.vec.Matrix4)

Example 3 with IFastRenderMetaTileEntity

use of gregtech.api.metatileentity.IFastRenderMetaTileEntity in project GregTech by GregTechCE.

the class MetaTileEntityRenderer method renderItem.

@Override
public void renderItem(ItemStack rawStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawStack);
    if (!(stack.getItem() instanceof MachineItemBlock)) {
        return;
    }
    MetaTileEntity metaTileEntity = MachineItemBlock.getMetaTileEntity(stack);
    if (metaTileEntity == null) {
        return;
    }
    GlStateManager.enableBlend();
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    metaTileEntity.setRenderContextStack(stack);
    metaTileEntity.renderMetaTileEntity(renderState, new Matrix4(), new IVertexOperation[0]);
    if (metaTileEntity instanceof IFastRenderMetaTileEntity) {
        ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, new Matrix4(), 0.0f);
    }
    metaTileEntity.setRenderContextStack(null);
    renderState.draw();
    if (metaTileEntity instanceof IRenderMetaTileEntity) {
        ((IRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityDynamic(0.0, 0.0, 0.0, 0.0f);
    }
    GlStateManager.disableBlend();
}
Also used : MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) ItemStack(net.minecraft.item.ItemStack) CCRenderState(codechicken.lib.render.CCRenderState) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) Matrix4(codechicken.lib.vec.Matrix4)

Aggregations

CCRenderState (codechicken.lib.render.CCRenderState)3 Matrix4 (codechicken.lib.vec.Matrix4)3 IFastRenderMetaTileEntity (gregtech.api.metatileentity.IFastRenderMetaTileEntity)3 IRenderMetaTileEntity (gregtech.api.metatileentity.IRenderMetaTileEntity)2 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)2 MachineItemBlock (gregtech.api.block.machines.MachineItemBlock)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1