Applied-Energistics-2-tiler.../src/main/java/appeng/client/render/blocks/RenderBlockCrank.java

116 lines
3.8 KiB
Java
Raw Normal View History

2014-11-14 12:02:52 +01:00
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
2014-09-24 02:26:27 +02:00
package appeng.client.render.blocks;
2014-12-29 21:59:05 +01:00
import org.lwjgl.opengl.GL11;
2014-09-24 02:26:27 +02:00
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.grindstone.BlockCrank;
2014-09-24 02:26:27 +02:00
import appeng.client.render.BaseBlockRender;
import appeng.tile.grindstone.TileCrank;
public class RenderBlockCrank extends BaseBlockRender<BlockCrank, TileCrank>
2014-09-24 02:26:27 +02:00
{
public RenderBlockCrank()
{
2014-09-24 02:26:27 +02:00
super( true, 60 );
}
@Override
public void renderInventory( final BlockCrank blk, final ItemStack is, final RenderBlocks renderer, final ItemRenderType type, final Object[] obj )
2014-09-24 02:26:27 +02:00
{
renderer.renderAllFaces = true;
renderer.setRenderBounds( 0.5D - 0.05, 0.5D - 0.5, 0.5D - 0.05, 0.5D + 0.05, 0.5D + 0.3, 0.5D + 0.05 );
super.renderInventory( blk, is, renderer, type, obj );
renderer.setRenderBounds( 0.70D - 0.15, 0.75D - 0.05, 0.5D - 0.05, 0.70D + 0.28, 0.75D + 0.05, 0.5D + 0.05 );
super.renderInventory( blk, is, renderer, type, obj );
renderer.renderAllFaces = false;
}
@Override
public boolean renderInWorld( final BlockCrank imb, final IBlockAccess world, final int x, final int y, final int z, final RenderBlocks renderer )
2014-09-24 02:26:27 +02:00
{
return true;
}
@Override
public void renderTile( final BlockCrank blk, final TileCrank tile, final Tessellator tess, final double x, final double y, final double z, final float f, final RenderBlocks renderBlocks )
2014-09-24 02:26:27 +02:00
{
2015-09-25 22:30:38 +02:00
if( tile.getUp() == null || tile.getUp() == ForgeDirection.UNKNOWN )
2015-04-29 02:30:53 +02:00
{
2014-09-24 02:26:27 +02:00
return;
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.locationBlocksTexture );
RenderHelper.disableStandardItemLighting();
if( Minecraft.isAmbientOcclusionEnabled() )
2015-04-29 02:30:53 +02:00
{
2014-09-24 02:26:27 +02:00
GL11.glShadeModel( GL11.GL_SMOOTH );
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
else
2015-04-29 02:30:53 +02:00
{
2014-09-24 02:26:27 +02:00
GL11.glShadeModel( GL11.GL_FLAT );
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
GL11.glCullFace( GL11.GL_FRONT );
2014-09-24 02:26:27 +02:00
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
2014-12-29 15:13:47 +01:00
this.applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
2014-09-24 02:26:27 +02:00
GL11.glTranslated( 0.5, 0, 0.5 );
GL11.glRotatef( tile.getVisibleRotation(), 0, 1, 0 );
2014-09-24 02:26:27 +02:00
GL11.glTranslated( -0.5, 0, -0.5 );
2015-09-25 22:30:38 +02:00
tess.setTranslation( -tile.xCoord, -tile.yCoord, -tile.zCoord );
2014-09-24 02:26:27 +02:00
tess.startDrawingQuads();
renderBlocks.renderAllFaces = true;
2015-09-25 22:30:38 +02:00
renderBlocks.blockAccess = tile.getWorldObj();
2014-09-24 02:26:27 +02:00
renderBlocks.setRenderBounds( 0.5D - 0.05, 0.5D - 0.5, 0.5D - 0.05, 0.5D + 0.05, 0.5D + 0.1, 0.5D + 0.05 );
2014-09-24 02:26:27 +02:00
2015-09-25 22:30:38 +02:00
renderBlocks.renderStandardBlock( blk, tile.xCoord, tile.yCoord, tile.zCoord );
2014-09-24 02:26:27 +02:00
renderBlocks.setRenderBounds( 0.70D - 0.15, 0.55D - 0.05, 0.5D - 0.05, 0.70D + 0.15, 0.55D + 0.05, 0.5D + 0.05 );
2014-09-24 02:26:27 +02:00
2015-09-25 22:30:38 +02:00
renderBlocks.renderStandardBlock( blk, tile.xCoord, tile.yCoord, tile.zCoord );
2014-09-24 02:26:27 +02:00
tess.draw();
tess.setTranslation( 0, 0, 0 );
GL11.glCullFace( GL11.GL_BACK );
2014-09-24 02:26:27 +02:00
RenderHelper.enableStandardItemLighting();
}
}