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

59 lines
1.6 KiB
Java

package appeng.client.render.items;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
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;
import appeng.items.misc.ItemEncodedPattern;
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 )
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();
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
RenderHelper.enableGUIStandardItemLighting();
ri.renderItemAndEffectIntoGUI( mc.fontRenderer, mc.getTextureManager(), is, 0, 0 );
RenderHelper.disableStandardItemLighting();
GL11.glPopAttrib();
resursive = false;
}
}