- 9
- 0
пробовал делать вывод модельки, но голова начала дрожать, когда я пытался сделать следование за мышью, помогите плиз
java:
private void drawEntityInGui(PoseStack poseStack, int posX, int posY, int scale, float mouseX, float mouseY, Player entity, float partialTicks) {
poseStack.pushPose();
poseStack.translate(posX, posY, 1050.0F);
poseStack.scale((float) -scale, (float) scale, (float) scale);
Quaternionf rotation = new Quaternionf().rotateZ((float) Math.toRadians(180.0F));
poseStack.mulPose(rotation);
float originalYaw = entity.getYRot();
float originalHeadYaw = entity.yHeadRot;
float originalPitch = entity.getXRot();
entity.setYBodyRot(0.0F);
double deltaX = mouseX - 0.5;
double deltaY = mouseY - 0.5;
float headYaw = (float) (Math.atan2(deltaX, -deltaY) * (180.0 / Math.PI));
float headPitch = (float) (-Math.atan2(Math.sqrt(deltaX * deltaX + deltaY * deltaY), 1.0) * (180.0 / Math.PI));
entity.yHeadRot = headYaw;
entity.setXRot(headPitch);
Minecraft.getInstance().getEntityRenderDispatcher().render(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks, poseStack, this.minecraft.renderBuffers().bufferSource(), 15728880);
entity.setYRot(originalYaw);
entity.yHeadRot = originalHeadYaw;
entity.setXRot(originalPitch);
poseStack.popPose();
}