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

121 lines
4.2 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;
2015-12-24 02:07:03 +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.RenderHelper;
2015-06-16 02:44:59 +02:00
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.RenderItem;
2014-09-24 02:26:27 +02:00
import net.minecraft.client.renderer.texture.TextureMap;
2015-06-16 02:44:59 +02:00
import net.minecraft.client.resources.model.IBakedModel;
2014-09-24 02:26:27 +02:00
import net.minecraft.item.ItemStack;
2015-06-16 02:44:59 +02:00
import net.minecraft.util.BlockPos;
2014-09-24 02:26:27 +02:00
import net.minecraft.world.IBlockAccess;
import appeng.client.ItemRenderType;
2015-06-16 02:44:59 +02:00
import appeng.block.grindstone.BlockCrank;
2014-09-24 02:26:27 +02:00
import appeng.client.render.BaseBlockRender;
2015-06-22 18:16:25 +02:00
import appeng.client.render.ModelGenerator;
2014-09-24 02:26:27 +02:00
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
2015-09-30 14:24:40 +02:00
public void renderInventory( final BlockCrank blk, final ItemStack is, final ModelGenerator renderer, final ItemRenderType type, final Object[] obj )
2014-09-24 02:26:27 +02:00
{
renderer.setRenderAllFaces( true );
2014-09-24 02:26:27 +02:00
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.setRenderAllFaces( false );
2014-09-24 02:26:27 +02:00
}
@Override
2015-09-30 14:24:40 +02:00
public boolean renderInWorld( final BlockCrank imb, final IBlockAccess world, final BlockPos pos, final ModelGenerator renderer )
2014-09-24 02:26:27 +02:00
{
return true;
}
@Override
2015-09-30 14:24:40 +02:00
public void renderTile( final BlockCrank blk, final TileCrank tile, final WorldRenderer tess, final double x, final double y, final double z, final float f, final ModelGenerator renderBlocks )
2014-09-24 02:26:27 +02:00
{
2015-09-25 22:30:38 +02:00
if( tile.getUp() == null )
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.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 );
2015-06-16 02:44:59 +02:00
GL11.glScalef( -1, 1, 1 );
2014-09-24 02:26:27 +02:00
GL11.glTranslated( -0.5, 0, -0.5 );
2015-12-24 02:03:16 +01:00
// tess.setTranslation( -tc.getPos().getX(), -tc.getPos().getY(), -tc.getPos().getZ() );
// tess.startDrawingQuads();
2015-09-30 14:24:40 +02:00
final RenderItem ri = Minecraft.getMinecraft().getRenderItem();
2015-09-30 14:24:40 +02:00
final ItemStack stack = new ItemStack( blk );
final IBakedModel model = ri.getItemModelMesher().getItemModel( stack );
2015-12-24 02:03:16 +01:00
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor( model, 1.0F, 1.0F, 1.0F, 1.0F );
2015-06-16 02:44:59 +02:00
/*
2015-12-24 02:03:16 +01:00
* renderBlocks.renderAllFaces = true;
* renderBlocks.blockAccess = tc.getWorld();
* 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 );
* renderBlocks.renderStandardBlock( blk, tc.getPos());
* 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 );
* renderBlocks.renderStandardBlock( blk, tc.getPos() );
*/
// Tessellator.getInstance().draw();
// tess.setTranslation( 0, 0, 0 );
2014-09-24 02:26:27 +02:00
RenderHelper.enableStandardItemLighting();
}
}