Search in sources :

Example 1 with Freecam

use of dev.hypnotic.module.render.Freecam in project Hypnotic-Client by Hypnotic-Development.

the class CameraMixin method onUpdateSetPosArgs.

@ModifyArgs(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V"))
private void onUpdateSetPosArgs(Args args) {
    Freecam freecam = ModuleManager.INSTANCE.getModule(Freecam.class);
    if (freecam.isEnabled()) {
        args.set(0, freecam.getX(tickDelta));
        args.set(1, freecam.getY(tickDelta));
        args.set(2, freecam.getZ(tickDelta));
    }
}
Also used : Freecam(dev.hypnotic.module.render.Freecam) ModifyArgs(org.spongepowered.asm.mixin.injection.ModifyArgs)

Example 2 with Freecam

use of dev.hypnotic.module.render.Freecam in project Hypnotic-Client by Hypnotic-Development.

the class GameRendererMixin method updateTargetedEntityInvoke.

@Inject(method = "updateTargetedEntity", at = @At("HEAD"), cancellable = true)
private void updateTargetedEntityInvoke(float tickDelta, CallbackInfo info) {
    Freecam freecam = ModuleManager.INSTANCE.getModule(Freecam.class);
    if ((freecam.isEnabled()) && mc.getCameraEntity() != null && !freecamSet) {
        info.cancel();
        Entity cameraE = mc.getCameraEntity();
        double x = cameraE.getX();
        double y = cameraE.getY();
        double z = cameraE.getZ();
        double prevX = cameraE.prevX;
        double prevY = cameraE.prevY;
        double prevZ = cameraE.prevZ;
        float yaw = cameraE.getYaw();
        float pitch = cameraE.getPitch();
        float prevYaw = cameraE.prevYaw;
        float prevPitch = cameraE.prevPitch;
        ((IVec3d) cameraE.getPos()).set(freecam.pos.x, freecam.pos.y - cameraE.getEyeHeight(cameraE.getPose()), freecam.pos.z);
        cameraE.prevX = freecam.prevPos.x;
        cameraE.prevY = freecam.prevPos.y - cameraE.getEyeHeight(cameraE.getPose());
        cameraE.prevZ = freecam.prevPos.z;
        freecamSet = true;
        updateTargetedEntity(tickDelta);
        freecamSet = false;
        ((IVec3d) cameraE.getPos()).set(x, y, z);
        cameraE.prevX = prevX;
        cameraE.prevY = prevY;
        cameraE.prevZ = prevZ;
        cameraE.setYaw(yaw);
        cameraE.setPitch(pitch);
        cameraE.prevYaw = prevYaw;
        cameraE.prevPitch = prevPitch;
    }
}
Also used : Entity(net.minecraft.entity.Entity) IVec3d(dev.hypnotic.utils.mixin.IVec3d) Freecam(dev.hypnotic.module.render.Freecam) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

Freecam (dev.hypnotic.module.render.Freecam)2 IVec3d (dev.hypnotic.utils.mixin.IVec3d)1 Entity (net.minecraft.entity.Entity)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 ModifyArgs (org.spongepowered.asm.mixin.injection.ModifyArgs)1