@SideOnly(Side.CLIENT) public static void renderItemInWorld(ItemStack stack){ if(!stack.isEmpty()){ Minecraft mc = Minecraft.getMinecraft(); RenderItem renderer = mc.getRenderItem(); TextureManager manager = mc.getTextureManager(); IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null); manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false); GlStateManager.enableRescaleNormal(); GlStateManager.enableBlend(); GlStateManager.pushMatrix(); model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.FIXED, false); renderer.renderItem(stack, model); GlStateManager.cullFace(GlStateManager.CullFace.BACK); GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); } }
private void renderAffinity(ItemStack affinity) { RenderItem itemRenderer = minecraft.getRenderItem(); if (affinity != null) { double local = (period * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); float hoverHeight = (float) ((0.4 * (Math.sin(local))) / 8); GlStateManager.translate(0.5F, 1.2F + hoverHeight, 0.5F); EntityItem entityItem = new EntityItem(getWorld(), 0, 0, 0, affinity); entityItem.getEntityItem().stackSize = 1; entityItem.hoverStart = 0.0F; GlStateManager.pushMatrix(); GlStateManager.disableLighting(); float rotation = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); GlStateManager.rotate(rotation, 0.0F, 1.0F, 0.0F); GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.pushAttrib(); RenderHelper.enableStandardItemLighting(); itemRenderer.renderItem(entityItem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED); RenderHelper.disableStandardItemLighting(); GlStateManager.popAttrib(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); GlStateManager.translate(0.0F, -hoverHeight, 0.0F); } }
/** * Draws a slot that is disabled... * * @param x slot x * @param y slot y * @param renderItem Item Render */ public static void drawDisabledSlot(int x, int y, RenderItem renderItem) { new GuiUtils().zLevel = 100.f; renderItem.zLevel = 100.0f; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int colorOverlay = new Color(139, 139, 139, 200).hashCode(); GlStateManager.disableLighting(); GlStateManager.disableDepth(); GlStateManager.colorMask(true, true, true, false); renderItem.renderItemAndEffectIntoGUI(new ItemStack(Blocks.AIR), x, y); new GuiUtils().drawGradientRect(x, y, x + 16, y + 16, colorOverlay, colorOverlay); GlStateManager.colorMask(true, true, true, true); GlStateManager.enableLighting(); GlStateManager.enableDepth(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); new GuiUtils().zLevel = 0.0f; renderItem.zLevel = 0.0f; }
private void renderSaiLeft(int id) { RenderItem renderer = Minecraft.getMinecraft().getRenderItem(); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, -0.1); GlStateManager.translate(0, 0.625, 0); GlStateManager.rotate(180, 1, 0, 0); GlStateManager.translate(0.275, 0, 0); GlStateManager.rotate(-90, 0, 1, 0); GlStateManager.scale(0.5, 0.5, 1); renderer.renderItem(this.itemsToRender[id], ItemCameraTransforms.TransformType.NONE); GlStateManager.popMatrix(); }
private void renderSaiRight(int id) { RenderItem renderer = Minecraft.getMinecraft().getRenderItem(); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, -0.1); GlStateManager.translate(0, 0.625, 0); GlStateManager.rotate(180, 1, 0, 0); GlStateManager.translate(-0.275, 0, 0); GlStateManager.rotate(-90, 0, 1, 0); GlStateManager.scale(0.5, 0.5, 1); renderer.renderItem(this.itemsToRender[id], ItemCameraTransforms.TransformType.NONE); GlStateManager.popMatrix(); }
private void renderRopeCoil(int id) { RenderItem renderer = Minecraft.getMinecraft().getRenderItem(); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, -0.15); GlStateManager.translate(0, 1.25, 0); GlStateManager.rotate(180, 1, 0, 0); GlStateManager.translate(0.3, 0, 0); GlStateManager.rotate(-90, 0, 1, 0); GlStateManager.rotate(-90, 0, 0, 1); GlStateManager.scale(0.8, 0.8, 1); renderer.renderItem(this.itemsToRender[id], ItemCameraTransforms.TransformType.NONE); GlStateManager.popMatrix(); }
@SideOnly (Side.CLIENT) public static void sanitizeEntityRenderers(RenderManager renderManager) { if (!hasSanitized) { try { for (Render<? extends Entity> render : renderManager.entityRenderMap.values()) { if (render != null) { for (Field field : render.getClass().getDeclaredFields()) { if (field.getType().equals(RenderItem.class)) { field.setAccessible(true); field.set(render, CCRenderItem.getOverridenRenderItem()); } } } } } catch (Exception e) { throw new RuntimeException("Unable to reflect an EntityRenderer!", e); } hasSanitized = true; } }
@Override public void renderTileEntityAt(TileMetal te, double x, double y, double z, float partialTicks, int destroyStage) { RenderItem renderer = Minecraft.getMinecraft().getRenderItem(); GlStateManager.pushMatrix(); GlStateManager.translate(x+0.5D,y+0.05D,z+0.5D); EntityItem stack = new EntityItem(getWorld(),0,0,0,te.blankStack); stack.getEntityItem().stackSize = 1; stack.hoverStart = 0.0F; GlStateManager.disableLighting(); GlStateManager.rotate(-90,1,0,0); GlStateManager.scale(0.5D,0.5D,0.5D); GlStateManager.pushAttrib(); RenderHelper.disableStandardItemLighting(); renderer.renderItem(stack.getEntityItem(), ItemCameraTransforms.TransformType.FIXED); RenderHelper.enableStandardItemLighting(); GlStateManager.popAttrib(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); }
public static void init() { RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); for (Map.Entry<String, Block> ent : renderMap.entrySet()) { renderItem.getItemModelMesher().register(Item.getItemFromBlock(ent.getValue()), 0, new ModelResourceLocation(Reference.MODID + ":" + ent.getKey(), "inventory")); } //TODO Convert to Lambda for (Map.Entry<Material, Block> entry : oreBlockMap.entrySet()) { Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() { @Override public int getColorFromItemstack(ItemStack stack, int tintIndex) { return entry.getKey().getColour().getRGB(); } }, entry.getValue()); } }
/** * Draws an ItemStack * * @param itemStack itemstack to draw * @param x startX * @param y startY */ public void drawItemStack(ItemStack itemStack, int x, int y) { int[][] savedGLState = OpenGLHelper.saveGLState(new int[]{GL11.GL_ALPHA_TEST, GL11.GL_LIGHTING}); RenderItem renderItem = mc.getRenderItem(); GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderHelper.enableGUIStandardItemLighting(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_DEPTH_TEST); renderItem.renderItemIntoGUI(itemStack, x, y); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); OpenGLHelper.restoreGLState(savedGLState); }
/** * Draws a slot that is disabled... * * @param x slot x * @param y slot y * @param renderItem Item Render */ public void drawDisabledSlot(int x, int y, RenderItem renderItem) { this.zLevel = 100.f; renderItem.zLevel = 100.0f; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int colorOverlay = new Color(139, 139, 139, 200).hashCode(); GlStateManager.disableLighting(); GlStateManager.disableDepth(); GlStateManager.colorMask(true, true, true, false); renderItem.renderItemAndEffectIntoGUI(new ItemStack(Blocks.BARRIER), x, y); this.drawGradientRect(x, y, x + 16, y + 16, colorOverlay, colorOverlay); GlStateManager.colorMask(true, true, true, true); GlStateManager.enableLighting(); GlStateManager.enableDepth(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.zLevel = 0.0f; renderItem.zLevel = 0.0f; }
private void renderItemOnBlock(World world, ItemStack itemStack) { RenderItem itemRenderer = minecraft.getRenderItem(); if (itemStack != null && !(itemStack.getItem() instanceof ItemBlock)) { GlStateManager.translate(0.0F, -0.98F, 0.0F); EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, itemStack); entityitem.getEntityItem().stackSize = 1; entityitem.hoverStart = 0.0F; GlStateManager.pushMatrix(); GlStateManager.disableLighting(); GlStateManager.rotate(180, 0.0F, 1.0F, 1.0F); GlStateManager.scale(0.75F, 0.75F, 0.75F); GlStateManager.pushAttrib(); RenderHelper.enableStandardItemLighting(); itemRenderer.renderItem(entityitem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED); RenderHelper.disableStandardItemLighting(); GlStateManager.popAttrib(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); } }
public static boolean renderObject(Minecraft mc, RenderItem itemRender, int x, int y, Object itm, boolean highlight, float lvl) { itemRender.zLevel = lvl; if (itm==null) { return renderItemStack(mc, itemRender, null, x, y, "", highlight); } if (itm instanceof Item) { return renderItemStack(mc, itemRender, new ItemStack((Item) itm, 1), x, y, "", highlight); } if (itm instanceof Block) { return renderItemStack(mc, itemRender, new ItemStack((Block) itm, 1), x, y, "", highlight); } if (itm instanceof ItemStack) { return renderItemStackWithCount(mc, itemRender, (ItemStack) itm, x, y, highlight); } // if (itm instanceof IIcon) { // return renderIcon(mc, itemRender, (IIcon) itm, x, y, highlight); // } return renderItemStack(mc, itemRender, null, x, y, "", highlight); }
@SuppressWarnings("unused") private void render(Object block) { if (block instanceof Block && block instanceof ICustomBlock) { if (Sponge.getPlatform().getExecutionType().isClient()) { RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); renderItem.getItemModelMesher().register( Item.getItemFromBlock((Block) block), 0, new ModelResourceLocation( "skree:" + ((ICustomBlock) block).__getID(), "inventory" ) ); } } else { throw new IllegalArgumentException("Invalid custom item!"); } }
@Override protected void drawItem(TexturePallette item, Minecraft mc, RenderItem itemRender, double left, double top, float partialTicks, boolean isHighlighted) { int size = this.actualItemPixels(); // if texture is translucent provide a background if(this.renderAlpha) GuiUtil.drawRect(left, top, left + size, top + size, this.baseColor); Rotation rotation = item.rotation.rotationType() == TextureRotationType.RANDOM ? Rotation.values()[(int) ((CommonProxy.currentTimeMillis() >> 11) & 3)] : item.rotation.rotation; TextureAtlasSprite tex = mc.getTextureMapBlocks().getAtlasSprite(item.getSampleTextureName()); GuiUtil.drawTexturedRectWithColor(left, top, this.zLevel, tex, size, size, this.borderColor, item.textureScale, rotation, renderAlpha); }
protected void renderItemModel(ItemStack stack, double x, double y, IBakedModel bakedmodel, RenderItem renderItem) { 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); this.setupGuiTransform((int) x, (int) y); bakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(bakedmodel, ItemCameraTransforms.TransformType.GUI, false); renderItem.renderItem(stack, bakedmodel); GlStateManager.disableAlpha(); GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); GlStateManager.popMatrix(); mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); }
@Override public void render(ItemStack stack, float patrtialTicks) { GlStateManager.pushMatrix(); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); renderItem.renderItem(stack, parent); InventoryBPortableBarrel barrel = BlocksItemsBetterChests.betterportablebarrel.getInventoryFor(stack, null); if (barrel != null && barrel.getChestPart().isItemSet()) { InventoryPartBarrel part = barrel.getChestPart(); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, -0.05); GlStateManager.scale(0.8, 0.8, 0.8); renderItem.renderItem(part.getDummy(), TransformType.FIXED); GlStateManager.enableBlend(); GlStateManager.popMatrix(); } GlStateManager.popMatrix(); }
private void renderItem(ItemStack itemStack) { parent.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); final RenderItem itemRenderer = parent.getItemRenderer(); final ItemModelMesher itemModelMesher = itemRenderer.getItemModelMesher(); final IBakedModel model = itemModelMesher.getItemModel(stack); GlStateManager.disableLighting(); GlStateManager.enableRescaleNormal(); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.pushMatrix(); itemRenderer.renderItem(stack, model); GlStateManager.cullFace(CullFace.BACK); GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); GlStateManager.enableLighting(); }
protected void drawItemStack(@Nonnull ItemStack stack, int x, int y, String overlayText) { if (stack.isEmpty()) return; RenderHelper.enableGUIStandardItemLighting(); final RenderItem itemRenderer = parent.getItemRenderer(); GlStateManager.translate(0.0F, 0.0F, 32.0F); this.zLevel = 200.0F; itemRenderer.zLevel = 200.0F; FontRenderer font = null; font = stack.getItem().getFontRenderer(stack); if (font == null) font = parent.getFontRenderer(); itemRenderer.renderItemAndEffectIntoGUI(stack, x, y); itemRenderer.renderItemOverlayIntoGUI(font, stack, x, y, overlayText); this.zLevel = 0.0F; itemRenderer.zLevel = 0.0F; RenderHelper.disableStandardItemLighting(); }
public static void renderStack(RenderItem ri, ItemStack stack, int cols, int col, int rows, int row) { GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); GlStateManager.translate(0.4f * (cols / 2.0 - col) - 0.2f, 0.4f * (rows / 2.0 - row), 0); GlStateManager.pushMatrix(); GlStateManager.rotate((float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL), 0, 1, 0); GlStateManager.scale(0.45, 0.45, 0.45); ri.renderItem(stack, ItemCameraTransforms.TransformType.FIXED); if (stack.hasEffect()) { GlStateManager.disableAlpha(); GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); } GlStateManager.popMatrix(); GlStateManager.popAttrib(); GlStateManager.popMatrix(); }
@EventHandler public void init(FMLInitializationEvent event) { // init MinecraftForge.EVENT_BUS.register(this); scriptyBlock = new ScriptyBlock(); if (event.getSide() == Side.CLIENT) { RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); renderItem.getItemModelMesher().register(Item.getItemFromBlock(scriptyBlock), 0, new ModelResourceLocation("scripty:" + scriptyBlock.getName(), "inventory")); } NetworkRegistry.INSTANCE.registerGuiHandler(this, gui); }
@Override public void render(IGuideRenderer guide, int startPoint, int endPoint, int mouseX, int mouseY, float partialTicks) { RenderItem renderer = guide.getItemRenderer(); FontRenderer font = guide.getFontRenderer(); // TODO background lp: for(int y = 0; y < 3; y++) { for(int x = 0; x < width; x++) { int index = y * width + x; if(index >= input.length) break lp; ItemStack item = getStack(input[y * width + x]); if(item == ItemStack.EMPTY) continue; renderItem(renderer, font, item, x * 17, y * 17);// TODO x and y } } renderItem(renderer, font, result, 17 * 4, 17); // TODO lang and center if(shaped) { //font.drawString("Shaped Recipe", 0, 0, 0x000000); } else { //font.drawString("Shapeless Recipe", 0, 0, 0x000000); } }
public static void init() { RenderManager rm = Minecraft.getMinecraft().getRenderManager(); RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem(); rm.entityRenderMap.put(EntityEvolvedEnderman.class, new RenderEvolvedEnderman(rm)); rm.entityRenderMap.put(EntityFrienderman.class, new RenderFrienderman(rm)); rm.entityRenderMap.put(EntityFrienderPearl.class, new RenderSnowball<EntityFrienderPearl>(rm, ModItems.FRIENDER_PEARL, itemRenderer)); rm.entityRenderMap.put(EntityEvolvedEndermite.class, new RenderEvolvedEndermite(rm)); }
@SideOnly(Side.CLIENT) public static void initModels() { Minecraft mc = Minecraft.getMinecraft(); RenderManager rm = mc.getRenderManager(); RenderItem ri = mc.getRenderItem(); RenderingRegistry.registerEntityRenderingHandler(EntityCustomPotion.class, new RenderThrowable(rm, UCItems.generic, 13, ri)); RenderingRegistry.registerEntityRenderingHandler(EntityItemWeepingEye.class, new RenderThrowable(rm, UCItems.generic, 16, ri)); RenderingRegistry.registerEntityRenderingHandler(EntityEulaBook.class, new RenderThrowable(rm, UCItems.generic, 24, ri)); }
public static void drawItem(ItemStack itemstack, int i, int j) { final RenderItem itemRenderer = Wrapper.getMinecraft().getRenderItem(); //TODO: FOR RENDERING BLOCKS IN PLAYERESP GuiIngame.itemRenderer.renderIcon(j, j, null, j, j); itemRenderer.renderItemIntoGUI(itemstack, i, j); itemRenderer.renderItemOverlayIntoGUI(Wrapper.getMinecraft().fontRendererObj, itemstack, i, j, null); GL11.glDisable(2884 /* GL_CULL_FACE */); GL11.glEnable(3008 /* GL_ALPHA_TEST */); GL11.glDisable(3042 /* GL_BLEND */); GL11.glDisable(2896 /* GL_LIGHTING */); GL11.glDisable(2884 /* GL_CULL_FACE */); GL11.glClear(256); }
public RenderEntityItem(RenderManager renderManagerIn, RenderItem p_i46167_2_) { super(renderManagerIn); this.itemRenderer = p_i46167_2_; this.shadowSize = 0.15F; this.shadowOpaque = 0.75F; }
public void renderItemGlow(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand, int glowColor) { // enchantments mess up the rendering ItemStack drop2 = drop.copy(); if (drop2.hasEffect()) { removeEnch(drop2.getTagCompound()); } float red = (glowColor >> 16 & 255) / 255.0F; float green = (glowColor >> 8 & 255) / 255.0F; float blue = (glowColor & 255) / 255.0F; float alpha = 0.2F; pushMatrix(); disableLighting(); GL14.glBlendColor(red, green, blue, alpha); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); ((IRenderItem) renderItem).useTransparency(true); scale(1.1, 1.1, 1.1); translate(0, .01, .01); renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); translate(.01, -.01, -.02); renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); ((IRenderItem) renderItem).useTransparency(false); enableLighting(); popMatrix(); // I hate rendering }
private void renderKatana(int id) { RenderItem renderer = Minecraft.getMinecraft().getRenderItem(); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, -0.2); GlStateManager.translate(0, 1.125, 0); GlStateManager.rotate(180, 1, 0, 0); GlStateManager.scale(0.8, 0.8, 1); renderer.renderItem(this.itemsToRender[id], ItemCameraTransforms.TransformType.NONE); GlStateManager.popMatrix(); }
private void renderShuriken(int id) { RenderItem renderer = Minecraft.getMinecraft().getRenderItem(); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, 0.2); GlStateManager.translate(0, 0.75, 0); GlStateManager.translate(-0.15, 0, 0); GlStateManager.scale(0.2, 0.2, 0.5); renderer.renderItem(this.itemsToRender[id], ItemCameraTransforms.TransformType.NONE); GlStateManager.popMatrix(); }
private void renderSmokeBomb(int id) { RenderItem renderer = Minecraft.getMinecraft().getRenderItem(); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, -0.2); GlStateManager.translate(0, 0.75, 0); GlStateManager.rotate(180, 0, 1, 0); GlStateManager.translate(0.125, 0, 0); GlStateManager.scale(0.3, 0.3, 1); renderer.renderItem(this.itemsToRender[id], ItemCameraTransforms.TransformType.NONE); GlStateManager.popMatrix(); }
@Override public void doRender(EntityItem entity, double x, double y, double z, float entityYaw, float partialTicks) { ItemStack stack = entity.getItem(); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); IBakedModel model = renderItem.getItemModelMesher().getItemModel(stack); if (model instanceof IEntityItemPreRenderCallback) { ((IEntityItemPreRenderCallback) model).preEntityRender(entity); } wrapped.doRender(entity, x, y, z, entityYaw, partialTicks); }
public static void registerRender(FMLInitializationEvent event) { for (Block block : blockList()) { new Item(); Item item = Item.getItemFromBlock(block); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); renderItem.getItemModelMesher().register(item, 0, new ModelResourceLocation(block.getRegistryName().toString(), ("inventory"))); } }
public static void registerRender(FMLInitializationEvent event) { RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); for (Item item : itemList()) { renderItem.getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName().toString(), "inventory")); } }
@SideOnly(Side.CLIENT) public static void registerRendering() { RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); BlockColors colors = Minecraft.getMinecraft().getBlockColors(); ItemColors icolors = Minecraft.getMinecraft().getItemColors(); for(Block block : blocks) { renderItem.getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(RefStrings.MODID + ":" + block.getUnlocalizedName().substring(5), "inventory")); colors.registerBlockColorHandler(new EverythingBlockColor(), block); icolors.registerItemColorHandler(new EverythingItemColor(), block); } }
/** * Draws a transparent item in the slot * * @param itemStack item to draw * @param x slot x * @param y slot y * @param renderItem Item Render */ public void drawItemStack(ItemStack itemStack, int x, int y, RenderItem renderItem, boolean transparent) { this.zLevel = 50.0f; renderItem.zLevel = 50.0f; GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); int colorOverlay = new Color(139, 139, 139, 160).hashCode(); RenderHelper.enableGUIStandardItemLighting(); renderItem.renderItemAndEffectIntoGUI(itemStack, x, y); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.disableDepth(); GlStateManager.colorMask(true, true, true, false); if (transparent) { this.zLevel = 100.0f; renderItem.zLevel = 100.0f; this.drawGradientRect(x, y, x + 16, y + 16, colorOverlay, colorOverlay); } GlStateManager.colorMask(true, true, true, true); GlStateManager.enableDepth(); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); this.zLevel = 0.0f; renderItem.zLevel = 0.0f; }
public void setCurrentScreen(GuiScreen guiScreen, float zLevel, FontRenderer fontRendererObj, RenderItem itemRender) { this.minecraft = guiScreen.mc; this.guiScreen = guiScreen; this.zLevel = zLevel; this.uiWidth = guiScreen.width; this.uiHeight = guiScreen.height; this.fontRenderer.setFontRenderer(fontRendererObj); this.nativeFontRenderer = fontRendererObj; this.itemRender = itemRender; this.offsetX = 0; this.offsetY = 0; }
/** * Check if an ItemStack renders correctly or * shows the missing texture * @param s */ public static boolean checkValidModel(ItemStack s) { IBakedModel bM; RenderItem rI = ClientProxy.mc.getRenderItem(); bM = rI.getItemModelWithOverrides(s, null, null); return !bM.getParticleTexture().getIconName().equals(MISSING_NO); }
private void renderFloatingItem(World world, ItemStack itemStack) { RenderItem itemRenderer = minecraft.getRenderItem(); if (itemStack != null) { double local = (period * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); float hoverHeight = (float) ((0.4 * (Math.sin(local))) / 8); GlStateManager.translate(0.5F, 2F + hoverHeight, 0.5F); EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, itemStack); entityitem.getEntityItem().stackSize = 1; entityitem.hoverStart = 0.0F; GlStateManager.pushMatrix(); GlStateManager.disableLighting(); float rotation = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); GlStateManager.rotate(rotation, 0.0F, 1.0F, 0); GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.pushAttrib(); RenderHelper.enableStandardItemLighting(); itemRenderer.renderItem(entityitem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED); RenderHelper.disableStandardItemLighting(); GlStateManager.popAttrib(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); GlStateManager.translate(0.0F, -hoverHeight, 0.0F); } }
private void renderFloatingItem(World world, ItemStack itemStack) { RenderItem itemRenderer = minecraft.getRenderItem(); if (itemStack != null) { double local = (period * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); float hoverHeight = (float) ((0.4 * (Math.sin(local))) / 8); GlStateManager.translate(0.5F, 0.5F + hoverHeight, 0.5F); EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, itemStack); entityitem.getEntityItem().stackSize = 1; entityitem.hoverStart = 0.0F; GlStateManager.pushMatrix(); GlStateManager.disableLighting(); float rotation = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); GlStateManager.rotate(rotation, 0.0F, 1.0F, 0); GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.pushAttrib(); RenderHelper.enableStandardItemLighting(); itemRenderer.renderItem(entityitem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED); RenderHelper.disableStandardItemLighting(); GlStateManager.popAttrib(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); } }