use of net.minecraft.client.renderer.RenderItem in project LogisticsPipes by RS485.
the class LogisticsRenderPipe method renderItemStackOnSign.
public void renderItemStackOnSign(@Nonnull ItemStack itemstack) {
if (itemstack.isEmpty()) {
// Only happens on false configuration
return;
}
Minecraft mc = Minecraft.getMinecraft();
RenderItem itemRender = mc.getRenderItem();
GlStateManager.disableLighting();
// Forge: Reset color in case Items change it.
GlStateManager.color(1F, 1F, 1F);
// Forge: Make sure blend is enabled else tabs show a white border.
GlStateManager.enableBlend();
itemRender.zLevel = 100.0F;
GlStateManager.enableRescaleNormal();
// itemRender.renderItemAndEffectIntoGUI(itemstack, 0, 0);
// item render code
GlStateManager.pushMatrix();
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
GlStateManager.enableRescaleNormal();
GlStateManager.enableAlpha();
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
// mezz.jei.render.ItemStackFastRenderer#getBakedModel
ItemModelMesher itemModelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
IBakedModel bakedModel = itemModelMesher.getItemModel(itemstack);
bakedModel = bakedModel.getOverrides().handleItemState(bakedModel, itemstack, null, null);
// make item/block flat and position it
GlStateManager.translate(0.05F, 0F, 0F);
GlStateManager.scale(0.8F, 0.8F, 0.001F);
// model rotation
bakedModel = ForgeHooksClient.handleCameraTransforms(bakedModel, ItemCameraTransforms.TransformType.GUI, false);
// model scaling to fit on sign
GlStateManager.scale(0.4F, 0.4F, 0.4F);
itemRender.renderItem(itemstack, bakedModel);
GlStateManager.disableRescaleNormal();
GlStateManager.disableAlpha();
GlStateManager.popMatrix();
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
// item render code end
// not needed?
// itemRender.renderItemOverlays(mc.fontRenderer, itemstack, 0, 0);
itemRender.zLevel = 0.0F;
}
Aggregations