Java Code Examples for net.minecraft.client.util.math.MatrixStack#scale()

The following examples show how to use net.minecraft.client.util.math.MatrixStack#scale() . 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 vote down vote up
@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: HallowedTreasureChestEntityRenderer.java    From the-hallow with MIT License 6 votes vote down vote up
@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 3
Source File: TinyPumpkinRenderer.java    From the-hallow with MIT License 6 votes vote down vote up
@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: EvolvedCreeperEntityRenderer.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
protected void scale(EvolvedCreeperEntity entity, MatrixStack matrices, float tickDelta) {
    float g = entity.getClientFuseTime(tickDelta);
    float h = 1.0F + MathHelper.sin(g * 100.0F) * g * 0.01F;
    g = MathHelper.clamp(g, 0.0F, 1.0F);
    g *= g;
    g *= g;
    float i = (1.0F + g * 0.4F) * h;
    float j = (1.0F + g * 0.1F) / h;
    matrices.scale(i, j, i);
}
 
Example 5
Source File: SkullFeature.java    From MineLittlePony with MIT License 5 votes vote down vote up
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 6
Source File: LevitatingItemRenderer.java    From MineLittlePony with MIT License 5 votes vote down vote up
/**
 * 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 7
Source File: EquineRenderManager.java    From MineLittlePony with MIT License 5 votes vote down vote up
public void preRenderCallback(T entity, MatrixStack stack, float ticks) {
    updateModel(entity, Mode.THIRD_PERSON);

    float s = getScaleFactor();
    stack.scale(s, s, s);
    enableModelRenderProfile(skipBlend);

    translateRider(entity, stack, ticks);
}
 
Example 8
Source File: InfusionPillarBlockEntityRenderer.java    From the-hallow with MIT License 5 votes vote down vote up
@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: BatWings.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
    stack.push();
    stack.scale(1.3F, 1.3F, 1.3F);

    super.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, interpolatorId);

    stack.pop();
}
 
Example 10
Source File: EvolvedCreeperEntityModel.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
    if (!this.child) {
        this.body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.oxygenMask.render(matrices, vertexConsumer, light, overlay);
        this.leg3.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.leg1.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.oxygenTank1.render(matrices, vertexConsumer, light, overlay);
        this.creeperArmor.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.head.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.leg4.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.leg2.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
    } else {
        matrices.push();
        matrices.scale(0.75f, 0.75f, 0.75f);
        matrices.translate(0.0F, 1.0F, 0.0F);
        this.head.render(matrices, vertexConsumer, light, overlay);
        this.oxygenMask.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        matrices.pop();
        matrices.push();
        matrices.scale(0.5f, 0.5f, 0.5f);
        matrices.translate(0.0F, 1.52083F, 0.0F);
        this.body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.leg3.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.leg1.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.oxygenTank1.render(matrices, vertexConsumer, light, overlay);
        this.creeperArmor.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.leg4.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.leg2.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        matrices.pop();
    }
}
 
Example 11
Source File: MoonVillagerRenderer.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
protected void scale(VillagerEntity villagerEntity, MatrixStack matrixStack, float f) {
    float g = 0.9375F;
    if (villagerEntity.isBaby()) {
        g = (float) ((double) g * 0.5D);
        this.shadowRadius = 0.25F;
    } else {
        this.shadowRadius = 0.5F;
    }

    matrixStack.scale(g, g, g);
}
 
Example 12
Source File: ZomponyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public void scale(HuskEntity entity, MatrixStack stack, float ticks) {
    super.scale(entity, stack, ticks);
    stack.scale(1.0625F, 1.0625F, 1.0625F);
}
 
Example 13
Source File: IllagerPonyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public void scale(T entity, MatrixStack stack, float ticks) {
    super.scale(entity, stack, ticks);
    stack.scale(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE);
}
 
Example 14
Source File: ZomponyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public void scale(GiantEntity entity, MatrixStack stack, float ticks) {
       super.scale(entity, stack, ticks);
       stack.scale(3, 3, 3);
   }
 
Example 15
Source File: EntityRendererMixin.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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 16
Source File: SkeleponyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public void scale(WitherSkeletonEntity skeleton, MatrixStack stack, float ticks) {
    super.scale(skeleton, stack, ticks);
    stack.scale(1.2F, 1.2F, 1.2F);
}
 
Example 17
Source File: AbstractPonyModel.java    From MineLittlePony with MIT License 4 votes vote down vote up
protected void renderNeck(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
    stack.scale(0.9F, 0.9F, 0.9F);
    neck.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
}
 
Example 18
Source File: VexRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
protected void scale(VexEntity entity, MatrixStack stack, float ticks) {
    stack.scale(0.4F, 0.4F, 0.4F);
}
 
Example 19
Source File: WitchRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public void scale(WitchEntity entity, MatrixStack stack, float ticks) {
    super.scale(entity, stack, ticks);
    stack.scale(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE);
}
 
Example 20
Source File: PonySkullRenderer.java    From MineLittlePony with MIT License 3 votes vote down vote up
boolean renderSkull(@Nullable Direction direction, float angle,
        SkullBlock.SkullType skullType, @Nullable GameProfile profile, float poweredTicks,
        MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {

    ISkull skull = skullMap.get(skullType);

    if (skull == null || !skull.canRender(MineLittlePony.getInstance().getConfig())) {
        return false;
    }

    Identifier skin = skull.getSkinResource(profile);

    skull.bindPony(MineLittlePony.getInstance().getManager().getPony(skin));

    stack.push();

    handleRotation(stack, direction);

    stack.scale(-1, -1, 1);

    VertexConsumer vertices = renderContext.getBuffer(LevitatingItemRenderer.getRenderLayer(skin));

    skull.setAngles(angle, poweredTicks);
    skull.render(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);

    stack.pop();

    return true;
}