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-02-28 09:12:00 +01:00
|
|
|
package appeng.client.render.blocks;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2015-09-30 14:25:28 +02:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
import org.lwjgl.opengl.GL12;
|
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2014-02-28 09:12:00 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.model.ModelChest;
|
2015-06-16 02:44:59 +02:00
|
|
|
import net.minecraft.client.renderer.WorldRenderer;
|
2014-02-28 09:12:00 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-06-16 02:44:59 +02:00
|
|
|
import net.minecraft.util.BlockPos;
|
2014-02-28 09:12:00 +01:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
2014-03-02 09:35:11 +01:00
|
|
|
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-05-09 12:18:43 +02:00
|
|
|
import appeng.block.storage.BlockSkyChest;
|
2015-06-16 02:44:59 +02:00
|
|
|
import appeng.block.storage.BlockSkyChest.SkyChestType;
|
2014-02-28 09:12:00 +01:00
|
|
|
import appeng.client.render.BaseBlockRender;
|
2015-06-22 18:16:25 +02:00
|
|
|
import appeng.client.render.ModelGenerator;
|
2014-02-28 09:12:00 +01:00
|
|
|
import appeng.tile.storage.TileSkyChest;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2015-05-09 12:18:43 +02:00
|
|
|
public class RenderBlockSkyChest extends BaseBlockRender<BlockSkyChest, TileSkyChest>
|
2014-02-28 09:12:00 +01:00
|
|
|
{
|
|
|
|
|
2015-05-26 15:51:16 +02:00
|
|
|
private final static ResourceLocation SKY_STONE_CHEST = new ResourceLocation( "appliedenergistics2", "textures/models/skychest.png" );
|
|
|
|
private final static ResourceLocation SKY_BLOCK_CHEST = new ResourceLocation( "appliedenergistics2", "textures/models/skyblockchest.png" );
|
2015-09-30 14:25:28 +02:00
|
|
|
private final static ResourceLocation[] METADATA_TO_TEXTURE = {
|
|
|
|
SKY_STONE_CHEST,
|
|
|
|
SKY_BLOCK_CHEST
|
|
|
|
};
|
2015-05-26 15:51:16 +02:00
|
|
|
|
|
|
|
private final ModelChest model = new ModelChest();
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public RenderBlockSkyChest()
|
|
|
|
{
|
2014-02-28 09:12:00 +01:00
|
|
|
super( true, 80 );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public void renderInventory( final BlockSkyChest blk, final ItemStack is, final ModelGenerator renderer, final ItemRenderType type, final Object[] obj )
|
2014-02-28 09:12:00 +01:00
|
|
|
{
|
2015-06-16 02:44:59 +02:00
|
|
|
//GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
|
|
|
//GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
//final int metaData = is.getItemDamage();
|
|
|
|
//final ResourceLocation loc = METADATA_TO_TEXTURE[metaData];
|
2014-03-01 04:45:30 +01:00
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
//Minecraft.getMinecraft().getTextureManager().bindTexture( loc );
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
//final float lidAngle = 0.0f;
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
//GL11.glScalef( 1.0F, -1F, -1F );
|
|
|
|
//GL11.glTranslatef( -0.0F, -1.0F, -1.0F );
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
//this.model.chestLid.offsetY = -( 0.9f / 16.0f );
|
|
|
|
//this.model.chestLid.rotateAngleX = -( ( lidAngle * 3.141593F ) / 2.0F );
|
|
|
|
//this.model.renderAll();
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
//GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
|
|
|
//GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
2014-02-28 09:12:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public boolean renderInWorld( final BlockSkyChest blk, final IBlockAccess world, final BlockPos pos, final ModelGenerator renderer )
|
2014-02-28 09:12:00 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public void renderTile( final BlockSkyChest block, final TileSkyChest skyChest, final WorldRenderer tess, final double x, final double y, final double z, final float partialTick, final ModelGenerator renderer )
|
2014-02-28 09:12:00 +01:00
|
|
|
{
|
2015-09-25 22:30:38 +02:00
|
|
|
if( skyChest == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-02-28 09:12:00 +01:00
|
|
|
return;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !skyChest.hasWorldObj() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-02-28 09:12:00 +01:00
|
|
|
return;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-05-26 15:51:16 +02:00
|
|
|
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
2014-02-28 09:12:00 +01:00
|
|
|
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
|
|
|
|
2015-09-25 22:30:38 +02:00
|
|
|
final IBlockState metaData = skyChest.getWorld().getBlockState( skyChest.getPos() );
|
2015-06-16 02:44:59 +02:00
|
|
|
final ResourceLocation loc = METADATA_TO_TEXTURE[ ((BlockSkyChest)metaData.getBlock()).type == SkyChestType.BLOCK ? 1 : 0 ];
|
2014-03-01 04:45:30 +01:00
|
|
|
|
2014-02-28 09:12:00 +01:00
|
|
|
Minecraft.getMinecraft().getTextureManager().bindTexture( loc );
|
|
|
|
|
|
|
|
this.applyTESRRotation( x, y, z, skyChest.getForward(), skyChest.getUp() );
|
|
|
|
|
|
|
|
GL11.glScalef( 1.0F, -1F, -1F );
|
|
|
|
GL11.glTranslatef( -0.0F, -1.0F, -1.0F );
|
|
|
|
|
2015-05-26 15:51:16 +02:00
|
|
|
final long now = System.currentTimeMillis();
|
|
|
|
final long distance = now - skyChest.lastEvent;
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( skyChest.playerOpen > 0 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-21 01:41:45 +02:00
|
|
|
skyChest.lidAngle += distance * 0.0001;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-28 09:12:00 +01:00
|
|
|
else
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-21 01:41:45 +02:00
|
|
|
skyChest.lidAngle -= distance * 0.0001;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( skyChest.lidAngle > 0.5f )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-02-28 09:12:00 +01:00
|
|
|
skyChest.lidAngle = 0.5f;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( skyChest.lidAngle < 0.0f )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-02-28 09:12:00 +01:00
|
|
|
skyChest.lidAngle = 0.0f;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2014-09-28 11:47:17 +02:00
|
|
|
float lidAngle = skyChest.lidAngle;
|
|
|
|
lidAngle = 1.0F - lidAngle;
|
|
|
|
lidAngle = 1.0F - lidAngle * lidAngle * lidAngle;
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
this.model.chestLid.offsetY = -( 1.01f / 16.0f );
|
|
|
|
this.model.chestLid.rotateAngleX = -( ( lidAngle * 3.141593F ) / 2.0F );
|
2015-05-26 15:51:16 +02:00
|
|
|
|
|
|
|
// The vanilla chests wants culling reversed...
|
|
|
|
GL11.glCullFace( GL11.GL_FRONT );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.model.renderAll();
|
2015-05-26 15:51:16 +02:00
|
|
|
GL11.glCullFace( GL11.GL_BACK );
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-05-26 15:51:16 +02:00
|
|
|
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
2014-02-28 09:12:00 +01:00
|
|
|
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
|
|
|
}
|
|
|
|
}
|