Skip to content

Commit

Permalink
fix xp orbs and other player facing stuff, as well as nametags with f…
Browse files Browse the repository at this point in the history
…igura
  • Loading branch information
fayer3 committed Jul 23, 2024
1 parent 6c61121 commit d124dc2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public interface EntityRenderDispatcherVRExtension {

Quaternionf vivecraft$getCameraOrientationOffset(float offset);
Quaternionf vivecraft$getCameraOrientation(float scale, float offset);

Map<String, VRArmRenderer> vivecraft$getArmSkinMap();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.vivecraft.mixin.client_vr.renderer.entity;

import com.mojang.math.Axis;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
Expand Down Expand Up @@ -42,24 +41,7 @@ public abstract class EntityRenderDispatcherVRMixin implements ResourceManagerRe

@Inject(at = @At("HEAD"), method = "cameraOrientation", cancellable = true)
public void vivecraft$cameraOrientation(CallbackInfoReturnable<Quaternionf> cir) {
if (RenderPassType.isVanilla() || RenderPassType.isGuiOnly()) {
cir.setReturnValue(cameraOrientation);
} else {
Entity entity = ((LevelRendererExtension) Minecraft.getInstance().levelRenderer).vivecraft$getRenderedEntity();
if (entity == null) {
cir.setReturnValue(this.camera.rotation());
} else {
Vec3 vec3 = ClientDataHolderVR.getInstance().vrPlayer.getVRDataWorld().getEye(RenderPass.CENTER).getPosition();
if (ClientDataHolderVR.getInstance().currentPass == RenderPass.THIRD || ClientDataHolderVR.getInstance().currentPass == RenderPass.CAMERA) {
vec3 = ClientDataHolderVR.getInstance().vrPlayer.getVRDataWorld().getEye(ClientDataHolderVR.getInstance().currentPass).getPosition();
}
Vec3 vec31 = entity.position().add(0.0D, entity.getBbHeight() / 2.0F, 0.0D).subtract(vec3).normalize();
Quaternionf q = new Quaternionf();
q.mul(Axis.YP.rotationDegrees((float) (-Math.toDegrees(Math.atan2(-vec31.x, vec31.z)))));
q.mul(Axis.XP.rotationDegrees((float) (-Math.toDegrees(Math.asin(vec31.y / vec31.length())))));
cir.setReturnValue(q);
}
}
cir.setReturnValue(vivecraft$getCameraOrientation(0.5F, 0.0F));
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderers;createPlayerRenderers(Lnet/minecraft/client/renderer/entity/EntityRendererProvider$Context;)Ljava/util/Map;"),
Expand All @@ -72,7 +54,7 @@ public abstract class EntityRenderDispatcherVRMixin implements ResourceManagerRe

@Override
@Unique
public Quaternionf vivecraft$getCameraOrientationOffset(float offset) {
public Quaternionf vivecraft$getCameraOrientation(float scale, float offset) {
if (RenderPassType.isVanilla() || RenderPassType.isGuiOnly()) {
return cameraOrientation;
} else {
Expand All @@ -84,7 +66,7 @@ public abstract class EntityRenderDispatcherVRMixin implements ResourceManagerRe
if (ClientDataHolderVR.getInstance().currentPass == RenderPass.THIRD || ClientDataHolderVR.getInstance().currentPass == RenderPass.CAMERA) {
vec3 = ClientDataHolderVR.getInstance().vrPlayer.getVRDataWorld().getEye(ClientDataHolderVR.getInstance().currentPass).getPosition();
}
Vec3 vec31 = entity.position().add(0.0D, entity.getBbHeight() + offset, 0.0D).subtract(vec3).normalize();
Vec3 vec31 = entity.position().add(0.0D, entity.getBbHeight() * scale + offset, 0.0D).subtract(vec3).normalize();
Quaternionf q = new Quaternionf();
q.rotationYXZ(3.1415927F - (float) Math.atan2(-vec31.x, vec31.z),
(float) Math.asin(vec31.y / vec31.length()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class EntityRendererVRMixin {

@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;cameraOrientation()Lorg/joml/Quaternionf;"), method = "renderNameTag")
public Quaternionf vivecraft$cameraOffset(EntityRenderDispatcher instance) {
return ((EntityRenderDispatcherVRExtension) this.entityRenderDispatcher).vivecraft$getCameraOrientationOffset(0.5f);
return ((EntityRenderDispatcherVRExtension) this.entityRenderDispatcher).vivecraft$getCameraOrientation(1.0f, 0.5f);
}

@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getRopeHoldPosition(F)Lnet/minecraft/world/phys/Vec3;"), method = "renderLeash")
Expand Down

0 comments on commit d124dc2

Please sign in to comment.