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

The following examples show how to use net.minecraft.client.util.math.MatrixStack#push() . 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: LevitatingItemRenderer.java    From MineLittlePony with MIT License 6 votes vote down vote up
/**
 * 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 2
Source File: SpaceRaceScreen.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
private void renderButton(MatrixStack stack, TextRenderer textRenderer, Text text, int x, int y, int width, int height) {
    RenderSystem.disableBlend();
    stack.push();

    fillSolid(stack.peek().getModel(), x, y, x + width, y + height, 0x0);

    drawHorizontalLineSolid(stack, x, x + width, y, 0x2d2d2d);
    drawVerticalLineSolid(stack, x + width, y, y + height, 0x2d2d2d);
    drawHorizontalLineSolid(stack, x + width, x, y + height, 0x2d2d2d);
    drawVerticalLineSolid(stack, x, y, y + height, 0x2d2d2d);

    stack.pop();
    RenderSystem.enableBlend();

    textRenderer.draw(stack, text, x + (width / 2F) - (textRenderer.getWidth(text) / 2F), y + (height / 2F) - 4F, 0xffffff);
}
 
Example 3
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 4
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 5
Source File: CapeFeature.java    From MineLittlePony with MIT License 5 votes vote down vote up
@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 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: HallowedTreasureChestBlockEntityRenderer.java    From the-hallow with MIT License 5 votes vote down vote up
@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 8
Source File: HallowedCactusEntityRenderer.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public void render(RestlessCactusEntity entity, float yaw, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light) {
	BlockRenderManager manager = MinecraftClient.getInstance().getBlockRenderManager();
	BlockState state = HallowedBlocks.RESTLESS_CACTUS.getDefaultState();
	renderManager.textureManager.bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
	matrixStack.push();
	matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-yaw));
	matrixStack.translate(-0.5f, 0.0f, -0.5f);
	
	for (int i = 0; i < entity.getCactusHeight(); i++) {
		manager.renderBlockAsEntity(state, matrixStack, vertexConsumerProvider, light, OverlayTexture.DEFAULT_UV);
		matrixStack.translate(0.0F, 1.0F, 0.0F);
	}
	matrixStack.pop();
}
 
Example 9
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 10
Source File: SkullFeature.java    From MineLittlePony with MIT License 5 votes vote down vote up
@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.HEAD);
    if (!itemstack.isEmpty()) {
        M model = getContext().getModelWrapper().getBody();
        Item item = itemstack.getItem();

        stack.push();

        model.transform(BodyPart.HEAD, stack);
        model.getHead().rotate(stack);

        if (model instanceof AbstractPonyModel) {
            stack.translate(0, 0.225F, 0);
        } else {
            stack.translate(0, 0, 0.15F);
        }

        if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof AbstractSkullBlock) {
            boolean isVillager = entity instanceof VillagerDataContainer;

            renderSkull(stack, renderContext, itemstack, isVillager, limbDistance, lightUv);
        } else if (!(item instanceof ArmorItem) || ((ArmorItem)item).getSlotType() != EquipmentSlot.HEAD) {
            renderBlock(stack, renderContext, entity, itemstack, lightUv);
        }

        stack.pop();
    }

}
 
Example 11
Source File: PumpcownStemFeatureRenderer.java    From the-hallow with MIT License 5 votes vote down vote up
@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 12
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 13
Source File: SpaceRaceScreen.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
private void renderHoveredButton(MatrixStack stack, TextRenderer textRenderer, Text text, int x, int y, int width, int height) {
    RenderSystem.disableBlend();
    stack.push();

    fillSolid(stack.peek().getModel(), x, y, x + width, y + height, 0x1e1e1e);

    drawHorizontalLineSolid(stack, x, x + width, y, 0x3c3c3c);
    drawVerticalLineSolid(stack, x + width, y, y + height, 0x3c3c3c);
    drawHorizontalLineSolid(stack, x + width, x, y + height, 0x3c3c3c);
    drawVerticalLineSolid(stack, x, y, y + height, 0x3c3c3c);

    stack.pop();
    RenderSystem.enableBlend();

    textRenderer.draw(stack, text, x + (width / 2F) - (textRenderer.getWidth(text) / 2F), y + (height / 2F) - 4F, 0xffffff);
}
 
Example 14
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 15
Source File: BasicSolarPanelBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public void render(BasicSolarPanelBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
    light = WorldRenderer.getLightmapCoordinates(blockEntity.getWorld(), blockEntity.getPos().offset(Direction.UP, 3));
    renderBlock(blockEntity, tickDelta, matrices, vertexConsumers, light, overlay);
    MinecraftClient.getInstance().getTextureManager().bindTexture(BasicSolarPanelBlockEntityRenderer.solarPanelTexture);

    matrices.push();

    matrices.translate(0.5F, 1.0F, 0.5F);
    this.render(matrices, vertexConsumers.getBuffer(RenderLayer.getEntityCutout(solarPanelTexture)), light, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
    matrices.pop();
}
 
Example 16
Source File: EvolvedZombieModel.java    From Galacticraft-Rewoven with MIT License 4 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) {
        super.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
    } else {
        float ratio = 2.0F;
        matrices.push();
        matrices.scale(1.5F / ratio, 1.5F / ratio, 1.5F / ratio);
        matrices.translate(0.0F, 16.0F, 0.0F);
        this.head.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.oxygenMask.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);

        matrices.pop();
        matrices.push();
        matrices.scale(1.0F / ratio, 1.0F / ratio, 1.0F / ratio);
        matrices.translate(0.0F, 24.0F, 0.0F);
        this.oxygenTank0.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.oxygenTank1.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);

        this.torso.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.rightArm.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.leftArm.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.rightLeg.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.leftLeg.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        this.head.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        matrices.pop();
    }
}
 
Example 17
Source File: DJPon3Feature.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
    if ("deadmau5".equals(entity.getName().getString())) {
        stack.push();

        M body = getModelWrapper().getBody();

        body.transform(BodyPart.HEAD, stack);
        body.getHead().rotate(stack);

        stack.scale(1.3333334F, 1.3333334F, 1.3333334F);
        stack.translate(0, 0.3F, 0);

        deadMau5.setVisible(true);

        VertexConsumer vertices = renderContext.getBuffer(deadMau5.getLayer(entity.getSkinTexture()));

        deadMau5.render(stack, vertices, OverlayTexture.DEFAULT_UV, lightUv, limbDistance, limbAngle, tickDelta, 1);

        stack.pop();
    }
}
 
Example 18
Source File: AbstractPonyModel.java    From MineLittlePony with MIT License 4 votes vote down vote up
protected void renderStage(BodyPart part, MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, RenderStage action) {
    stack.push();
    transform(part, stack);
    action.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
    stack.pop();
}
 
Example 19
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 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;
}