net.minecraft.client.renderer.ItemRenderer Java Examples
The following examples show how to use
net.minecraft.client.renderer.ItemRenderer.
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: RenderGolemHelper.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
public static void renderCore(EntityGolemBase golem, AdditionalGolemCore core) { GL11.glPushMatrix(); GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); GL11.glTranslatef(0.0875F, -0.96F, 0.15F + (golem.getGolemDecoration().contains("P") ? 0.03F : 0.0F)); GL11.glScaled(0.175D, 0.175D, 0.175D); GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); ItemStack coreItem = core.getItem(); IIcon icon = coreItem.getItem().getIcon(coreItem, 0); float f1 = icon.getMaxU(); float f2 = icon.getMinV(); float f3 = icon.getMinU(); float f4 = icon.getMaxV(); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f3, f4, icon.getIconWidth(), icon.getIconHeight(), 0.2F); GL11.glPopMatrix(); }
Example #2
Source File: PlayerSpecials.java From Chisel-2 with GNU General Public License v2.0 | 6 votes |
@Override public void renderExtras(EntityPlayer player, boolean post) { if (!post) { GL11.glPushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); if (player.isSneaking()) { GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); } boolean armor = player.getCurrentArmor(1) != null; GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.25F, -0.85F, armor ? 0.2F : 0.28F); GL11.glScalef(0.5F, 0.5F, 0.5F); GL11.glColor3f(1.0F, 1.0F, 1.0F); int light = 0xF000F0; int lightmapX = light % 0x10000; int lightmapY = light / 0x10000; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); IIcon icon = toRender.getIconIndex(); ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 1.0F / 16.0F); GL11.glPopMatrix(); } }
Example #3
Source File: ChoppingBlockRenderer.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void render(ChoppingBlockTileEntity te, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int p_225616_5_, int p_225616_6_) { BlockState state = te.getWorld().getBlockState(te.getPos()); if (!(state.getBlock() instanceof ChoppingBlock)) return; //if (destroyStage < 0) { matrixStack.push(); ItemRenderer itemRenderer = mc.getItemRenderer(); LazyOptional<IItemHandler> linv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); linv.ifPresent((inv) -> { ItemStack stack = inv.getStackInSlot(0); if (stack.getCount() > 0) { matrixStack.push(); matrixStack.translate(0.5, 0.5, 0.5); matrixStack.translate(0, -4.5 / 16.0f, 0); matrixStack.scale(2, 2, 2); IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(stack, te.getWorld(), (LivingEntity) null); itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.GROUND, true, matrixStack, buffer, p_225616_5_, p_225616_6_, ibakedmodel); /*int breakStage = te.getBreakStage(); if (breakStage >= 0) { renderItem(stack, ItemCameraTransforms.TransformType.GROUND, breakStage); }*/ matrixStack.pop(); } }); matrixStack.pop(); } }
Example #4
Source File: RenderGolemHelper.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public static void renderCarriedItemsFix(EntityGolemBase golem) { GL11.glPushMatrix(); GL11.glScaled(0.4D, 0.4D, 0.4D); GL11.glTranslatef(-0.5F, 2.5F, -1.25F); GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); ItemStack item = golem.getCarriedForDisplay(); int renderPass = 0; do { IIcon icon = item.getItem().getIcon(item, renderPass); if (icon != null) { Color color = new Color(item.getItem().getColorFromItemStack(item, renderPass)); GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); GL11.glColor3f(1.0F, 1.0F, 1.0F); } renderPass++; } while (renderPass < item.getItem().getRenderPasses(item.getItemDamage())); GL11.glPopMatrix(); }
Example #5
Source File: ItemMinigun.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) private void suppressSwitchAnimation(){ Minecraft mc = Minecraft.getMinecraft(); ItemRenderer renderer = mc.entityRenderer.itemRenderer; renderer.updateEquippedItem(); renderer.equippedProgress = 1; renderer.prevEquippedProgress = 1; }
Example #6
Source File: BW_GT_ItemRenderer.java From bartworks with MIT License | 4 votes |
@Override public void renderItem(IItemRenderer.ItemRenderType type, ItemStack aStack, Object... data) { if (!GT_Utility.isStackInvalid(aStack)) { short aMetaData = (short) aStack.getItemDamage(); if (aMetaData >= 0) { BW_Meta_Items.BW_GT_MetaGen_Item_Hook aItem = (BW_Meta_Items.BW_GT_MetaGen_Item_Hook) aStack.getItem(); GL11.glEnable(3042); if (type == IItemRenderer.ItemRenderType.ENTITY) { if (RenderItem.renderInFrame) { GL11.glScalef(0.85F, 0.85F, 0.85F); GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); } GL11.glTranslated(-0.5D, -0.42D, 0.0D); } GL11.glColor3f(1.0F, 1.0F, 1.0F); IIcon tIcon = (IIcon) BW_Util.get2DCoordFrom1DArray(aMetaData, 0, 2, aItem.mIconList); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); GL11.glBlendFunc(770, 771); if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { if (aMetaData < CircuitImprintLoader.reverseIDs) GT_RenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); else { for (int i = 0; i < 4; i++) { GT_RenderUtil.renderItemIcon(tIcon, 0.0D+i*2D,0.0D+i*2D,10.0D+i*2D,10.0D+i*2D, 0.001D, 0.0F, 0.0F, -1.0F); } } } else { if (aMetaData < CircuitImprintLoader.reverseIDs) ItemRenderer.renderItemIn2D(Tessellator.instance,tIcon.getMaxU(), tIcon.getMinV(), tIcon.getMinU(), tIcon.getMaxV(), tIcon.getIconWidth(), tIcon.getIconHeight(), 0.0625F); // else { // for (int i = 0; i < 4; i++) { // ItemRenderer.renderItemIn2D(Tessellator.instance, 0.0F+i*2F,0.0F+i*2F,10.0F+i*2F,10.0F+i*2F, tIcon.getIconWidth(), tIcon.getIconHeight(),0.0625F); // } // } // ItemRenderer.renderItemIn2D(Tessellator.instance, tIcon.getMaxU(), tIcon.getMinV(), tIcon.getMinU(), tIcon.getMaxV(), tIcon.getIconWidth(), tIcon.getIconHeight(), 0.0625F); } IIcon tOverlay = (IIcon) BW_Util.get2DCoordFrom1DArray(aMetaData, 1, 2, aItem.mIconList); GL11.glColor3f(1.0F, 1.0F, 1.0F); if (tOverlay != null) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); GL11.glBlendFunc(770, 771); if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { GT_RenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } else { ItemRenderer.renderItemIn2D(Tessellator.instance, tOverlay.getMaxU(), tOverlay.getMinV(), tOverlay.getMinU(), tOverlay.getMaxV(), tOverlay.getIconWidth(), tOverlay.getIconHeight(), 0.0625F); } } } GL11.glDisable(3042); } }
Example #7
Source File: HyperiumItemRenderer.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public HyperiumItemRenderer(ItemRenderer parent) { this.parent = parent; mc = Minecraft.getMinecraft(); }
Example #8
Source File: EssentialsMissingHandlerClient.java From Cyberware with MIT License | 4 votes |
private void renderItemInFirstPerson(float partialTicks) { ItemRenderer ir = mc.getItemRenderer(); AbstractClientPlayer abstractclientplayer = mc.thePlayer; float f = abstractclientplayer.getSwingProgress(partialTicks); EnumHand enumhand = (EnumHand)Objects.firstNonNull(abstractclientplayer.swingingHand, EnumHand.MAIN_HAND); float f1 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks; float f2 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks; boolean flag = true; boolean flag1 = true; if (abstractclientplayer.isHandActive()) { ItemStack itemstack = abstractclientplayer.getActiveItemStack(); if (itemstack != null && itemstack.getItem() == Items.BOW) //Forge: Data watcher can desync and cause this to NPE... { EnumHand enumhand1 = abstractclientplayer.getActiveHand(); flag = enumhand1 == EnumHand.MAIN_HAND; flag1 = !flag; } } rotateArroundXAndY(f1, f2); setLightmap(); rotateArm(partialTicks); GlStateManager.enableRescaleNormal(); ItemStack itemStackMainHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 3); ItemStack itemStackOffHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 4); float equippedProgressMainHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 5); float prevEquippedProgressMainHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 6); float equippedProgressOffHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 7); float prevEquippedProgressOffHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 8); RenderCyberlimbHand.INSTANCE.itemStackMainHand = itemStackMainHand; RenderCyberlimbHand.INSTANCE.itemStackOffHand = itemStackOffHand; if (flag && !missingSecondArm) { float f3 = enumhand == EnumHand.MAIN_HAND ? f : 0.0F; float f5 = 1.0F - (prevEquippedProgressMainHand + (equippedProgressMainHand - prevEquippedProgressMainHand) * partialTicks); RenderCyberlimbHand.INSTANCE.leftRobot = hasRoboLeft; RenderCyberlimbHand.INSTANCE.rightRobot = hasRoboRight; RenderCyberlimbHand.INSTANCE.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.MAIN_HAND, f3, itemStackMainHand, f5); } if (flag1 && !missingArm) { float f4 = enumhand == EnumHand.OFF_HAND ? f : 0.0F; float f6 = 1.0F - (prevEquippedProgressOffHand + (equippedProgressOffHand - prevEquippedProgressOffHand) * partialTicks); RenderCyberlimbHand.INSTANCE.leftRobot = hasRoboLeft; RenderCyberlimbHand.INSTANCE.rightRobot = hasRoboRight; RenderCyberlimbHand.INSTANCE.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.OFF_HAND, f4, itemStackOffHand, f6); } GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); }
Example #9
Source File: DryingRackBakedModel.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Nonnull @Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { List<BakedQuad> quads = Lists.newArrayList(); RenderType renderLayer = MinecraftForgeClient.getRenderLayer(); if (renderLayer == RenderType.getSolid()) { quads.addAll(rackBakedModel.getQuads(state, side, rand)); } else if (renderLayer == RenderType.getCutout() && side == null) { ItemRenderer renderItem = Minecraft.getInstance().getItemRenderer(); World world = Minecraft.getInstance().world; DryingRackItemsStateData items = extraData.getData(DryingRackTileEntity.CONTAINED_ITEMS_DATA); for (int i = 0; i < 4; i++) { ItemStack stack = items.stacks[i]; if (stack.isEmpty()) continue; MatrixStack matrixStack = new MatrixStack(); matrixStack.push(); // pushMatrix TransformationMatrix ct = itemTransforms[i]; matrixStack.getLast().getMatrix().mul(ct.getMatrix()); // current().getPositionMatrix().multiply(getPositionMatrix) matrixStack.getLast().getNormal().mul(ct.getNormalMatrix()); // current().getNormalMatrix().multiply IBakedModel model = renderItem.getItemModelWithOverrides(stack, world, null); if (stack.getItem() == Items.TRIDENT) { model = Minecraft.getInstance().getItemRenderer().getItemModelMesher().getModelManager().getModel(new ModelResourceLocation("minecraft:trident#inventory")); } model = model.handlePerspective(ItemCameraTransforms.TransformType.FIXED, matrixStack); if (!model.isBuiltInRenderer()) { @SuppressWarnings("unchecked") Map<Pair<IBakedModel, TransformationMatrix>, List<BakedQuad>> cache = caches.get(i); Matrix4f positionTransform = matrixStack.getLast().getMatrix(); // current() // getPositionMatrix TransformationMatrix transformMatrix = new TransformationMatrix(positionTransform); Pair<IBakedModel, TransformationMatrix> pair = Pair.of(model, transformMatrix); List<BakedQuad> cachedQuads = cache.get(pair); if (cachedQuads == null) { cachedQuads = Lists.newArrayList(); for (Direction face : faces) { List<BakedQuad> inQuads = model.getQuads(null, face, rand); List<BakedQuad> outQuads = new QuadTransformer(transformMatrix).processMany(inQuads); cachedQuads.addAll(outQuads); } cache.put(pair, cachedQuads); } quads.addAll(cachedQuads); } } } return quads; }
Example #10
Source File: DryingRackRenderer.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void render(DryingRackTileEntity te, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) { BlockState state = te.getWorld().getBlockState(te.getPos()); if (state.getBlock() != SurvivalistBlocks.RACK.get()) return; te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent((inv) -> { matrixStack.push(); // pushMatrix float angle = -state.get(DryingRackBlock.FACING).getHorizontalAngle(); matrixStack.translate(0.5, 0.5, 0.5); // translate matrixStack.rotate(Vector3f.YP.rotationDegrees(angle)); // rotate matrixStack.translate(-0.5, -0.5, -0.5); // translate //matrixStack.func_227863_a_(Vector3f.field_229183_f_.func_229187_a_(180)); Minecraft mc = Minecraft.getInstance(); ItemRenderer itemRenderer = mc.getItemRenderer(); for (int i = 0; i < 4; i++) { ItemStack stack = inv.getStackInSlot(i); if (stack.getCount() > 0) { matrixStack.push(); // pushMatrix float zz = (i - 1.5f) * 0.1875f; matrixStack.translate(0, 0, zz); // translate matrixStack.scale(0.7f, 0.7f, 0.7f); // scale matrixStack.translate(0.715, 0.93, 0.635); // translate matrixStack.rotate(Vector3f.YP.rotationDegrees(180)); // rotate IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(stack, te.getWorld(), (LivingEntity) null); itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, true, matrixStack, buffer, combinedLightIn, combinedOverlayIn, ibakedmodel); // renderItem matrixStack.pop(); // popMatrix } } matrixStack.pop(); // popMatrix }); }