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;
}
}
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;
}
Aggregations