Java Code Examples for net.minecraft.client.Minecraft#getRenderItem()
The following examples show how to use
net.minecraft.client.Minecraft#getRenderItem() .
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: InventoryComponent.java From seppuku with GNU General Public License v3.0 | 6 votes |
@Override public void render(int mouseX, int mouseY, float partialTicks) { super.render(mouseX, mouseY, partialTicks); final Minecraft mc = Minecraft.getMinecraft();// store the minecraft instance in a local variable if (mc.player == null) return; this.setW(16 * 9); this.setH(16 * 3); GlStateManager.pushMatrix(); RenderHelper.enableGUIStandardItemLighting(); RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x75101010); // background for (int i = 0; i < 27; i++) { ItemStack itemStack = mc.player.inventory.mainInventory.get(i + 9); int offsetX = (int) this.getX() + (i % 9) * 16; int offsetY = (int) this.getY() + (i / 9) * 16; mc.getRenderItem().renderItemAndEffectIntoGUI(itemStack, offsetX, offsetY); mc.getRenderItem().renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, offsetX, offsetY, null); } RenderHelper.disableStandardItemLighting(); mc.getRenderItem().zLevel = 0.0F; GlStateManager.popMatrix(); }
Example 2
Source File: GuiFabricatorButton.java From EmergingTechnology with MIT License | 6 votes |
@SideOnly(Side.CLIENT) @Override public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { if (!visible) return; RenderHelper.enableGUIStandardItemLighting(); RenderItem itemRender = mc.getRenderItem(); GlStateManager.translate(0.0F, 0.0F, 32.0F); this.zLevel = 200.0F; itemRender.zLevel = 200.0F; itemRender.renderItemAndEffectIntoGUI(itemStackToRender, x, y); this.zLevel = 0.0F; itemRender.zLevel = 0.0F; RenderHelper.disableStandardItemLighting(); }
Example 3
Source File: Widget.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@SideOnly(Side.CLIENT) protected static void drawItemStack(ItemStack itemStack, int x, int y, @Nullable String altTxt) { GlStateManager.pushMatrix(); GlStateManager.translate(0.0F, 0.0F, 32.0F); GlStateManager.color(1F, 1F, 1F, 1F); GlStateManager.enableRescaleNormal(); GlStateManager.enableLighting(); RenderHelper.enableGUIStandardItemLighting(); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f); Minecraft mc = Minecraft.getMinecraft(); RenderItem itemRender = mc.getRenderItem(); itemRender.renderItemAndEffectIntoGUI(itemStack, x, y); itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x, y, altTxt); GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); GlStateManager.color(1F, 1F, 1F, 1F); GlStateManager.popMatrix(); GlStateManager.enableBlend(); GlStateManager.disableDepth(); }
Example 4
Source File: FacadeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static void renderItemCover(CCRenderState ccrs, int side, ItemStack renderStack, Cuboid6 bounds) { Minecraft minecraft = Minecraft.getMinecraft(); RenderItem renderItem = minecraft.getRenderItem(); IBakedModel model = renderItem.getItemModelWithOverrides(renderStack, null, null); IBlockState state = FacadeHelper.lookupBlockForItem(renderStack); String cacheKey = state.getBlock().getRegistryName() + "|" + state.getBlock().getMetaFromState(state); List<CCQuad> renderQuads = itemQuadCache.getIfPresent(cacheKey); if (renderQuads == null) { List<BakedQuad> quads = new ArrayList<>(model.getQuads(null, null, 0)); for (EnumFacing face : EnumFacing.VALUES) { quads.addAll(model.getQuads(null, face, 0)); } renderQuads = applyItemTint(sliceQuads(CCQuad.fromArray(quads), side, bounds), renderStack); itemQuadCache.put(cacheKey, renderQuads); } AdvCCRSConsumer consumer = new AdvCCRSConsumer(ccrs); consumer.setTranslation(new Matrix4() .translate(Vector3.center.copy().subtract(bounds.center())) .scale(1.05, 1.05, 1.05)); for (CCQuad quad : renderQuads) { quad.pipe(consumer); } }
Example 5
Source File: Hud.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
public Hud(Minecraft mc, int width, int height) { this.mc = mc; this.itemRender = mc.getRenderItem(); this.fontRenderer = mc.fontRenderer; if (fontRenderer == null) { throw new NullPointerException("fontRenderer is NULL"); } this.width = width; this.height = height; }
Example 6
Source File: ShulkerPreviewModule.java From seppuku with GNU General Public License v3.0 | 4 votes |
@Listener public void onRenderTooltip(EventRenderTooltip event) { if (event.getItemStack() == null) return; final Minecraft mc = Minecraft.getMinecraft(); if (event.getItemStack().getItem() instanceof ItemShulkerBox) { ItemStack shulker = event.getItemStack(); NBTTagCompound tagCompound = shulker.getTagCompound(); if (tagCompound != null && tagCompound.hasKey("BlockEntityTag", 10)) { NBTTagCompound blockEntityTag = tagCompound.getCompoundTag("BlockEntityTag"); if (blockEntityTag.hasKey("Items", 9)) { event.setCanceled(true); // cancel rendering the old tooltip NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>withSize(27, ItemStack.EMPTY); ItemStackHelper.loadAllItems(blockEntityTag, nonnulllist); // load the itemstacks from the tag to the list // store mouse/event coords int x = event.getX(); int y = event.getY(); // translate to mouse x, y GlStateManager.translate(x + 10, y - 5, 0); GlStateManager.disableLighting(); GlStateManager.disableDepth(); // background RenderUtil.drawRect(-3, -mc.fontRenderer.FONT_HEIGHT - 4, 9 * 16 + 3, 3 * 16 + 3, 0x99101010); RenderUtil.drawRect(-2, -mc.fontRenderer.FONT_HEIGHT - 3, 9 * 16 + 2, 3 * 16 + 2, 0xFF202020); RenderUtil.drawRect(0, 0, 9 * 16, 3 * 16, 0xFF101010); // text mc.fontRenderer.drawStringWithShadow(shulker.getDisplayName(), 0, -mc.fontRenderer.FONT_HEIGHT - 1, 0xFFFFFFFF); GlStateManager.enableDepth(); mc.getRenderItem().zLevel = 150.0F; RenderHelper.enableGUIStandardItemLighting(); // loop through items in shulker inventory for (int i = 0; i < nonnulllist.size(); i++) { ItemStack itemStack = nonnulllist.get(i); int offsetX = (i % 9) * 16; int offsetY = (i / 9) * 16; mc.getRenderItem().renderItemAndEffectIntoGUI(itemStack, offsetX, offsetY); mc.getRenderItem().renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, offsetX, offsetY, null); } RenderHelper.disableStandardItemLighting(); mc.getRenderItem().zLevel = 0.0F; GlStateManager.enableLighting(); // reverse the translate GlStateManager.translate(-(x + 10), -(y - 5), 0); } } if(this.middleClick.getValue()) { if (Mouse.isButtonDown(2)) { if (!this.clicked) { final BlockShulkerBox shulkerBox = (BlockShulkerBox) Block.getBlockFromItem(shulker.getItem()); if (shulkerBox != null) { final NBTTagCompound tag = shulker.getTagCompound(); if (tag != null && tag.hasKey("BlockEntityTag", 10)) { final NBTTagCompound entityTag = tag.getCompoundTag("BlockEntityTag"); final TileEntityShulkerBox te = new TileEntityShulkerBox(); te.setWorld(mc.world); te.readFromNBT(entityTag); mc.displayGuiScreen(new GuiShulkerBox(mc.player.inventory, te)); } } } this.clicked = true; } else { this.clicked = false; } } } }
Example 7
Source File: BlockInfo.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
public void render(int x, int y, int zLevel, Minecraft mc) { if (this.state != null) { GlStateManager.pushMatrix(); RenderUtils.drawOutlinedBox(x, y, this.totalWidth, this.totalHeight, 0xFF000000, GuiBase.COLOR_HORIZONTAL_BAR, zLevel); FontRenderer textRenderer = mc.fontRenderer; int x1 = x + 10; y += 4; textRenderer.drawString(this.title, x1, y, 0xFFFFFFFF); y += 12; GlStateManager.disableLighting(); RenderUtils.enableGuiItemLighting(); RenderUtils.drawRect(x1, y, 16, 16, 0x20FFFFFF, zLevel); // light background for the item float origZ = mc.getRenderItem().zLevel; mc.getRenderItem().zLevel = zLevel + 1; mc.getRenderItem().renderItemAndEffectIntoGUI(mc.player, this.stack, x1, y); mc.getRenderItem().renderItemOverlayIntoGUI(textRenderer, this.stack, x1, y, null); mc.getRenderItem().zLevel = origZ; //GlStateManager.disableBlend(); RenderUtils.disableItemLighting(); textRenderer.drawString(this.stackName, x1 + 20, y + 4, 0xFFFFFFFF); y += 20; textRenderer.drawString(this.blockRegistryname, x1, y, 0xFF4060FF); y += textRenderer.FONT_HEIGHT + 4; RenderUtils.renderText(x1, y, 0xFFB0B0B0, this.props); GlStateManager.popMatrix(); } }