use of net.minecraft.client.render.Camera in project ImmersivePortalsMod by qouteall.
the class PortalRenderer method manageCameraAndRenderPortalContent.
// it will overwrite the matrix
protected final void manageCameraAndRenderPortalContent(Portal portal) {
if (getPortalLayer() > maxPortalLayer.get()) {
return;
}
Entity cameraEntity = mc.cameraEntity;
Camera camera = mc.gameRenderer.getCamera();
if (getPortalLayer() >= 2 && portal.getDistanceToNearestPointInPortal(cameraEntity.getPos()) > (16 * maxPortalLayer.get())) {
return;
}
MyRenderHelper.onBeginPortalWorldRendering(portalLayers);
assert cameraEntity.world == mc.world;
Vec3d oldPos = cameraEntity.getPos();
Vec3d oldLastTickPos = McHelper.lastTickPosOf(cameraEntity);
DimensionType oldDimension = cameraEntity.dimension;
ClientWorld oldWorld = ((ClientWorld) cameraEntity.world);
Vec3d oldCameraPos = camera.getPos();
Vec3d newPos = portal.applyTransformationToPoint(oldPos);
Vec3d newLastTickPos = portal.applyTransformationToPoint(oldLastTickPos);
DimensionType newDimension = portal.dimensionTo;
ClientWorld newWorld = CGlobal.clientWorldLoader.getOrCreateFakedWorld(newDimension);
// Vec3d newCameraPos = portal.applyTransformationToPoint(oldCameraPos);
Helper.setPosAndLastTickPos(cameraEntity, newPos, newLastTickPos);
cameraEntity.dimension = newDimension;
cameraEntity.world = newWorld;
mc.world = newWorld;
renderPortalContentWithContextSwitched(portal, oldCameraPos);
// restore the position
cameraEntity.dimension = oldDimension;
cameraEntity.world = oldWorld;
mc.world = oldWorld;
Helper.setPosAndLastTickPos(cameraEntity, oldPos, oldLastTickPos);
// restore the transformation
GlStateManager.enableDepthTest();
GlStateManager.disableBlend();
MyRenderHelper.setupCameraTransformation();
}
use of net.minecraft.client.render.Camera in project meteor-client by MeteorDevelopment.
the class ModelPredicateProviderRegistryMixin method onGetAngleToPos.
@Inject(method = "getAngleToPos(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/entity/Entity;)D", at = @At("HEAD"), cancellable = true)
private void onGetAngleToPos(Vec3d pos, Entity entity, CallbackInfoReturnable<Double> info) {
if (Modules.get().isActive(Freecam.class)) {
Camera camera = mc.gameRenderer.getCamera();
info.setReturnValue(Math.atan2(pos.getZ() - camera.getPos().z, pos.getX() - camera.getPos().x));
}
}
use of net.minecraft.client.render.Camera in project meteor-client by MeteorDevelopment.
the class MouseMixin method updateMouseChangeLookDirection.
@Redirect(method = "updateMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;changeLookDirection(DD)V"))
private void updateMouseChangeLookDirection(ClientPlayerEntity player, double cursorDeltaX, double cursorDeltaY) {
Freecam freecam = Modules.get().get(Freecam.class);
FreeLook freeLook = Modules.get().get(FreeLook.class);
if (freecam.isActive())
freecam.changeLookDirection(cursorDeltaX * 0.15, cursorDeltaY * 0.15);
else if (Modules.get().isActive(HighwayBuilder.class)) {
Camera camera = client.gameRenderer.getCamera();
((ICamera) camera).setRot(camera.getYaw() + cursorDeltaX * 0.15, camera.getPitch() + cursorDeltaY * 0.15);
} else if (freeLook.cameraMode()) {
freeLook.cameraYaw += cursorDeltaX / freeLook.sensitivity.get().floatValue();
freeLook.cameraPitch += cursorDeltaY / freeLook.sensitivity.get().floatValue();
if (Math.abs(freeLook.cameraPitch) > 90.0F)
freeLook.cameraPitch = freeLook.cameraPitch > 0.0F ? 90.0F : -90.0F;
} else
player.changeLookDirection(cursorDeltaX, cursorDeltaY);
}
use of net.minecraft.client.render.Camera in project BlockMeter by ModProg.
the class BlockMeterClient method renderOverlay.
public void renderOverlay(float partialTicks, MatrixStack stack) {
final MinecraftClient client = MinecraftClient.getInstance();
final Camera camera = client.gameRenderer.getCamera();
final Identifier currentDimension = client.player.world.getRegistryKey().getValue();
final ModConfig cfg = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
// MEH! but this seems to be needed to get the first background
// rectangle
client.textRenderer.draw(stack, "XXX", -100, -100, 0);
if (this.active || cfg.showBoxesWhenDisabled)
if (cfg.showOtherUsersBoxes) {
if (otherUsersBoxes != null && otherUsersBoxes.size() > 0) {
this.otherUsersBoxes.forEach((playerText, boxList) -> {
boxList.forEach(box -> box.render(camera, stack, currentDimension, playerText));
});
this.boxes.forEach(box -> {
if (!box.isFinished())
box.render(camera, stack, currentDimension);
});
}
if (!cfg.sendBoxes)
this.boxes.forEach(box -> {
if (box.isFinished())
box.render(camera, stack, currentDimension, client.player.getDisplayName());
else
box.render(camera, stack, currentDimension);
});
} else
this.boxes.forEach(box -> box.render(camera, stack, currentDimension));
}
use of net.minecraft.client.render.Camera in project Skyblocker by LifeIsAParadox.
the class RenderUtils method matrixFrom.
// -------------------- Utils --------------------
public static MatrixStack matrixFrom(double x, double y, double z) {
MatrixStack matrices = new MatrixStack();
Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F));
matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z);
return matrices;
}
Aggregations