net.minecraft.client.render.item.ItemRenderer Java Examples
The following examples show how to use
net.minecraft.client.render.item.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: SkirtCostumeItem.java From the-hallow with MIT License | 6 votes |
@Override @Environment(EnvType.CLIENT) public void render(String slot, MatrixStack matrix, VertexConsumerProvider vertexConsumer, int light, PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity player, float headYaw, float headPitch) { ItemRenderer renderer = MinecraftClient.getInstance().getItemRenderer(); matrix.push(); translateToChest(model, player, headYaw, headPitch, matrix); //TODO switch back to trinkets version once it's fixed matrix.push(); matrix.translate(0.25, 0.65, 0); matrix.scale(0.5F, 0.5F, 0.5F); matrix.multiply(ROTATION_CONSTANT); renderer.renderItem(new ItemStack(Items.BLAZE_ROD), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer); matrix.pop(); matrix.push(); matrix.translate(-0.25, 0.65, 0); matrix.scale(0.5F, 0.5F, 0.5F); matrix.multiply(ROTATION_CONSTANT); renderer.renderItem(new ItemStack(Items.BLAZE_ROD), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer); matrix.pop(); matrix.push(); matrix.translate(0, 0.65, 0.325); matrix.scale(0.5F, 0.5F, 0.5F); matrix.multiply(ROTATION_CONSTANT); renderer.renderItem(new ItemStack(Items.BLAZE_ROD), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer); matrix.pop(); matrix.pop(); }
Example #2
Source File: TinyPumpkinRenderer.java From the-hallow with MIT License | 6 votes |
@Override public void render(TinyPumpkinBlockEntity pumpkin, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) { ItemRenderer renderer = MinecraftClient.getInstance().getItemRenderer(); matrixStack.push(); matrixStack.translate(0.5, 0.275, 0.5); matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(360 - pumpkin.getCachedState().get(HorizontalFacingBlock.FACING).asRotation())); matrixStack.multiply(NINETY_DEG_X); matrixStack.scale(0.75f, 0.75f, 0.75f); matrixStack.push(); matrixStack.translate(0.25, 0, 0); matrixStack.multiply(MINUS_NINETY_DEG_Y); renderer.renderItem(pumpkin.getLeftItem(), ModelTransformation.Mode.FIXED, i, j, matrixStack, vertexConsumerProvider); matrixStack.pop(); matrixStack.push(); matrixStack.translate(-0.25, 0, 0); matrixStack.multiply(MINUS_NINETY_DEG_Y); renderer.renderItem(pumpkin.getRightItem(), ModelTransformation.Mode.FIXED, i, j, matrixStack, vertexConsumerProvider); matrixStack.pop(); matrixStack.pop(); }
Example #3
Source File: LevitatingItemRenderer.java From MineLittlePony with MIT License | 6 votes |
/** * Renders a magical overlay over an item in third person. */ public void renderItemGlow(LivingEntity entity, ItemStack drop, ModelTransformation.Mode transform, Arm hand, int glowColor, MatrixStack stack, VertexConsumerProvider renderContext) { setColor(glowColor); stack.push(); ItemRenderer renderItem = MinecraftClient.getInstance().getItemRenderer(); stack.scale(1.1F, 1.1F, 1.1F); stack.translate(0.01F, 0.01F, 0.01F); renderItem.renderItem(entity, drop, transform, hand == Arm.LEFT, stack, renderContext, entity.world, 0x0F00F0, OverlayTexture.DEFAULT_UV); stack.translate(-0.02F, -0.02F, -0.02F); renderItem.renderItem(entity, drop, transform, hand == Arm.LEFT, stack, renderContext, entity.world, 0x0F00F0, OverlayTexture.DEFAULT_UV); stack.pop(); unsetColor(); }
Example #4
Source File: ElytraFeature.java From MineLittlePony with MIT License | 6 votes |
@Override public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) { ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.CHEST); if (itemstack.getItem() == Items.ELYTRA) { stack.push(); preRenderCallback(stack); EntityModel<T> elytra = getElytraModel(); getContextModel().copyStateTo(elytra); if (elytra instanceof PonyElytra) { ((PonyElytra<T>)elytra).isSneaking = getContext().getEntityPony(entity).isCrouching(entity); } elytra.setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch); VertexConsumer vertexConsumer = ItemRenderer.method_29711(renderContext, modelElytra.getLayer(getElytraTexture(entity)), false, itemstack.hasEnchantmentGlint()); modelElytra.render(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1); stack.pop(); } }
Example #5
Source File: ArmourFeature.java From MineLittlePony with MIT License | 6 votes |
private static <T extends LivingEntity, V extends BipedEntityModel<T> & IArmour> void renderArmourPart( MatrixStack matrices, VertexConsumerProvider provider, int light, boolean glint, V model, float r, float g, float b, IArmourTextureResolver<T> resolver, ArmourLayer layer, Identifier texture) { VertexConsumer vertices = ItemRenderer.method_27952(provider, RenderLayer.getArmorCutoutNoCull(texture), false, glint); model.setVariant(resolver.getArmourVariant(layer, texture)); model.render(matrices, vertices, light, OverlayTexture.DEFAULT_UV, r, g, b, 1); }
Example #6
Source File: HallowCharmItem.java From the-hallow with MIT License | 5 votes |
@Override public void render(String slot, MatrixStack matrix, VertexConsumerProvider vertexConsumer, int light, PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity player, float headYaw, float headPitch) { ItemRenderer renderer = MinecraftClient.getInstance().getItemRenderer(); matrix.push(); translateToChest(model, player, headYaw, headPitch, matrix); //TODO switch back to trinkets version once it's fixed matrix.translate(0, -0.15, 0); matrix.scale(0.5F, 0.5F, 0.5F); matrix.multiply(ROTATION_CONSTANT); renderer.renderItem(new ItemStack(HallowedItems.HALLOW_CHARM), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer); matrix.pop(); }
Example #7
Source File: InfusionAltarBlockEntityRenderer.java From the-hallow with MIT License | 5 votes |
@Override public void render(InfusionAltarBlockEntity altar, float partialTicks, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) { ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer(); if (!altar.storedStack.isEmpty()) { matrixStack.push(); matrixStack.translate(0.5, 1.25 + MathHelper.sin(rotation / 2) / 32, 0.5); matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation * 2)); matrixStack.scale(0.5f, 0.5f, 0.5f); itemRenderer.renderItem(altar.storedStack, ModelTransformation.Mode.FIXED, i, j, matrixStack, vertexConsumerProvider); matrixStack.pop(); } nanosA = System.nanoTime(); if ((nanosA - nanosB) / 1000000 > 16) { nanosB = System.nanoTime(); if (rotationMode) { rotation += 0.16; if (rotation >= 360) { rotationMode = !rotationMode; } } else { rotation += 0.16; if (rotation <= 0) { rotationMode = !rotationMode; } } } }
Example #8
Source File: InfusionPillarBlockEntityRenderer.java From the-hallow with MIT License | 5 votes |
@Override public void render(InfusionPillarBlockEntity pillar, float partialTicks, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) { ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer(); if (!pillar.storedStack.isEmpty()) { matrixStack.push(); matrixStack.translate(0.5, 1.25 + MathHelper.sin(rotation / 2) / 32, 0.5); matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation * 2)); matrixStack.scale(0.5f, 0.5f, 0.5f); itemRenderer.renderItem(pillar.storedStack, ModelTransformation.Mode.FIXED, i, j, matrixStack, vertexConsumerProvider); matrixStack.pop(); } nanosA = System.nanoTime(); if ((nanosA - nanosB) / 1000000 > 16) { nanosB = System.nanoTime(); if (rotationMode) { rotation += 0.16; if (rotation >= 360) { rotationMode = !rotationMode; } } else { rotation += 0.16; if (rotation <= 0) { rotationMode = !rotationMode; } } } }
Example #9
Source File: WItem.java From LibGui with MIT License | 5 votes |
@Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { RenderSystem.enableDepthTest(); MinecraftClient mc = MinecraftClient.getInstance(); ItemRenderer renderer = mc.getItemRenderer(); renderer.zOffset = 100f; renderer.renderInGui(items.get(current), x + getWidth() / 2 - 9, y + getHeight() / 2 - 9); renderer.zOffset = 0f; }
Example #10
Source File: LevitatingItemRenderer.java From MineLittlePony with MIT License | 5 votes |
/** * Renders an item in first person optionally with a magical overlay. */ public void renderItemInFirstPerson(ItemRenderer itemRenderer, @Nullable LivingEntity entity, ItemStack stack, ModelTransformation.Mode transform, boolean left, MatrixStack matrix, VertexConsumerProvider renderContext, @Nullable World world, int lightUv) { if (entity instanceof PlayerEntity) { IPony pony = MineLittlePony.getInstance().getManager().getPony((PlayerEntity)entity); matrix.push(); boolean doMagic = MineLittlePony.getInstance().getConfig().fpsmagic.get() && pony.getMetadata().hasMagic(); if (doMagic) { setupPerspective(itemRenderer, entity, stack, left, matrix); } itemRenderer.renderItem(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV); if (doMagic) { setColor(pony.getMetadata().getGlowColor()); matrix.scale(1.1F, 1.1F, 1.1F); matrix.translate(0.015F, 0.01F, 0.01F); itemRenderer.renderItem(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV); matrix.translate(-0.03F, -0.02F, -0.02F); itemRenderer.renderItem(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV); unsetColor(); } matrix.pop(); } else { itemRenderer.renderItem(entity, stack, transform, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV); } }
Example #11
Source File: LevitatingItemRenderer.java From MineLittlePony with MIT License | 5 votes |
/** * Moves held items to look like they're floating in the player's field. */ private void setupPerspective(ItemRenderer renderer, LivingEntity entity, ItemStack item, boolean left, MatrixStack stack) { UseAction action = item.getUseAction(); boolean doNormal = entity.getItemUseTime() <= 0 || action == UseAction.NONE || action == UseAction.CROSSBOW; if (doNormal) { // eating, blocking, and drinking are not transformed. Only held items. int sign = left ? 1 : -1; float ticks = entity.age * sign; float floatAmount = -(float)Math.sin(ticks / 9F) / 40F; float driftAmount = -(float)Math.cos(ticks / 6F) / 40F; boolean handHeldTool = action == UseAction.BOW || action == UseAction.CROSSBOW || action == UseAction.BLOCK; float distanceChange = handHeldTool ? -0.3F : -0.6F; stack.translate( driftAmount - floatAmount / 4F + distanceChange / 1.5F * sign, floatAmount, distanceChange); if (!handHeldTool) { // bows have to point forwards stack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(sign * -60 + floatAmount)); stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(sign * 30 + driftAmount)); } } }