Search in sources :

Example 1 with IVec3d

use of dev.hypnotic.utils.mixin.IVec3d 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)

Example 2 with IVec3d

use of dev.hypnotic.utils.mixin.IVec3d in project Hypnotic-Client by Hypnotic-Development.

the class WorldUtils method place.

public static boolean place(BlockPos blockPos, Hand hand, int slot, boolean rotate, int rotationPriority, boolean swingHand, boolean checkEntities, boolean swapBack) {
    if (slot < 0 || slot > 8)
        return false;
    if (!canPlace(blockPos, checkEntities))
        return false;
    ((IVec3d) hitPos).set(blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5);
    BlockPos neighbour;
    Direction side = getPlaceSide(blockPos);
    if (side == null) {
        side = Direction.UP;
        neighbour = blockPos;
    } else {
        neighbour = blockPos.offset(side.getOpposite());
        hitPos.add(side.getOffsetX() * 0.5, side.getOffsetY() * 0.5, side.getOffsetZ() * 0.5);
    }
    Direction s = side;
    if (rotate) {
        RotationUtils.rotate(RotationUtils.getYaw(hitPos), RotationUtils.getPitch(hitPos), rotationPriority, () -> {
            InventoryUtils.swap(slot, swapBack);
            place(new BlockHitResult(hitPos, s, neighbour, false), hand, swingHand);
            if (swapBack)
                InventoryUtils.swapBack();
        });
    } else {
        InventoryUtils.swap(slot, swapBack);
        place(new BlockHitResult(hitPos, s, neighbour, false), hand, swingHand);
        if (swapBack)
            InventoryUtils.swapBack();
    }
    return true;
}
Also used : IVec3d(dev.hypnotic.utils.mixin.IVec3d) BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Direction(net.minecraft.util.math.Direction)

Aggregations

IVec3d (dev.hypnotic.utils.mixin.IVec3d)2 Freecam (dev.hypnotic.module.render.Freecam)1 Entity (net.minecraft.entity.Entity)1 BlockHitResult (net.minecraft.util.hit.BlockHitResult)1 BlockPos (net.minecraft.util.math.BlockPos)1 Direction (net.minecraft.util.math.Direction)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1