Applied-Energistics-2-tiler.../client/render/items/ItemEncodedPatternRenderer.java

60 lines
1.6 KiB
Java
Raw Normal View History

2014-04-23 03:36:26 +02:00
package appeng.client.render.items;
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;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
2014-04-23 03:36:26 +02:00
import appeng.items.misc.ItemEncodedPattern;
2014-04-23 03:36:26 +02:00
public class ItemEncodedPatternRenderer implements IItemRenderer
{
RenderItem ri = new RenderItem();
boolean resursive;
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
boolean isShiftHeld = Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) || Keyboard.isKeyDown( Keyboard.KEY_RSHIFT );
if ( resursive == false && type == IItemRenderer.ItemRenderType.INVENTORY && isShiftHeld )
{
ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem();
if ( iep.getOutput( item ) != null )
2014-04-23 03:36:26 +02:00
return true;
}
return false;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
return false;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
resursive = true;
ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem();
ItemStack is = iep.getOutput( item );
Minecraft mc = Minecraft.getMinecraft();
2014-04-23 03:36:26 +02:00
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
RenderHelper.enableGUIStandardItemLighting();
ri.renderItemAndEffectIntoGUI( mc.fontRenderer, mc.getTextureManager(), is, 0, 0 );
RenderHelper.disableStandardItemLighting();
GL11.glPopAttrib();
2014-04-23 03:36:26 +02:00
resursive = false;
}
}