net.minecraft.client.renderer.model.ItemCameraTransforms Java Examples

The following examples show how to use net.minecraft.client.renderer.model.ItemCameraTransforms. 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: RenderUtilsLiving.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) {
	glSetup(x, y, z);
	
    GL11.glScaled(0.4*scale, 0.4*scale, 0);
    
    GL11.glTranslated(offX, offY, 0);
    if (item.getItem() instanceof BlockItem) GL11.glRotatef(180F, 1F, 180F, 10F);
    mc.getItemRenderer().renderItem(new ItemStack(item.getItem()), ItemCameraTransforms.TransformType.GUI);
    if (item.getItem() instanceof BlockItem) GL11.glRotatef(-180F, -1F, -180F, -10F);
    GL11.glDisable(GL11.GL_LIGHTING);
    
    GL11.glScalef(-0.05F, -0.05F, 0);
    
    if (item.getCount() > 0) {
	    int w = mc.fontRenderer.getStringWidth("x" + item.getCount()) / 2;
	    mc.fontRenderer.drawStringWithShadow("x" + item.getCount(), 7 - w, 5, 0xffffff);
    }
    
    GL11.glScalef(0.85F, 0.85F, 0.85F);
    
    int c = 0;
    for (Entry<Enchantment, Integer> m: EnchantmentHelper.getEnchantments(item).entrySet()) {
    	int w1 = mc.fontRenderer.getStringWidth(I18n.format(m.getKey().getName()).substring(0, 2) + m.getValue()) / 2;
    	mc.fontRenderer.drawStringWithShadow(
    			I18n.format(m.getKey().getName()).substring(0, 2) + m.getValue(), -4 - w1, c*10-1,
    			m.getKey() == Enchantments.VANISHING_CURSE || m.getKey() == Enchantments.BINDING_CURSE
    			? 0xff5050 : 0xffb0e0);
    	c--;
    }
    
    glCleanup();
}
 
Example #2
Source File: CCRenderItem.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void renderItem(ItemStack stack, ItemCameraTransforms.TransformType transformType, boolean leftHand, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay, IBakedModel modelIn) {
    if (modelIn instanceof IItemRenderer) {
        mStack.push();
        IBakedModel handled = ForgeHooksClient.handleCameraTransforms(mStack, modelIn, transformType, leftHand);
        mStack.translate(-0.5D, -0.5D, -0.5D);
        //If anyone doesnt return an IItemRenderer from here, your doing it wrong.
        ((IItemRenderer) handled).renderItem(stack, transformType, mStack, getter, packedLight, packedOverlay);
        mStack.pop();
    }
    super.renderItem(stack, transformType, leftHand, mStack, getter, packedLight, packedOverlay, modelIn);
}
 
Example #3
Source File: ChoppingBlockRenderer.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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: DryingRackRenderer.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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
    });
}