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

The following examples show how to use net.minecraft.client.util.math.MatrixStack#pop() . 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: 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 2
Source File: HeldItemFeature.java    From MineLittlePony with MIT License 6 votes vote down vote up
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: IllagerPonyRenderer.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Override
public void render(IllusionerEntity entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
    if (entity.isInvisible()) {
        Vec3d[] clones = entity.method_7065(tickDelta);
        float rotation = getAnimationProgress(entity, tickDelta);

        for (int i = 0; i < clones.length; ++i) {
            stack.push();
            stack.translate(
                    clones[i].x + MathHelper.cos(i + rotation * 0.5F) * 0.025D,
                    clones[i].y + MathHelper.cos(i + rotation * 0.75F) * 0.0125D,
                    clones[i].z + MathHelper.cos(i + rotation * 0.7F) * 0.025D
            );
            super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
            stack.pop();
        }
    } else {
        super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
    }
}
 
Example 4
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 5
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
protected void renderLabelIfPresent(AbstractClientPlayerEntity entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
    stack.push();

    if (entity.isSleeping()) {
        if (entity.getSleepingPosition().isPresent() && entity.getEntityWorld().getBlockState(entity.getSleepingPosition().get()).getBlock() instanceof BedBlock) {
            double bedRad = Math.toRadians(entity.getSleepingDirection().asRotation());

            stack.translate(Math.cos(bedRad), 0, -Math.sin(bedRad));
        }
    }
    stack.translate(0, manager.getNamePlateYOffset(entity), 0);
    super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
    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: 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 8
Source File: WLabeledSlider.java    From LibGui with MIT License 5 votes vote down vote up
@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 9
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 10
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 11
Source File: GearFeature.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) {

    if (entity.isInvisible()) {
        return;
    }

    M model = getModelWrapper().getBody();

    Map<BodyPart, Float> renderStackingOffsets = new HashMap<>();

    for (Map.Entry<Wearable, IGear> entry : gears.entrySet()) {
        Wearable wearable = entry.getKey();
        IGear gear = entry.getValue();

        if (getContext().shouldRender(model, entity, wearable, gear)) {
            stack.push();
            model.transform(gear.getGearLocation(), stack);
            model.getBodyPart(gear.getGearLocation()).rotate(stack);

            if (gear instanceof IStackable) {
                BodyPart part = gear.getGearLocation();
                renderStackingOffsets.compute(part, (k, v) -> {
                    float offset = ((IStackable)gear).getStackingOffset();
                    if (v != null) {
                        stack.translate(0, -v, 0);
                        offset += v;
                    }
                    return offset;
                });
            }

            renderGear(model, entity, gear, stack, renderContext, lightUv, limbDistance, limbAngle, tickDelta);
            stack.pop();
        }
    }
}
 
Example 12
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 13
Source File: InfusionAltarBlockEntityRenderer.java    From the-hallow with MIT License 5 votes vote down vote up
@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 14
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 15
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 16
Source File: UnicornModel.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
    super.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);

    if (hasHorn() && canCast() && isCasting()) {
        stack.push();
        transform(BodyPart.HEAD, stack);
        head.rotate(stack);
        horn.renderMagic(stack, vertices, getMagicColor());
        stack.pop();
    }
}
 
Example 17
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 18
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 19
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 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;
}