Java Code Examples for net.minecraft.client.renderer.block.model.IBakedModel#isGui3d()
The following examples show how to use
net.minecraft.client.renderer.block.model.IBakedModel#isGui3d() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SurfaceHelper.java From ForgeHax with MIT License | 5 votes |
private static void renderItemModelIntoGUI( ItemStack stack, double x, double y, IBakedModel bakedmodel, double scale) { GlStateManager.pushMatrix(); MC.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); MC.getTextureManager() .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); GlStateManager.translate(x, y, 100.0F + MC.getRenderItem().zLevel); GlStateManager.translate(8.0F, 8.0F, 0.0F); GlStateManager.scale(1.0F, -1.0F, 1.0F); GlStateManager.scale(scale, scale, scale); if (bakedmodel.isGui3d()) { GlStateManager.enableLighting(); } else { GlStateManager.disableLighting(); } bakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms( bakedmodel, ItemCameraTransforms.TransformType.GUI, false); MC.getRenderItem().renderItem(stack, bakedmodel); GlStateManager.disableAlpha(); GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); GlStateManager.popMatrix(); MC.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); MC.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); }
Example 2
Source File: RenderUtils.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
/** * Will render an itemstack with opacity support properly. Minecraft does not normally support this so we * reimplemented all the itemstack rendering code. */ public static void renderItemStackWithOpacity(ItemStack stack, float opacity, @Nullable Runnable preDrawRunnable) { RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableRescaleNormal(); GlStateManager.enableTexture2D(); GlStateManager.scale(2, 2, 2); if (preDrawRunnable != null) preDrawRunnable.run(); GlStateManager.color(1f, 1f, 1f, opacity); IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, null, Minecraft.getMinecraft().player); GlStateManager.pushMatrix(); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Minecraft.getMinecraft().getTextureManager().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.translate(8.0F, 8.0F, 0.0F); GlStateManager.scale(1.0F, -1.0F, 1.0F); GlStateManager.scale(16.0F, 16.0F, 16.0F); if (model.isGui3d()) GlStateManager.enableLighting(); else GlStateManager.disableLighting(); ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.GUI, false); if (!stack.isEmpty()) { GlStateManager.pushMatrix(); GlStateManager.translate(-0.5F, -0.5F, -0.5F); if (model.isBuiltInRenderer()) { GlStateManager.enableRescaleNormal(); stack.getItem().getTileEntityItemStackRenderer().renderByItem(stack); } else { renderModel(model, 0xFFFFFF | (((int) (opacity * 255)) << 24), stack); if (stack.hasEffect()) { renderEffect(model); } } GlStateManager.translate(0.5F, 0.5F, 0.5F); GlStateManager.popMatrix(); } GlStateManager.translate(-8.0F, -8.0F, -0.0F); GlStateManager.scale(1 / 16.0F, 1 / 16.0F, 1 / 16.0F); GlStateManager.scale(1 / 2.0, 1 / 2.0, 1 / 2.0); GlStateManager.disableAlpha(); GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); GlStateManager.popMatrix(); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); }