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-04-23 03:36:26 +02:00
|
|
|
package appeng.client.render.items;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2014-04-23 07:18:44 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.renderer.RenderHelper;
|
2014-04-23 03:36:26 +02:00
|
|
|
import net.minecraft.client.renderer.entity.RenderItem;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraftforge.client.IItemRenderer;
|
|
|
|
|
2014-04-23 07:30:29 +02:00
|
|
|
import appeng.items.misc.ItemEncodedPattern;
|
2014-04-23 03:36:26 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-04-23 03:36:26 +02:00
|
|
|
public class ItemEncodedPatternRenderer implements IItemRenderer
|
|
|
|
{
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private final RenderItem ri = new RenderItem();
|
|
|
|
private boolean recursive = false;
|
2014-04-23 03:36:26 +02:00
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public boolean handleRenderType( final ItemStack item, final ItemRenderType type )
|
2014-04-23 03:36:26 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final boolean isShiftHeld = Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) || Keyboard.isKeyDown( Keyboard.KEY_RSHIFT );
|
2014-04-23 03:36:26 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !this.recursive && type == IItemRenderer.ItemRenderType.INVENTORY && isShiftHeld )
|
2014-04-23 03:36:26 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem();
|
2015-09-16 18:03:07 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( iep.getOutput( item ) != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-04-23 03:36:26 +02:00
|
|
|
return true;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-04-23 03:36:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public boolean shouldUseRenderHelper( final ItemRenderType type, final ItemStack item, final ItemRendererHelper helper )
|
2014-04-23 03:36:26 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void renderItem( final ItemRenderType type, final ItemStack item, final Object... data )
|
2014-04-23 03:36:26 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.recursive = true;
|
2014-04-23 03:36:26 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
final ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem();
|
|
|
|
final ItemStack is = iep.getOutput( item );
|
|
|
|
final Minecraft mc = Minecraft.getMinecraft();
|
2014-04-23 03:36:26 +02:00
|
|
|
|
2015-09-16 18:03:07 +02:00
|
|
|
GL11.glPushAttrib( GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT );
|
2014-04-23 07:18:44 +02:00
|
|
|
RenderHelper.enableGUIStandardItemLighting();
|
2014-12-29 15:13:47 +01:00
|
|
|
this.ri.renderItemAndEffectIntoGUI( mc.fontRenderer, mc.getTextureManager(), is, 0, 0 );
|
2014-04-23 07:18:44 +02:00
|
|
|
RenderHelper.disableStandardItemLighting();
|
|
|
|
GL11.glPopAttrib();
|
2014-04-23 03:36:26 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.recursive = false;
|
2014-04-23 03:36:26 +02:00
|
|
|
}
|
|
|
|
}
|