use of com.infinityraider.agricraft.api.v1.client.IMagnifyingGlassInspector in project AgriCraft by AgriCraft.
the class MagnifyingGlassViewHandler method inspectionRender.
@SubscribeEvent
@SuppressWarnings("unused")
public void inspectionRender(RenderWorldLastEvent event) {
// Check if the player is in first person
if (!Minecraft.getInstance().gameSettings.getPointOfView().func_243192_a()) {
return;
}
// Check if an inspection renderer is present and cache it (another thread might set it to null)
IMagnifyingGlassInspector inspector = this.inspector;
if (inspector == null) {
return;
}
// Check if the inspector has a target and cache (another thread might set it to null)
Target target = this.lastTarget;
if (target == null) {
return;
}
// Fetch and push matrix to the matrix stack
MatrixStack transforms = event.getMatrixStack();
transforms.push();
// Correct for render view
Vector3d projectedView = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
transforms.translate(-projectedView.x, -projectedView.y, -projectedView.z);
// Move to the player's eye position
Vector3d eyes = this.getPlayer().getEyePosition(event.getPartialTicks());
transforms.translate(eyes.getX(), eyes.getY(), eyes.getZ());
// Fetch the player's target
Vector3d hit = target.getTargetVector(event.getPartialTicks());
Vector3d view = hit.subtract(eyes).normalize();
// Translate offset
transforms.translate(GENOME_OFFSET * view.getX(), GENOME_OFFSET * view.getY(), GENOME_OFFSET * view.getZ());
// Fetch player look orientation;
float yaw = (float) (Math.PI * this.getPlayer().getYaw(event.getPartialTicks())) / 180;
float pitch = (float) (Math.PI * this.getPlayer().getPitch(event.getPartialTicks())) / 180;
// Rotate for yaw
transforms.rotate(Vector3f.YP.rotation(-yaw));
// Render
transforms.push();
inspector.doInspectionRender(transforms, event.getPartialTicks(), target.getTargetEntity());
transforms.pop();
// Pop last transformation matrix from the stack
transforms.pop();
}
Aggregations