Java Code Examples for net.minecraft.client.util.math.MatrixStack#multiply()
The following examples show how to use
net.minecraft.client.util.math.MatrixStack#multiply() .
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: HeldItemFeature.java From MineLittlePony with MIT License | 6 votes |
private void renderHeldItem(T entity, ItemStack drop, ModelTransformation.Mode transform, Arm arm, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) { if (!drop.isEmpty()) { stack.push(); renderArm(arm, stack); if (getContextModel().getAttributes().isCrouching) { stack.translate(0, 0.2F, 0); } float left = arm == Arm.LEFT ? 1 : -1; if (entity.hasVehicle()) { stack.translate(left / 10, -0.2F, -0.5F); } stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90)); stack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(left * 180)); stack.translate(left * -0.2F, 0, 0); preItemRender(entity, drop, transform, arm, stack); MinecraftClient.getInstance().getItemRenderer().renderItem(entity, drop, transform, arm == Arm.LEFT, stack, renderContext, entity.world, lightUv, OverlayTexture.DEFAULT_UV); postItemRender(entity, drop, transform, arm, stack, renderContext); stack.pop(); } }
Example 3
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 4
Source File: HallowedTreasureChestEntityRenderer.java From the-hallow with MIT License | 6 votes |
@Override public void render(HallowedTreasureChestEntity chest, float yaw, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light) { matrixStack.push(); // initial size and position matrixStack.translate(-0.275, 0.57, 0.275); matrixStack.multiply(INITIAL_ROTATION_X); matrixStack.scale(0.57f, 0.57f, 0.57f); // calculate interpolated render rotation from last rotation float interpolated = chest.previousRotation + (chest.rotation - chest.previousRotation) * tickDelta; matrixStack.translate(0.5, 0.5, 0.5); matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(interpolated)); matrixStack.translate(-0.5, -0.5, -0.5); // jiggle after finishing spin if (chest.getEndProgress() != 0) { matrixStack.translate(0.5, 0.5, 0.5); matrixStack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion((float) MathHelper.sin(chest.getEndProgress()))); matrixStack.translate(-0.5f, -0.5f, -0.5f); } // render chest updateHingeProgress(chest, chestModel); chestModel.render(matrixStack, vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutout(TEXTURE)), light, OverlayTexture.DEFAULT_UV, 1f, 1f, 1f, 1f); // finish matrixStack.pop(); }
Example 5
Source File: PlayerPonyRenderer.java From MineLittlePony with MIT License | 6 votes |
@Override public void render(AbstractClientPlayerEntity entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) { shadowRadius = manager.getShadowScale(); super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv); DebugBoundingBoxRenderer.render(manager.getPony(entity), this, entity, stack, renderContext, tickDelta); // Translate the shadow position after everything is done // (shadows are drawn after us) if (!entity.hasVehicle() && !entity.isSleeping()) { float yaw = MathHelper.lerpAngleDegrees(tickDelta, entity.prevBodyYaw, entity.bodyYaw); float l = entity.getWidth() / 2 * manager.getPony(entity).getMetadata().getSize().getScaleFactor(); stack.multiply(Vector3f.NEGATIVE_Y.getDegreesQuaternion(yaw)); stack.translate(0, 0, -l); } }
Example 6
Source File: AbstractPonyModel.java From MineLittlePony with MIT License | 5 votes |
@Override public void transform(BodyPart part, MatrixStack stack) { if (attributes.isSleeping) { stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); stack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180)); } if (part == BodyPart.HEAD) { stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(attributes.motionPitch)); } PonyTransformation.forSize(getSize()).transform(this, part, stack); }
Example 7
Source File: SkullFeature.java From MineLittlePony with MIT License | 5 votes |
private void renderBlock(MatrixStack stack, VertexConsumerProvider renderContext, T entity, ItemStack itemstack, int lightUv) { stack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180)); stack.scale(0.625F, -0.625F, -0.625F); stack.translate(0, 0.6F, -0.21F); MinecraftClient.getInstance().getHeldItemRenderer().renderItem(entity, itemstack, ModelTransformation.Mode.HEAD, false, stack, renderContext, lightUv); }
Example 8
Source File: CapeFeature.java From MineLittlePony with MIT License | 5 votes |
@Override public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) { M model = getContextModel(); if (player.hasSkinTexture() && !player.isInvisible() && player.isPartVisible(PlayerModelPart.CAPE) && player.getCapeTexture() != null && player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) { stack.push(); model.transform(BodyPart.BODY, stack); stack.translate(0, 0.24F, 0); model.getBodyPart(BodyPart.BODY).rotate(stack); double capeX = MathHelper.lerp(tickDelta, player.capeX, player.prevCapeX) - MathHelper.lerp(tickDelta, player.prevX, player.getX()); double capeY = MathHelper.lerp(tickDelta, player.capeY, player.prevCapeY) - MathHelper.lerp(tickDelta, player.prevY, player.getY()); double capeZ = MathHelper.lerp(tickDelta, player.capeZ, player.prevCapeZ) - MathHelper.lerp(tickDelta, player.prevZ, player.getZ()); float motionYaw = player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw); double sin = MathHelper.sin(motionYaw * PI / 180); double cos = (-MathHelper.cos(motionYaw * PI / 180)); float capeMotionY = (float) capeY * 10; if (capeMotionY < -6) capeMotionY = -6; if (capeMotionY > 32) capeMotionY = 32; float capeMotionX = (float) (capeX * sin + capeZ * cos) * 100; float diagMotion = (float) (capeX * cos - capeZ * sin) * 100; if (capeMotionX < 0) capeMotionX = 0; float camera = MathHelper.lerp(tickDelta, player.prevStrideDistance, player.strideDistance); capeMotionY += MathHelper.sin(MathHelper.lerp(tickDelta, player.prevHorizontalSpeed, player.horizontalSpeed) * 6) * 32 * camera; stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(2 + capeMotionX / 12 + capeMotionY)); stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion( diagMotion / 2)); stack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-diagMotion / 2)); stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180)); stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); VertexConsumer vertices = renderContext.getBuffer(RenderLayer.getEntitySolid(player.getCapeTexture())); model.renderCape(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV); stack.pop(); } }
Example 9
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)); } } }
Example 10
Source File: WitchRenderer.java From MineLittlePony with MIT License | 5 votes |
@Override protected HeldItemFeature<WitchEntity, WitchPonyModel> createItemHoldingLayer() { return new HeldItemFeature<WitchEntity, WitchPonyModel>(this) { @Override protected void preItemRender(WitchEntity entity, ItemStack drop, ModelTransformation.Mode transform, Arm hand, MatrixStack stack) { stack.translate(0, -0.3F, -0.8F); stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(10)); } }; }
Example 11
Source File: WLabeledSlider.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) { int aWidth = axis == Axis.HORIZONTAL ? width : height; int aHeight = axis == Axis.HORIZONTAL ? height : width; int rotMouseX = axis == Axis.HORIZONTAL ? (direction == Direction.LEFT ? width - mouseX : mouseX) : (direction == Direction.UP ? height - mouseY : mouseY); int rotMouseY = axis == Axis.HORIZONTAL ? mouseY : mouseX; matrices.push(); matrices.translate(x, y, 0); if (axis == Axis.VERTICAL) { matrices.translate(0, height, 0); matrices.multiply(ROTATION_Z_270); } drawButton(0, 0, 0, aWidth); // 1: regular, 2: hovered, 0: disabled/dragging int thumbX = Math.round(coordToValueRatio * (value - min)); int thumbY = 0; int thumbWidth = getThumbWidth(); int thumbHeight = aHeight; boolean hovering = rotMouseX >= thumbX && rotMouseX <= thumbX + thumbWidth && rotMouseY >= thumbY && rotMouseY <= thumbY + thumbHeight; int thumbState = dragging || hovering ? 2 : 1; drawButton(thumbX, thumbY, thumbState, thumbWidth); if (thumbState == 1 && isFocused()) { float px = 1 / 32f; ScreenDrawing.texturedRect(thumbX, thumbY, thumbWidth, thumbHeight, WSlider.LIGHT_TEXTURE, 24*px, 0*px, 32*px, 20*px, 0xFFFFFFFF); } if (label != null) { int color = isMouseInsideBounds(mouseX, mouseY) ? 0xFFFFA0 : 0xE0E0E0; ScreenDrawing.drawStringWithShadow(matrices, label, labelAlignment, 2, aHeight / 2 - 4, aWidth - 4, color); } matrices.pop(); }
Example 12
Source File: HallowedTreasureChestBlockEntityRenderer.java From the-hallow with MIT License | 5 votes |
@Override public void render(HallowedTreasureChestBlockEntity treasureChest, float partialTicks, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) { matrixStack.push(); BlockState state; if(treasureChest.hasWorld()) { state = treasureChest.getCachedState(); } else { state = HallowedBlocks.HALLOWED_TREASURE_CHEST.getDefaultState(); } // initial translation to center chest -- default renders upside down. matrixStack.multiply(RIGHTSIDE_UP); matrixStack.translate(0.215, -0.57, -0.215); // rotate based on facing direction if (state.contains(HallowedTreasureChestBlock.FACING)) { switch (state.get(HallowedTreasureChestBlock.FACING)) { case NORTH: matrixStack.translate(0.57, 0, 0); matrixStack.multiply(SOUTH_ROTATION_QUAT); break; case EAST: matrixStack.translate(0.57, 0, -0.57); matrixStack.multiply(EAST_ROTATION_QUAT); break; case SOUTH: matrixStack.translate(0, 0, -0.57); matrixStack.multiply(NORTH_ROTATION_QUAT); break; case WEST: matrixStack.multiply(WEST_ROTATION_QUAT); break; default: break; } } // flip & scale to size matrixStack.multiply(NORTH_ROTATION_QUAT); matrixStack.scale(0.57f, 0.57f, 0.57f); // render chest chestModel.render(matrixStack, vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutout(TEXTURE)), i, j, 1f, 1f, 1f, 1f); matrixStack.pop(); }
Example 13
Source File: BasicSolarPanelBlockEntityRenderer.java From Galacticraft-Rewoven with MIT License | 5 votes |
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { this.pole.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha); matrices.translate(0.0F, 1.5F, 0.0F); matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180.0F)); matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90.0F)); this.renderPanel(matrices, vertexConsumer, light, overlay, red, green, blue, alpha); }
Example 14
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 15
Source File: PumpcownStemFeatureRenderer.java From the-hallow with MIT License | 5 votes |
@Override public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, PumpcownEntity pumpcown, float f, float g, float tickDelta, float h, float j, float k) { if (!pumpcown.isBaby() && !pumpcown.isInvisible()) { BlockRenderManager blockRenderManager = MinecraftClient.getInstance().getBlockRenderManager(); BlockState blockState = PumpcownEntity.STEM_FEATURE; int m = LivingEntityRenderer.getOverlay(pumpcown, 0.0F); matrixStack.push(); matrixStack.translate(0.2, -0.35, 0.5); matrixStack.multiply(MINUS_48_YAW); matrixStack.scale(-1.0F, -1.0F, 1.0F); matrixStack.translate(-0.5, -0.5, -0.5); blockRenderManager.renderBlockAsEntity(blockState, matrixStack, vertexConsumerProvider, i, m); matrixStack.pop(); matrixStack.push(); matrixStack.translate(0.2, -0.35, 0.5); matrixStack.multiply(PLUS_48_YAW); matrixStack.translate(0.1, 0, -0.6); matrixStack.multiply(MINUS_48_YAW); matrixStack.scale(-1.0F, -1.0F, 1.0F); matrixStack.translate(-0.5, -0.5, -0.5); blockRenderManager.renderBlockAsEntity(blockState, matrixStack, vertexConsumerProvider, i, m); matrixStack.pop(); matrixStack.push(); ((CowEntityModel)this.getContextModel()).getHead().rotate(matrixStack); matrixStack.translate(0, -0.7, -0.2); matrixStack.multiply(MINUS_78_YAW); matrixStack.scale(-1.0F, -1.0F, 1.0F); matrixStack.translate(-0.5, -0.5, -0.5); blockRenderManager.renderBlockAsEntity(blockState, matrixStack, vertexConsumerProvider, i, m); matrixStack.pop(); } }
Example 16
Source File: SkirtCostumeItem.java From the-hallow with MIT License | 5 votes |
public static void translateToChest(PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity player, float headYaw, float headPitch, MatrixStack matrix) { if (player.isInSneakingPose() && !model.riding && !player.isSwimming()) { matrix.translate(0, 0.2, 0); matrix.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(model.torso.pitch * 57.5f)); } matrix.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(model.torso.yaw * 57.5f)); matrix.translate(0, 0.4, -0.16); }
Example 17
Source File: HallowCharmItem.java From the-hallow with MIT License | 5 votes |
public static void translateToChest(PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity player, float headYaw, float headPitch, MatrixStack matrix) { if (player.isInSneakingPose() && !model.riding && !player.isSwimming()) { matrix.translate(0, 0.2, 0); matrix.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(model.torso.pitch * 57.5f)); } matrix.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(model.torso.yaw * 57.5f)); matrix.translate(0, 0.4, -0.16); }
Example 18
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 19
Source File: EntityRendererMixin.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
/** * Copy of renderLabelIfPresent() since calling the original would result in * an infinite loop. Also makes it easier to modify. */ protected void wurstRenderLabelIfPresent(T entity, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { double d = this.dispatcher.getSquaredDistanceToCamera(entity); if(d > 4096) return; NameTagsHack nameTagsHack = WurstClient.INSTANCE.getHax().nameTagsHack; boolean bl = !entity.isSneaky() || nameTagsHack.isEnabled(); float f = entity.getHeight() + 0.5F; int j = "deadmau5".equals(text.getString()) ? -10 : 0; matrixStack.push(); matrixStack.translate(0.0D, f, 0.0D); matrixStack.multiply(this.dispatcher.getRotation()); float scale = 0.025F; if(nameTagsHack.isEnabled()) { double distance = WurstClient.MC.player.distanceTo(entity); if(distance > 10) scale *= distance / 10; } matrixStack.scale(-scale, -scale, scale); Matrix4f matrix4f = matrixStack.peek().getModel(); float g = WurstClient.MC.options.getTextBackgroundOpacity(0.25F); int k = (int)(g * 255.0F) << 24; TextRenderer textRenderer = this.getFontRenderer(); float h = -textRenderer.getWidth(text) / 2; textRenderer.draw(text, h, j, 553648127, false, matrix4f, vertexConsumerProvider, bl, k, i); if(bl) textRenderer.draw(text, h, j, -1, false, matrix4f, vertexConsumerProvider, false, 0, i); matrixStack.pop(); }
Example 20
Source File: PostureElytra.java From MineLittlePony with MIT License | 4 votes |
@Override public void transform(IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float ticks) { stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); stack.translate(0, model.getAttributes().isCrouching ? 0.2F : -1, 0); }