Search in sources :

Example 11 with Camera

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();
}
Also used : Entity(net.minecraft.entity.Entity) DimensionType(net.minecraft.world.dimension.DimensionType) Camera(net.minecraft.client.render.Camera) ClientWorld(net.minecraft.client.world.ClientWorld) Vec3d(net.minecraft.util.math.Vec3d)

Example 12 with Camera

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));
    }
}
Also used : Camera(net.minecraft.client.render.Camera) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 13 with Camera

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);
}
Also used : HighwayBuilder(meteordevelopment.meteorclient.systems.modules.world.HighwayBuilder) Freecam(meteordevelopment.meteorclient.systems.modules.render.Freecam) ICamera(meteordevelopment.meteorclient.mixininterface.ICamera) Camera(net.minecraft.client.render.Camera) FreeLook(meteordevelopment.meteorclient.systems.modules.render.FreeLook) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 14 with Camera

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));
}
Also used : PacketSender(net.fabricmc.fabric.api.networking.v1.PacketSender) Item(net.minecraft.item.Item) OptionsGui(win.baruna.blockmeter.gui.OptionsGui) ConfigManager(me.shedaniel.autoconfig.ConfigManager) TranslatableText(net.minecraft.text.TranslatableText) PacketByteBuf(net.minecraft.network.PacketByteBuf) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Unpooled(io.netty.buffer.Unpooled) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) UseBlockCallback(net.fabricmc.fabric.api.event.player.UseBlockCallback) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) ClientModInitializer(net.fabricmc.api.ClientModInitializer) ClientPlayNetworking(net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking) PlayerEntity(net.minecraft.entity.player.PlayerEntity) KeyBindingHelper(net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper) InputUtil(net.minecraft.client.util.InputUtil) MatrixStack(net.minecraft.client.util.math.MatrixStack) BlockHitResult(net.minecraft.util.hit.BlockHitResult) BlockPos(net.minecraft.util.math.BlockPos) KeyBinding(net.minecraft.client.option.KeyBinding) GLFW(org.lwjgl.glfw.GLFW) Toml4jConfigSerializer(me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer) ActionResult(net.minecraft.util.ActionResult) HitResult(net.minecraft.util.hit.HitResult) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) DyeColor(net.minecraft.util.DyeColor) SelectBoxGui(win.baruna.blockmeter.gui.SelectBoxGui) AutoConfig(me.shedaniel.autoconfig.AutoConfig) Identifier(net.minecraft.util.Identifier) ClientTickEvents(net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents) MinecraftClient(net.minecraft.client.MinecraftClient) Text(net.minecraft.text.Text) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) Camera(net.minecraft.client.render.Camera) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) Camera(net.minecraft.client.render.Camera)

Example 15 with Camera

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;
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack) Camera(net.minecraft.client.render.Camera)

Aggregations

Camera (net.minecraft.client.render.Camera)25 MatrixStack (net.minecraft.client.util.math.MatrixStack)11 Vec3d (net.minecraft.util.math.Vec3d)6 MinecraftClient (net.minecraft.client.MinecraftClient)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3 Matrix4f (net.minecraft.util.math.Matrix4f)3 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)2 List (java.util.List)2 BufferBuilder (net.minecraft.client.render.BufferBuilder)2 GameRenderer (net.minecraft.client.render.GameRenderer)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 CameraInvoker (com.glisco.isometricrenders.mixin.CameraInvoker)1 Lists (com.google.common.collect.Lists)1 IEGameRenderer (com.qouteall.immersive_portals.ducks.IEGameRenderer)1 EventTarget (dev.hypnotic.event.EventTarget)1 Freecam (dev.hypnotic.module.render.Freecam)1 QuadColor (dev.hypnotic.utils.render.QuadColor)1 Waypoint (dev.hypnotic.waypoint.Waypoint)1 Unpooled (io.netty.buffer.Unpooled)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1